Skip to content

Commit

Permalink
refator: fixed tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Yashk767 committed Apr 11, 2024
1 parent 8e90d1a commit 5a7a24c
Show file tree
Hide file tree
Showing 5 changed files with 701 additions and 682 deletions.
9 changes: 5 additions & 4 deletions cmd/commit_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (
"github.com/ethereum/go-ethereum/ethclient"
"github.com/stretchr/testify/mock"
"math/big"
clientPkg "razor/client"
"razor/core"
"razor/core/types"
"razor/pkg/bindings"
Expand Down Expand Up @@ -228,11 +229,11 @@ func TestHandleCommitState(t *testing.T) {
utilsMock.On("GetNumActiveCollections", mock.AnythingOfType("*ethclient.Client")).Return(tt.args.numActiveCollections, tt.args.numActiveCollectionsErr)
utilsMock.On("GetAssignedCollections", mock.AnythingOfType("*ethclient.Client"), mock.Anything, mock.Anything).Return(tt.args.assignedCollections, tt.args.seqAllottedCollections, tt.args.assignedCollectionsErr)
utilsMock.On("GetCollectionIdFromIndex", mock.AnythingOfType("*ethclient.Client"), mock.Anything).Return(tt.args.collectionId, tt.args.collectionIdErr)
utilsMock.On("GetAggregatedDataOfCollection", mock.AnythingOfType("*ethclient.Client"), mock.Anything, mock.Anything, mock.Anything).Return(tt.args.collectionData, tt.args.collectionDataErr)
utilsMock.On("GetAggregatedDataOfCollection", mock.AnythingOfType("*ethclient.Client"), mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tt.args.collectionData, tt.args.collectionDataErr)
utilsMock.On("GetRogueRandomValue", mock.Anything).Return(rogueValue)

utils := &UtilsStruct{}
got, err := utils.HandleCommitState(client, epoch, seed, tt.args.rogueData)
got, err := utils.HandleCommitState(client, epoch, seed, &clientPkg.HttpClient{}, tt.args.rogueData)
if !reflect.DeepEqual(got, tt.want) {
t.Errorf("Data from HandleCommitState function, got = %v, want = %v", got, tt.want)
}
Expand Down Expand Up @@ -393,11 +394,11 @@ func BenchmarkHandleCommitState(b *testing.B) {
utilsMock.On("GetNumActiveCollections", mock.AnythingOfType("*ethclient.Client")).Return(v.numActiveCollections, nil)
utilsMock.On("GetAssignedCollections", mock.AnythingOfType("*ethclient.Client"), mock.Anything, mock.Anything).Return(v.assignedCollections, nil, nil)
utilsMock.On("GetCollectionIdFromIndex", mock.AnythingOfType("*ethclient.Client"), mock.Anything).Return(uint16(1), nil)
utilsMock.On("GetAggregatedDataOfCollection", mock.AnythingOfType("*ethclient.Client"), mock.Anything, mock.Anything, mock.Anything).Return(big.NewInt(1000), nil)
utilsMock.On("GetAggregatedDataOfCollection", mock.AnythingOfType("*ethclient.Client"), mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(big.NewInt(1000), nil)
utilsMock.On("GetRogueRandomValue", mock.Anything).Return(rogueValue)

ut := &UtilsStruct{}
_, err := ut.HandleCommitState(client, epoch, seed, types.Rogue{IsRogue: false})
_, err := ut.HandleCommitState(client, epoch, seed, &clientPkg.HttpClient{}, types.Rogue{IsRogue: false})
if err != nil {
log.Fatal(err)
}
Expand Down
Loading

0 comments on commit 5a7a24c

Please sign in to comment.