diff --git a/cmd/commit.go b/cmd/commit.go index 6e0252bbd..83a496142 100644 --- a/cmd/commit.go +++ b/cmd/commit.go @@ -61,7 +61,7 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se return types.CommitData{}, err } log.Debug("HandleCommitState: Number of active collections: ", numActiveCollections) - log.Debugf("HandleCommitState: Calling GetAssignedCollections() with arguments number of active collections = %d, seed = %v", numActiveCollections, seed) + log.Debugf("HandleCommitState: Calling GetAssignedCollections() with arguments number of active collections = %d", numActiveCollections) assignedCollections, seqAllottedCollections, err := razorUtils.GetAssignedCollections(client, numActiveCollections, seed) if err != nil { return types.CommitData{}, err @@ -112,15 +112,18 @@ func (*UtilsStruct) HandleCommitState(client *ethclient.Client, epoch uint32, se /* Commit finally commits the data to the smart contract. It calculates the commitment to send using the merkle tree root and the seed. */ -func (*UtilsStruct) Commit(client *ethclient.Client, config types.Configurations, account types.Account, epoch uint32, seed []byte, root [32]byte) (common.Hash, error) { +func (*UtilsStruct) Commit(client *ethclient.Client, config types.Configurations, account types.Account, epoch uint32, seed []byte, values []*big.Int) (common.Hash, error) { if state, err := razorUtils.GetBufferedState(client, config.BufferPercent); err != nil || state != 0 { log.Error("Not commit state") return core.NilHash, err } - commitment := solsha3.SoliditySHA3([]string{"bytes32", "bytes32"}, []interface{}{"0x" + hex.EncodeToString(root[:]), "0x" + hex.EncodeToString(seed)}) - commitmentToSend := [32]byte{} - copy(commitmentToSend[:], commitment) + commitmentToSend, err := CalculateCommitment(seed, values) + if err != nil { + log.Error("Error in getting commitment: ", err) + return core.NilHash, err + } + txnOpts := razorUtils.GetTxnOpts(types.TransactionOptions{ Client: client, Password: account.Password, @@ -133,8 +136,6 @@ func (*UtilsStruct) Commit(client *ethclient.Client, config types.Configurations Parameters: []interface{}{epoch, commitmentToSend}, }) - log.Debugf("Committing: epoch: %d, commitment: %s, seed: %s, account: %s", epoch, "0x"+hex.EncodeToString(commitment), "0x"+hex.EncodeToString(seed), account.Address) - log.Info("Commitment sent...") log.Debugf("Executing Commit transaction with epoch = %d, commitmentToSend = %v", epoch, commitmentToSend) txn, err := voteManagerUtils.Commit(client, txnOpts, epoch, commitmentToSend) @@ -145,3 +146,67 @@ func (*UtilsStruct) Commit(client *ethclient.Client, config types.Configurations log.Info("Txn Hash: ", txnHash.Hex()) return txnHash, nil } + +func CalculateSeed(client *ethclient.Client, account types.Account, keystorePath string, epoch uint32) ([]byte, error) { + log.Debugf("CalculateSeed: Calling CalculateSecret() with arguments epoch = %d, keystorePath = %s, chainId = %s", epoch, keystorePath, core.ChainId) + _, secret, err := cmdUtils.CalculateSecret(account, epoch, keystorePath, core.ChainId) + if err != nil { + return nil, err + } + log.Debugf("CalculateSeed: Getting Salt for current epoch %d...", epoch) + salt, err := cmdUtils.GetSalt(client, epoch) + if err != nil { + log.Error("Error in getting salt: ", err) + return nil, err + } + seed := solsha3.SoliditySHA3([]string{"bytes32", "bytes32"}, []interface{}{"0x" + hex.EncodeToString(salt[:]), "0x" + hex.EncodeToString(secret)}) + return seed, nil +} + +func CalculateCommitment(seed []byte, values []*big.Int) ([32]byte, error) { + log.Debug("CalculateCommitment: Calling CreateMerkle() with argument Leaves = ", values) + merkleTree, err := merkleUtils.CreateMerkle(values) + if err != nil { + return [32]byte{}, errors.New("Error in getting merkle tree: " + err.Error()) + } + log.Debug("CalculateCommitment: Merkle Tree: ", merkleTree) + log.Debug("CalculateCommitment: Calling GetMerkleRoot() for the merkle tree...") + merkleRoot, err := merkleUtils.GetMerkleRoot(merkleTree) + if err != nil { + return [32]byte{}, errors.New("Error in getting root: " + err.Error()) + } + commitment := solsha3.SoliditySHA3([]string{"bytes32", "bytes32"}, []interface{}{"0x" + hex.EncodeToString(merkleRoot[:]), "0x" + hex.EncodeToString(seed)}) + log.Debug("CalculateCommitment: Commitment: ", hex.EncodeToString(commitment)) + commitmentToSend := [32]byte{} + copy(commitmentToSend[:], commitment) + return commitmentToSend, nil +} + +func VerifyCommitment(client *ethclient.Client, account types.Account, keystorePath string, epoch uint32, values []*big.Int) (bool, error) { + commitmentStruct, err := razorUtils.GetCommitment(client, account.Address) + if err != nil { + log.Error("Error in getting commitments: ", err) + return false, err + } + log.Debugf("VerifyCommitment: CommitmentStruct: %+v", commitmentStruct) + + seed, err := CalculateSeed(client, account, keystorePath, epoch) + if err != nil { + log.Error("Error in calculating seed: ", err) + return false, err + } + + calculatedCommitment, err := CalculateCommitment(seed, values) + if err != nil { + log.Error("Error in calculating commitment for given committed values: ", err) + return false, err + } + log.Debug("VerifyCommitment: Calculated commitment: ", calculatedCommitment) + + if calculatedCommitment == commitmentStruct.CommitmentHash { + log.Debug("VerifyCommitment: Calculated commitment for given values is EQUAL to commitment of the epoch") + return true, nil + } + log.Debug("VerifyCommitment: Calculated commitment for given values DOES NOT MATCH with commitment in the epoch") + return false, nil +} diff --git a/cmd/commit_test.go b/cmd/commit_test.go index 983d084e1..5c3fdf9cb 100644 --- a/cmd/commit_test.go +++ b/cmd/commit_test.go @@ -15,6 +15,7 @@ import ( "razor/core" "razor/core/types" "razor/pkg/bindings" + "razor/utils" "reflect" "testing" ) @@ -31,9 +32,9 @@ func TestCommit(t *testing.T) { txnOpts, _ := bind.NewKeyedTransactorWithChainID(privateKey, big.NewInt(1)) type args struct { + values []*big.Int state int64 stateErr error - root [32]byte txnOpts *bind.TransactOpts commitTxn *Types.Transaction commitErr error @@ -48,6 +49,7 @@ func TestCommit(t *testing.T) { { name: "Test 1: When Commit function executes successfully", args: args{ + values: []*big.Int{big.NewInt(1)}, state: 0, stateErr: nil, txnOpts: txnOpts, @@ -61,6 +63,7 @@ func TestCommit(t *testing.T) { { name: "Test 2: When there is an error in getting state", args: args{ + values: []*big.Int{big.NewInt(1)}, stateErr: errors.New("state error"), txnOpts: txnOpts, commitTxn: &Types.Transaction{}, @@ -73,6 +76,7 @@ func TestCommit(t *testing.T) { { name: "Test 3: When Commit transaction fails", args: args{ + values: []*big.Int{big.NewInt(1)}, state: 0, stateErr: nil, txnOpts: txnOpts, @@ -88,13 +92,16 @@ func TestCommit(t *testing.T) { t.Run(tt.name, func(t *testing.T) { SetUpMockInterfaces() + utils.MerkleInterface = &utils.MerkleTreeStruct{} + merkleUtils = utils.MerkleInterface + utilsMock.On("GetBufferedState", mock.AnythingOfType("*ethclient.Client"), mock.AnythingOfType("int32")).Return(tt.args.state, tt.args.stateErr) utilsMock.On("GetTxnOpts", mock.AnythingOfType("types.TransactionOptions")).Return(tt.args.txnOpts) voteManagerMock.On("Commit", mock.AnythingOfType("*ethclient.Client"), mock.AnythingOfType("*bind.TransactOpts"), mock.AnythingOfType("uint32"), mock.Anything).Return(tt.args.commitTxn, tt.args.commitErr) transactionMock.On("Hash", mock.AnythingOfType("*types.Transaction")).Return(tt.args.hash) utils := &UtilsStruct{} - got, err := utils.Commit(client, config, account, epoch, seed, tt.args.root) + got, err := utils.Commit(client, config, account, epoch, seed, tt.args.values) if got != tt.want { t.Errorf("Txn hash for Commit function, got = %v, want = %v", got, tt.want) } diff --git a/cmd/interface.go b/cmd/interface.go index 3934c810b..a168b638e 100644 --- a/cmd/interface.go +++ b/cmd/interface.go @@ -188,7 +188,7 @@ type UtilsCmdInterface interface { ClaimBlockReward(options types.TransactionOptions) (common.Hash, error) GetSalt(client *ethclient.Client, epoch uint32) ([32]byte, error) HandleCommitState(client *ethclient.Client, epoch uint32, seed []byte, rogueData types.Rogue) (types.CommitData, error) - Commit(client *ethclient.Client, config types.Configurations, account types.Account, epoch uint32, seed []byte, root [32]byte) (common.Hash, error) + Commit(client *ethclient.Client, config types.Configurations, account types.Account, epoch uint32, seed []byte, values []*big.Int) (common.Hash, error) ListAccounts() ([]accounts.Account, error) AssignAmountInWei(flagSet *pflag.FlagSet) (*big.Int, error) ExecuteTransfer(flagSet *pflag.FlagSet) diff --git a/cmd/mocks/utils_cmd_interface.go b/cmd/mocks/utils_cmd_interface.go index 2a96d3ac6..9b8b794a0 100644 --- a/cmd/mocks/utils_cmd_interface.go +++ b/cmd/mocks/utils_cmd_interface.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. +// Code generated by mockery v2.30.1. DO NOT EDIT. package mocks @@ -36,6 +36,10 @@ func (_m *UtilsCmdInterface) Approve(txnArgs types.TransactionOptions) (common.H ret := _m.Called(txnArgs) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(types.TransactionOptions) (common.Hash, error)); ok { + return rf(txnArgs) + } if rf, ok := ret.Get(0).(func(types.TransactionOptions) common.Hash); ok { r0 = rf(txnArgs) } else { @@ -44,7 +48,6 @@ func (_m *UtilsCmdInterface) Approve(txnArgs types.TransactionOptions) (common.H } } - var r1 error if rf, ok := ret.Get(1).(func(types.TransactionOptions) error); ok { r1 = rf(txnArgs) } else { @@ -59,6 +62,10 @@ func (_m *UtilsCmdInterface) ApproveUnstake(client *ethclient.Client, stakerToke ret := _m.Called(client, stakerTokenAddress, txnArgs) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, common.Address, types.TransactionOptions) (common.Hash, error)); ok { + return rf(client, stakerTokenAddress, txnArgs) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, common.Address, types.TransactionOptions) common.Hash); ok { r0 = rf(client, stakerTokenAddress, txnArgs) } else { @@ -67,7 +74,6 @@ func (_m *UtilsCmdInterface) ApproveUnstake(client *ethclient.Client, stakerToke } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, common.Address, types.TransactionOptions) error); ok { r1 = rf(client, stakerTokenAddress, txnArgs) } else { @@ -82,6 +88,10 @@ func (_m *UtilsCmdInterface) AssignAmountInWei(flagSet *pflag.FlagSet) (*big.Int ret := _m.Called(flagSet) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*pflag.FlagSet) (*big.Int, error)); ok { + return rf(flagSet) + } if rf, ok := ret.Get(0).(func(*pflag.FlagSet) *big.Int); ok { r0 = rf(flagSet) } else { @@ -90,7 +100,6 @@ func (_m *UtilsCmdInterface) AssignAmountInWei(flagSet *pflag.FlagSet) (*big.Int } } - var r1 error if rf, ok := ret.Get(1).(func(*pflag.FlagSet) error); ok { r1 = rf(flagSet) } else { @@ -105,6 +114,11 @@ func (_m *UtilsCmdInterface) CalculateSecret(account types.Account, epoch uint32 ret := _m.Called(account, epoch, keystorePath, chainId) var r0 []byte + var r1 []byte + var r2 error + if rf, ok := ret.Get(0).(func(types.Account, uint32, string, *big.Int) ([]byte, []byte, error)); ok { + return rf(account, epoch, keystorePath, chainId) + } if rf, ok := ret.Get(0).(func(types.Account, uint32, string, *big.Int) []byte); ok { r0 = rf(account, epoch, keystorePath, chainId) } else { @@ -113,7 +127,6 @@ func (_m *UtilsCmdInterface) CalculateSecret(account types.Account, epoch uint32 } } - var r1 []byte if rf, ok := ret.Get(1).(func(types.Account, uint32, string, *big.Int) []byte); ok { r1 = rf(account, epoch, keystorePath, chainId) } else { @@ -122,7 +135,6 @@ func (_m *UtilsCmdInterface) CalculateSecret(account types.Account, epoch uint32 } } - var r2 error if rf, ok := ret.Get(2).(func(types.Account, uint32, string, *big.Int) error); ok { r2 = rf(account, epoch, keystorePath, chainId) } else { @@ -137,13 +149,16 @@ func (_m *UtilsCmdInterface) CheckCurrentStatus(client *ethclient.Client, collec ret := _m.Called(client, collectionId) var r0 bool + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) (bool, error)); ok { + return rf(client, collectionId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) bool); ok { r0 = rf(client, collectionId) } else { r0 = ret.Get(0).(bool) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16) error); ok { r1 = rf(client, collectionId) } else { @@ -158,6 +173,10 @@ func (_m *UtilsCmdInterface) CheckDisputeForIds(client *ethclient.Client, transa ret := _m.Called(client, transactionOpts, epoch, blockIndex, idsInProposedBlock, revealedCollectionIds) var r0 *coretypes.Transaction + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.TransactionOptions, uint32, uint8, []uint16, []uint16) (*coretypes.Transaction, error)); ok { + return rf(client, transactionOpts, epoch, blockIndex, idsInProposedBlock, revealedCollectionIds) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.TransactionOptions, uint32, uint8, []uint16, []uint16) *coretypes.Transaction); ok { r0 = rf(client, transactionOpts, epoch, blockIndex, idsInProposedBlock, revealedCollectionIds) } else { @@ -166,7 +185,6 @@ func (_m *UtilsCmdInterface) CheckDisputeForIds(client *ethclient.Client, transa } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.TransactionOptions, uint32, uint8, []uint16, []uint16) error); ok { r1 = rf(client, transactionOpts, epoch, blockIndex, idsInProposedBlock, revealedCollectionIds) } else { @@ -200,6 +218,10 @@ func (_m *UtilsCmdInterface) ClaimBlockReward(options types.TransactionOptions) ret := _m.Called(options) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(types.TransactionOptions) (common.Hash, error)); ok { + return rf(options) + } if rf, ok := ret.Get(0).(func(types.TransactionOptions) common.Hash); ok { r0 = rf(options) } else { @@ -208,7 +230,6 @@ func (_m *UtilsCmdInterface) ClaimBlockReward(options types.TransactionOptions) } } - var r1 error if rf, ok := ret.Get(1).(func(types.TransactionOptions) error); ok { r1 = rf(options) } else { @@ -223,6 +244,10 @@ func (_m *UtilsCmdInterface) ClaimBounty(config types.Configurations, client *et ret := _m.Called(config, client, redeemBountyInput) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(types.Configurations, *ethclient.Client, types.RedeemBountyInput) (common.Hash, error)); ok { + return rf(config, client, redeemBountyInput) + } if rf, ok := ret.Get(0).(func(types.Configurations, *ethclient.Client, types.RedeemBountyInput) common.Hash); ok { r0 = rf(config, client, redeemBountyInput) } else { @@ -231,7 +256,6 @@ func (_m *UtilsCmdInterface) ClaimBounty(config types.Configurations, client *et } } - var r1 error if rf, ok := ret.Get(1).(func(types.Configurations, *ethclient.Client, types.RedeemBountyInput) error); ok { r1 = rf(config, client, redeemBountyInput) } else { @@ -246,22 +270,25 @@ func (_m *UtilsCmdInterface) ClaimCommission(flagSet *pflag.FlagSet) { _m.Called(flagSet) } -// Commit provides a mock function with given fields: client, config, account, epoch, seed, root -func (_m *UtilsCmdInterface) Commit(client *ethclient.Client, config types.Configurations, account types.Account, epoch uint32, seed []byte, root [32]byte) (common.Hash, error) { - ret := _m.Called(client, config, account, epoch, seed, root) +// Commit provides a mock function with given fields: client, config, account, epoch, seed, values +func (_m *UtilsCmdInterface) Commit(client *ethclient.Client, config types.Configurations, account types.Account, epoch uint32, seed []byte, values []*big.Int) (common.Hash, error) { + ret := _m.Called(client, config, account, epoch, seed, values) var r0 common.Hash - if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.Account, uint32, []byte, [32]byte) common.Hash); ok { - r0 = rf(client, config, account, epoch, seed, root) + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.Account, uint32, []byte, []*big.Int) (common.Hash, error)); ok { + return rf(client, config, account, epoch, seed, values) + } + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.Account, uint32, []byte, []*big.Int) common.Hash); ok { + r0 = rf(client, config, account, epoch, seed, values) } else { if ret.Get(0) != nil { r0 = ret.Get(0).(common.Hash) } } - var r1 error - if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.Account, uint32, []byte, [32]byte) error); ok { - r1 = rf(client, config, account, epoch, seed, root) + if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.Account, uint32, []byte, []*big.Int) error); ok { + r1 = rf(client, config, account, epoch, seed, values) } else { r1 = ret.Error(1) } @@ -279,13 +306,16 @@ func (_m *UtilsCmdInterface) Create(password string) (accounts.Account, error) { ret := _m.Called(password) var r0 accounts.Account + var r1 error + if rf, ok := ret.Get(0).(func(string) (accounts.Account, error)); ok { + return rf(password) + } if rf, ok := ret.Get(0).(func(string) accounts.Account); ok { r0 = rf(password) } else { r0 = ret.Get(0).(accounts.Account) } - var r1 error if rf, ok := ret.Get(1).(func(string) error); ok { r1 = rf(password) } else { @@ -300,6 +330,10 @@ func (_m *UtilsCmdInterface) CreateCollection(client *ethclient.Client, config t ret := _m.Called(client, config, collectionInput) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateCollectionInput) (common.Hash, error)); ok { + return rf(client, config, collectionInput) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateCollectionInput) common.Hash); ok { r0 = rf(client, config, collectionInput) } else { @@ -308,7 +342,6 @@ func (_m *UtilsCmdInterface) CreateCollection(client *ethclient.Client, config t } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.CreateCollectionInput) error); ok { r1 = rf(client, config, collectionInput) } else { @@ -323,6 +356,10 @@ func (_m *UtilsCmdInterface) CreateJob(client *ethclient.Client, config types.Co ret := _m.Called(client, config, jobInput) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateJobInput) (common.Hash, error)); ok { + return rf(client, config, jobInput) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateJobInput) common.Hash); ok { r0 = rf(client, config, jobInput) } else { @@ -331,7 +368,6 @@ func (_m *UtilsCmdInterface) CreateJob(client *ethclient.Client, config types.Co } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.CreateJobInput) error); ok { r1 = rf(client, config, jobInput) } else { @@ -346,6 +382,10 @@ func (_m *UtilsCmdInterface) Delegate(txnArgs types.TransactionOptions, stakerId ret := _m.Called(txnArgs, stakerId) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(types.TransactionOptions, uint32) (common.Hash, error)); ok { + return rf(txnArgs, stakerId) + } if rf, ok := ret.Get(0).(func(types.TransactionOptions, uint32) common.Hash); ok { r0 = rf(txnArgs, stakerId) } else { @@ -354,7 +394,6 @@ func (_m *UtilsCmdInterface) Delegate(txnArgs types.TransactionOptions, stakerId } } - var r1 error if rf, ok := ret.Get(1).(func(types.TransactionOptions, uint32) error); ok { r1 = rf(txnArgs, stakerId) } else { @@ -512,13 +551,16 @@ func (_m *UtilsCmdInterface) GetAlternateProvider() (string, error) { ret := _m.Called() var r0 string + var r1 error + if rf, ok := ret.Get(0).(func() (string, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() } else { r0 = ret.Get(0).(string) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -533,6 +575,11 @@ func (_m *UtilsCmdInterface) GetBiggestStakeAndId(client *ethclient.Client, addr ret := _m.Called(client, address, epoch) var r0 *big.Int + var r1 uint32 + var r2 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, string, uint32) (*big.Int, uint32, error)); ok { + return rf(client, address, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, string, uint32) *big.Int); ok { r0 = rf(client, address, epoch) } else { @@ -541,14 +588,12 @@ func (_m *UtilsCmdInterface) GetBiggestStakeAndId(client *ethclient.Client, addr } } - var r1 uint32 if rf, ok := ret.Get(1).(func(*ethclient.Client, string, uint32) uint32); ok { r1 = rf(client, address, epoch) } else { r1 = ret.Get(1).(uint32) } - var r2 error if rf, ok := ret.Get(2).(func(*ethclient.Client, string, uint32) error); ok { r2 = rf(client, address, epoch) } else { @@ -563,13 +608,16 @@ func (_m *UtilsCmdInterface) GetBountyIdFromEvents(client *ethclient.Client, blo ret := _m.Called(client, blockNumber, bountyHunter) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, string) (uint32, error)); ok { + return rf(client, blockNumber, bountyHunter) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, string) uint32); ok { r0 = rf(client, blockNumber, bountyHunter) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, *big.Int, string) error); ok { r1 = rf(client, blockNumber, bountyHunter) } else { @@ -584,13 +632,16 @@ func (_m *UtilsCmdInterface) GetBufferPercent() (int32, error) { ret := _m.Called() var r0 int32 + var r1 error + if rf, ok := ret.Get(0).(func() (int32, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int32); ok { r0 = rf() } else { r0 = ret.Get(0).(int32) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -635,13 +686,16 @@ func (_m *UtilsCmdInterface) GetConfigData() (types.Configurations, error) { ret := _m.Called() var r0 types.Configurations + var r1 error + if rf, ok := ret.Get(0).(func() (types.Configurations, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() types.Configurations); ok { r0 = rf() } else { r0 = ret.Get(0).(types.Configurations) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -656,20 +710,23 @@ func (_m *UtilsCmdInterface) GetEpochAndState(client *ethclient.Client) (uint32, ret := _m.Called(client) var r0 uint32 + var r1 int64 + var r2 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint32, int64, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint32); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint32) } - var r1 int64 if rf, ok := ret.Get(1).(func(*ethclient.Client) int64); ok { r1 = rf(client) } else { r1 = ret.Get(1).(int64) } - var r2 error if rf, ok := ret.Get(2).(func(*ethclient.Client) error); ok { r2 = rf(client) } else { @@ -684,13 +741,16 @@ func (_m *UtilsCmdInterface) GetGasLimit() (float32, error) { ret := _m.Called() var r0 float32 + var r1 error + if rf, ok := ret.Get(0).(func() (float32, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() float32); ok { r0 = rf() } else { r0 = ret.Get(0).(float32) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -705,13 +765,16 @@ func (_m *UtilsCmdInterface) GetGasLimitOverride() (uint64, error) { ret := _m.Called() var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func() (uint64, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() uint64); ok { r0 = rf() } else { r0 = ret.Get(0).(uint64) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -726,13 +789,16 @@ func (_m *UtilsCmdInterface) GetGasPrice() (int32, error) { ret := _m.Called() var r0 int32 + var r1 error + if rf, ok := ret.Get(0).(func() (int32, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int32); ok { r0 = rf() } else { r0 = ret.Get(0).(int32) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -747,13 +813,16 @@ func (_m *UtilsCmdInterface) GetHTTPTimeout() (int64, error) { ret := _m.Called() var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func() (int64, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -796,13 +865,16 @@ func (_m *UtilsCmdInterface) GetLocalMediansData(client *ethclient.Client, accou ret := _m.Called(client, account, epoch, blockNumber, rogueData) var r0 types.ProposeFileData + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Account, uint32, *big.Int, types.Rogue) (types.ProposeFileData, error)); ok { + return rf(client, account, epoch, blockNumber, rogueData) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Account, uint32, *big.Int, types.Rogue) types.ProposeFileData); ok { r0 = rf(client, account, epoch, blockNumber, rogueData) } else { r0 = ret.Get(0).(types.ProposeFileData) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Account, uint32, *big.Int, types.Rogue) error); ok { r1 = rf(client, account, epoch, blockNumber, rogueData) } else { @@ -817,13 +889,16 @@ func (_m *UtilsCmdInterface) GetLogFileMaxAge() (int, error) { ret := _m.Called() var r0 int + var r1 error + if rf, ok := ret.Get(0).(func() (int, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int); ok { r0 = rf() } else { r0 = ret.Get(0).(int) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -838,13 +913,16 @@ func (_m *UtilsCmdInterface) GetLogFileMaxBackups() (int, error) { ret := _m.Called() var r0 int + var r1 error + if rf, ok := ret.Get(0).(func() (int, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int); ok { r0 = rf() } else { r0 = ret.Get(0).(int) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -859,13 +937,16 @@ func (_m *UtilsCmdInterface) GetLogFileMaxSize() (int, error) { ret := _m.Called() var r0 int + var r1 error + if rf, ok := ret.Get(0).(func() (int, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int); ok { r0 = rf() } else { r0 = ret.Get(0).(int) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -880,13 +961,16 @@ func (_m *UtilsCmdInterface) GetLogLevel() (string, error) { ret := _m.Called() var r0 string + var r1 error + if rf, ok := ret.Get(0).(func() (string, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() } else { r0 = ret.Get(0).(string) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -901,13 +985,16 @@ func (_m *UtilsCmdInterface) GetMultiplier() (float32, error) { ret := _m.Called() var r0 float32 + var r1 error + if rf, ok := ret.Get(0).(func() (float32, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() float32); ok { r0 = rf() } else { r0 = ret.Get(0).(float32) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -922,13 +1009,16 @@ func (_m *UtilsCmdInterface) GetProvider() (string, error) { ret := _m.Called() var r0 string + var r1 error + if rf, ok := ret.Get(0).(func() (string, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() string); ok { r0 = rf() } else { r0 = ret.Get(0).(string) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -943,13 +1033,16 @@ func (_m *UtilsCmdInterface) GetRPCTimeout() (int64, error) { ret := _m.Called() var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func() (int64, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int64); ok { r0 = rf() } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -964,6 +1057,10 @@ func (_m *UtilsCmdInterface) GetSalt(client *ethclient.Client, epoch uint32) ([3 ret := _m.Called(client, epoch) var r0 [32]byte + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) ([32]byte, error)); ok { + return rf(client, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) [32]byte); ok { r0 = rf(client, epoch) } else { @@ -972,7 +1069,6 @@ func (_m *UtilsCmdInterface) GetSalt(client *ethclient.Client, epoch uint32) ([3 } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, epoch) } else { @@ -987,6 +1083,11 @@ func (_m *UtilsCmdInterface) GetSmallestStakeAndId(client *ethclient.Client, epo ret := _m.Called(client, epoch) var r0 *big.Int + var r1 uint32 + var r2 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (*big.Int, uint32, error)); ok { + return rf(client, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) *big.Int); ok { r0 = rf(client, epoch) } else { @@ -995,14 +1096,12 @@ func (_m *UtilsCmdInterface) GetSmallestStakeAndId(client *ethclient.Client, epo } } - var r1 uint32 if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) uint32); ok { r1 = rf(client, epoch) } else { r1 = ret.Get(1).(uint32) } - var r2 error if rf, ok := ret.Get(2).(func(*ethclient.Client, uint32) error); ok { r2 = rf(client, epoch) } else { @@ -1017,6 +1116,10 @@ func (_m *UtilsCmdInterface) GetSortedRevealedValues(client *ethclient.Client, b ret := _m.Called(client, blockNumber, epoch) var r0 *types.RevealedDataMaps + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, uint32) (*types.RevealedDataMaps, error)); ok { + return rf(client, blockNumber, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, uint32) *types.RevealedDataMaps); ok { r0 = rf(client, blockNumber, epoch) } else { @@ -1025,7 +1128,6 @@ func (_m *UtilsCmdInterface) GetSortedRevealedValues(client *ethclient.Client, b } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, *big.Int, uint32) error); ok { r1 = rf(client, blockNumber, epoch) } else { @@ -1054,13 +1156,16 @@ func (_m *UtilsCmdInterface) GetWaitTime() (int32, error) { ret := _m.Called() var r0 int32 + var r1 error + if rf, ok := ret.Get(0).(func() (int32, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() int32); ok { r0 = rf() } else { r0 = ret.Get(0).(int32) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -1108,13 +1213,16 @@ func (_m *UtilsCmdInterface) HandleCommitState(client *ethclient.Client, epoch u ret := _m.Called(client, epoch, seed, rogueData) var r0 types.CommitData + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, []byte, types.Rogue) (types.CommitData, error)); ok { + return rf(client, epoch, seed, rogueData) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, []byte, types.Rogue) types.CommitData); ok { r0 = rf(client, epoch, seed, rogueData) } else { r0 = ret.Get(0).(types.CommitData) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, []byte, types.Rogue) error); ok { r1 = rf(client, epoch, seed, rogueData) } else { @@ -1148,6 +1256,10 @@ func (_m *UtilsCmdInterface) HandleUnstakeLock(client *ethclient.Client, account ret := _m.Called(client, account, configurations, stakerId) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Account, types.Configurations, uint32) (common.Hash, error)); ok { + return rf(client, account, configurations, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Account, types.Configurations, uint32) common.Hash); ok { r0 = rf(client, account, configurations, stakerId) } else { @@ -1156,7 +1268,6 @@ func (_m *UtilsCmdInterface) HandleUnstakeLock(client *ethclient.Client, account } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Account, types.Configurations, uint32) error); ok { r1 = rf(client, account, configurations, stakerId) } else { @@ -1171,6 +1282,10 @@ func (_m *UtilsCmdInterface) HandleWithdrawLock(client *ethclient.Client, accoun ret := _m.Called(client, account, configurations, stakerId) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Account, types.Configurations, uint32) (common.Hash, error)); ok { + return rf(client, account, configurations, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Account, types.Configurations, uint32) common.Hash); ok { r0 = rf(client, account, configurations, stakerId) } else { @@ -1179,7 +1294,6 @@ func (_m *UtilsCmdInterface) HandleWithdrawLock(client *ethclient.Client, accoun } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Account, types.Configurations, uint32) error); ok { r1 = rf(client, account, configurations, stakerId) } else { @@ -1194,13 +1308,16 @@ func (_m *UtilsCmdInterface) ImportAccount() (accounts.Account, error) { ret := _m.Called() var r0 accounts.Account + var r1 error + if rf, ok := ret.Get(0).(func() (accounts.Account, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() accounts.Account); ok { r0 = rf() } else { r0 = ret.Get(0).(accounts.Account) } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -1215,6 +1332,10 @@ func (_m *UtilsCmdInterface) IndexRevealEventsOfCurrentEpoch(client *ethclient.C ret := _m.Called(client, blockNumber, epoch) var r0 []types.RevealedStruct + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, uint32) ([]types.RevealedStruct, error)); ok { + return rf(client, blockNumber, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, uint32) []types.RevealedStruct); ok { r0 = rf(client, blockNumber, epoch) } else { @@ -1223,7 +1344,6 @@ func (_m *UtilsCmdInterface) IndexRevealEventsOfCurrentEpoch(client *ethclient.C } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, *big.Int, uint32) error); ok { r1 = rf(client, blockNumber, epoch) } else { @@ -1280,6 +1400,10 @@ func (_m *UtilsCmdInterface) InitiateWithdraw(client *ethclient.Client, txnOpts ret := _m.Called(client, txnOpts, stakerId) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, *bind.TransactOpts, uint32) (common.Hash, error)); ok { + return rf(client, txnOpts, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, *bind.TransactOpts, uint32) common.Hash); ok { r0 = rf(client, txnOpts, stakerId) } else { @@ -1288,7 +1412,6 @@ func (_m *UtilsCmdInterface) InitiateWithdraw(client *ethclient.Client, txnOpts } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, *bind.TransactOpts, uint32) error); ok { r1 = rf(client, txnOpts, stakerId) } else { @@ -1317,6 +1440,10 @@ func (_m *UtilsCmdInterface) ListAccounts() ([]accounts.Account, error) { ret := _m.Called() var r0 []accounts.Account + var r1 error + if rf, ok := ret.Get(0).(func() ([]accounts.Account, error)); ok { + return rf() + } if rf, ok := ret.Get(0).(func() []accounts.Account); ok { r0 = rf() } else { @@ -1325,7 +1452,6 @@ func (_m *UtilsCmdInterface) ListAccounts() ([]accounts.Account, error) { } } - var r1 error if rf, ok := ret.Get(1).(func() error); ok { r1 = rf() } else { @@ -1340,6 +1466,12 @@ func (_m *UtilsCmdInterface) MakeBlock(client *ethclient.Client, blockNumber *bi ret := _m.Called(client, blockNumber, epoch, rogueData) var r0 []*big.Int + var r1 []uint16 + var r2 *types.RevealedDataMaps + var r3 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, uint32, types.Rogue) ([]*big.Int, []uint16, *types.RevealedDataMaps, error)); ok { + return rf(client, blockNumber, epoch, rogueData) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int, uint32, types.Rogue) []*big.Int); ok { r0 = rf(client, blockNumber, epoch, rogueData) } else { @@ -1348,7 +1480,6 @@ func (_m *UtilsCmdInterface) MakeBlock(client *ethclient.Client, blockNumber *bi } } - var r1 []uint16 if rf, ok := ret.Get(1).(func(*ethclient.Client, *big.Int, uint32, types.Rogue) []uint16); ok { r1 = rf(client, blockNumber, epoch, rogueData) } else { @@ -1357,7 +1488,6 @@ func (_m *UtilsCmdInterface) MakeBlock(client *ethclient.Client, blockNumber *bi } } - var r2 *types.RevealedDataMaps if rf, ok := ret.Get(2).(func(*ethclient.Client, *big.Int, uint32, types.Rogue) *types.RevealedDataMaps); ok { r2 = rf(client, blockNumber, epoch, rogueData) } else { @@ -1366,7 +1496,6 @@ func (_m *UtilsCmdInterface) MakeBlock(client *ethclient.Client, blockNumber *bi } } - var r3 error if rf, ok := ret.Get(3).(func(*ethclient.Client, *big.Int, uint32, types.Rogue) error); ok { r3 = rf(client, blockNumber, epoch, rogueData) } else { @@ -1381,6 +1510,10 @@ func (_m *UtilsCmdInterface) ModifyCollectionStatus(client *ethclient.Client, co ret := _m.Called(client, config, modifyCollectionInput) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.ModifyCollectionInput) (common.Hash, error)); ok { + return rf(client, config, modifyCollectionInput) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.ModifyCollectionInput) common.Hash); ok { r0 = rf(client, config, modifyCollectionInput) } else { @@ -1389,7 +1522,6 @@ func (_m *UtilsCmdInterface) ModifyCollectionStatus(client *ethclient.Client, co } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.ModifyCollectionInput) error); ok { r1 = rf(client, config, modifyCollectionInput) } else { @@ -1423,6 +1555,10 @@ func (_m *UtilsCmdInterface) ResetUnstakeLock(client *ethclient.Client, config t ret := _m.Called(client, config, extendLockInput) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.ExtendLockInput) (common.Hash, error)); ok { + return rf(client, config, extendLockInput) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.ExtendLockInput) common.Hash); ok { r0 = rf(client, config, extendLockInput) } else { @@ -1431,7 +1567,6 @@ func (_m *UtilsCmdInterface) ResetUnstakeLock(client *ethclient.Client, config t } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.ExtendLockInput) error); ok { r1 = rf(client, config, extendLockInput) } else { @@ -1446,6 +1581,10 @@ func (_m *UtilsCmdInterface) Reveal(client *ethclient.Client, config types.Confi ret := _m.Called(client, config, account, epoch, commitData, signature) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.Account, uint32, types.CommitData, []byte) (common.Hash, error)); ok { + return rf(client, config, account, epoch, commitData, signature) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.Account, uint32, types.CommitData, []byte) common.Hash); ok { r0 = rf(client, config, account, epoch, commitData, signature) } else { @@ -1454,7 +1593,6 @@ func (_m *UtilsCmdInterface) Reveal(client *ethclient.Client, config types.Confi } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.Account, uint32, types.CommitData, []byte) error); ok { r1 = rf(client, config, account, epoch, commitData, signature) } else { @@ -1483,6 +1621,10 @@ func (_m *UtilsCmdInterface) SetDelegation(client *ethclient.Client, config type ret := _m.Called(client, config, delegationInput) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.SetDelegationInput) (common.Hash, error)); ok { + return rf(client, config, delegationInput) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.SetDelegationInput) common.Hash); ok { r0 = rf(client, config, delegationInput) } else { @@ -1491,7 +1633,6 @@ func (_m *UtilsCmdInterface) SetDelegation(client *ethclient.Client, config type } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.SetDelegationInput) error); ok { r1 = rf(client, config, delegationInput) } else { @@ -1506,6 +1647,10 @@ func (_m *UtilsCmdInterface) StakeCoins(txnArgs types.TransactionOptions) (commo ret := _m.Called(txnArgs) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(types.TransactionOptions) (common.Hash, error)); ok { + return rf(txnArgs) + } if rf, ok := ret.Get(0).(func(types.TransactionOptions) common.Hash); ok { r0 = rf(txnArgs) } else { @@ -1514,7 +1659,6 @@ func (_m *UtilsCmdInterface) StakeCoins(txnArgs types.TransactionOptions) (commo } } - var r1 error if rf, ok := ret.Get(1).(func(types.TransactionOptions) error); ok { r1 = rf(txnArgs) } else { @@ -1543,6 +1687,10 @@ func (_m *UtilsCmdInterface) Transfer(client *ethclient.Client, config types.Con ret := _m.Called(client, config, transferInput) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.TransferInput) (common.Hash, error)); ok { + return rf(client, config, transferInput) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.TransferInput) common.Hash); ok { r0 = rf(client, config, transferInput) } else { @@ -1551,7 +1699,6 @@ func (_m *UtilsCmdInterface) Transfer(client *ethclient.Client, config types.Con } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.TransferInput) error); ok { r1 = rf(client, config, transferInput) } else { @@ -1566,6 +1713,10 @@ func (_m *UtilsCmdInterface) UnlockWithdraw(client *ethclient.Client, txnOpts *b ret := _m.Called(client, txnOpts, stakerId) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, *bind.TransactOpts, uint32) (common.Hash, error)); ok { + return rf(client, txnOpts, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, *bind.TransactOpts, uint32) common.Hash); ok { r0 = rf(client, txnOpts, stakerId) } else { @@ -1574,7 +1725,6 @@ func (_m *UtilsCmdInterface) UnlockWithdraw(client *ethclient.Client, txnOpts *b } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, *bind.TransactOpts, uint32) error); ok { r1 = rf(client, txnOpts, stakerId) } else { @@ -1589,6 +1739,10 @@ func (_m *UtilsCmdInterface) Unstake(config types.Configurations, client *ethcli ret := _m.Called(config, client, input) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(types.Configurations, *ethclient.Client, types.UnstakeInput) (common.Hash, error)); ok { + return rf(config, client, input) + } if rf, ok := ret.Get(0).(func(types.Configurations, *ethclient.Client, types.UnstakeInput) common.Hash); ok { r0 = rf(config, client, input) } else { @@ -1597,7 +1751,6 @@ func (_m *UtilsCmdInterface) Unstake(config types.Configurations, client *ethcli } } - var r1 error if rf, ok := ret.Get(1).(func(types.Configurations, *ethclient.Client, types.UnstakeInput) error); ok { r1 = rf(config, client, input) } else { @@ -1612,6 +1765,10 @@ func (_m *UtilsCmdInterface) UpdateCollection(client *ethclient.Client, config t ret := _m.Called(client, config, collectionInput, collectionId) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateCollectionInput, uint16) (common.Hash, error)); ok { + return rf(client, config, collectionInput, collectionId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateCollectionInput, uint16) common.Hash); ok { r0 = rf(client, config, collectionInput, collectionId) } else { @@ -1620,7 +1777,6 @@ func (_m *UtilsCmdInterface) UpdateCollection(client *ethclient.Client, config t } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.CreateCollectionInput, uint16) error); ok { r1 = rf(client, config, collectionInput, collectionId) } else { @@ -1649,6 +1805,10 @@ func (_m *UtilsCmdInterface) UpdateJob(client *ethclient.Client, config types.Co ret := _m.Called(client, config, jobInput, jobId) var r0 common.Hash + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateJobInput, uint16) (common.Hash, error)); ok { + return rf(client, config, jobInput, jobId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, types.Configurations, types.CreateJobInput, uint16) common.Hash); ok { r0 = rf(client, config, jobInput, jobId) } else { @@ -1657,7 +1817,6 @@ func (_m *UtilsCmdInterface) UpdateJob(client *ethclient.Client, config types.Co } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, types.Configurations, types.CreateJobInput, uint16) error); ok { r1 = rf(client, config, jobInput, jobId) } else { @@ -1693,13 +1852,16 @@ func (_m *UtilsCmdInterface) WaitForAppropriateState(client *ethclient.Client, a ret := _m.Called(_ca...) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, string, ...int) (uint32, error)); ok { + return rf(client, action, states...) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, string, ...int) uint32); ok { r0 = rf(client, action, states...) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, string, ...int) error); ok { r1 = rf(client, action, states...) } else { @@ -1714,13 +1876,16 @@ func (_m *UtilsCmdInterface) WaitIfCommitState(client *ethclient.Client, action ret := _m.Called(client, action) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, string) (uint32, error)); ok { + return rf(client, action) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, string) uint32); ok { r0 = rf(client, action) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, string) error); ok { r1 = rf(client, action) } else { @@ -1730,13 +1895,12 @@ func (_m *UtilsCmdInterface) WaitIfCommitState(client *ethclient.Client, action return r0, r1 } -type mockConstructorTestingTNewUtilsCmdInterface interface { +// NewUtilsCmdInterface creates a new instance of UtilsCmdInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUtilsCmdInterface(t interface { mock.TestingT Cleanup(func()) -} - -// NewUtilsCmdInterface creates a new instance of UtilsCmdInterface. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewUtilsCmdInterface(t mockConstructorTestingTNewUtilsCmdInterface) *UtilsCmdInterface { +}) *UtilsCmdInterface { mock := &UtilsCmdInterface{} mock.Mock.Test(t) diff --git a/cmd/vote.go b/cmd/vote.go index ec740466b..10410b4b2 100644 --- a/cmd/vote.go +++ b/cmd/vote.go @@ -3,7 +3,6 @@ package cmd import ( "context" - "encoding/hex" "errors" "fmt" "math/big" @@ -350,21 +349,11 @@ func (*UtilsStruct) InitiateCommit(client *ethclient.Client, config types.Config log.Debugf("InitiateCommit: .razor directory path: %s", razorPath) keystorePath := filepath.Join(razorPath, "keystore_files") log.Debugf("InitiateCommit: Keystore file path: %s", keystorePath) - log.Debugf("InitiateCommit: Calling CalculateSecret() with arguments epoch = %d, keystorePath = %s, chainId = %s", epoch, keystorePath, core.ChainId) - _, secret, err := cmdUtils.CalculateSecret(account, epoch, keystorePath, core.ChainId) + log.Debugf("InitiateCommit: Calling CalculateSeed() with arguments keystorePath = %s, epoch = %d", keystorePath, epoch) + seed, err := CalculateSeed(client, account, keystorePath, epoch) if err != nil { - return err - } - log.Debug("InitiateCommit: Secret: ", secret) - - log.Debugf("Getting Salt for current epoch %d...", epoch) - salt, err := cmdUtils.GetSalt(client, epoch) - if err != nil { - return err + return errors.New("Error in getting seed: " + err.Error()) } - log.Debug("InitiateCommit: Salt: ", salt) - - seed := solsha3.SoliditySHA3([]string{"bytes32", "bytes32"}, []interface{}{"0x" + hex.EncodeToString(salt[:]), "0x" + hex.EncodeToString(secret)}) log.Debugf("InitiateCommit: Calling HandleCommitState with arguments epoch = %d, seed = %v, rogueData = %+v", epoch, seed, rogueData) commitData, err := cmdUtils.HandleCommitState(client, epoch, seed, rogueData) @@ -373,24 +362,26 @@ func (*UtilsStruct) InitiateCommit(client *ethclient.Client, config types.Config } log.Debug("InitiateCommit: Commit Data: ", commitData) - log.Debug("InitiateCommit: Calling CreateMerkle() with argument Leaves = ", commitData.Leaves) - merkleTree, err := merkleUtils.CreateMerkle(commitData.Leaves) - if err != nil { - return errors.New("Error in getting merkle tree: " + err.Error()) - } - log.Debug("InitiateCommit: Merkle Tree: ", merkleTree) - log.Debug("InitiateCommit: Calling GetMerkleRoot() for the merkle tree...") - merkleRoot, err := merkleUtils.GetMerkleRoot(merkleTree) - if err != nil { - return errors.New("Error in getting root: " + err.Error()) - } - log.Debug("InitiateCommit: Merkle Tree Root: ", merkleRoot) - commitTxn, err := cmdUtils.Commit(client, config, account, epoch, seed, merkleRoot) + commitTxn, err := cmdUtils.Commit(client, config, account, epoch, seed, commitData.Leaves) if err != nil { return errors.New("Error in committing data: " + err.Error()) } log.Debug("InitiateCommit: Commit Transaction Hash: ", commitTxn) if commitTxn != core.NilHash { + log.Debug("Saving committed data for recovery...") + fileName, err := pathUtils.GetCommitDataFileName(account.Address) + if err != nil { + return errors.New("Error in getting file name to save committed data: " + err.Error()) + } + log.Debug("InitiateCommit: Commit data file path: ", fileName) + + err = fileUtils.SaveDataToCommitJsonFile(fileName, epoch, commitData) + if err != nil { + return errors.New("Error in saving data to file" + fileName + ": " + err.Error()) + } + log.Debug("Data saved!") + + log.Debug("Checking for commit transaction status with transaction hash: ", commitTxn) waitForBlockCompletionErr := razorUtils.WaitForBlockCompletion(client, commitTxn.Hex()) if waitForBlockCompletionErr != nil { log.Error("Error in WaitForBlockCompletion for commit: ", waitForBlockCompletionErr) @@ -400,19 +391,6 @@ func (*UtilsStruct) InitiateCommit(client *ethclient.Client, config types.Config updateGlobalCommitDataStruct(commitData, epoch) log.Debugf("InitiateCommit: Global commit data struct: %+v", globalCommitDataStruct) } - - log.Debug("Saving committed data for recovery...") - fileName, err := pathUtils.GetCommitDataFileName(account.Address) - if err != nil { - return errors.New("Error in getting file name to save committed data: " + err.Error()) - } - log.Debug("InitiateCommit: Commit data file path: ", fileName) - - err = fileUtils.SaveDataToCommitJsonFile(fileName, epoch, commitData) - if err != nil { - return errors.New("Error in saving data to file" + fileName + ": " + err.Error()) - } - log.Debug("Data saved!") return nil } @@ -447,10 +425,9 @@ func (*UtilsStruct) InitiateReveal(client *ethclient.Client, config types.Config return err } - nilCommitData := globalCommitDataStruct.AssignedCollections == nil && globalCommitDataStruct.SeqAllottedCollections == nil && globalCommitDataStruct.Leaves == nil - - if nilCommitData { - log.Debug("InitiateReveal: Global commit data is nil, getting the commit data from file...") + if globalCommitDataStruct.Epoch != epoch { + log.Debugf("InitiateReveal: Epoch in global commit data: %v is not equal to current epoch: %v", globalCommitDataStruct.Epoch, epoch) + log.Info("Getting the commit data from file...") fileName, err := pathUtils.GetCommitDataFileName(account.Address) if err != nil { log.Error("Error in getting file name to save committed data: ", err) @@ -467,6 +444,25 @@ func (*UtilsStruct) InitiateReveal(client *ethclient.Client, config types.Config log.Errorf("File %s doesn't contain latest committed data", fileName) return errors.New("commit data file doesn't contain latest committed data") } + log.Debug("Verifying commit data from file...") + razorPath, err := pathUtils.GetDefaultPath() + if err != nil { + return err + } + log.Debugf("InitiateReveal: .razor directory path: %s", razorPath) + keystorePath := filepath.Join(razorPath, "keystore_files") + log.Debugf("InitiateReveal: Keystore file path: %s", keystorePath) + + log.Debugf("InitiateReveal: Calling VerifyCommitment() for address %v with arguments epoch = %v, values = %v", account.Address, epoch, committedDataFromFile.Leaves) + isCommittedDataFromFileValid, err := VerifyCommitment(client, account, keystorePath, epoch, committedDataFromFile.Leaves) + if err != nil { + log.Error("Error in verifying commitment for commit data from file: ", err) + return err + } + if !isCommittedDataFromFileValid { + log.Infof("Not using data from file! as commitment calculated for data from commit data file is not equal to staker's commitment for this epoch.") + return errors.New("commitment verification for commit file data failed") + } log.Debug("Updating global commit data struct...") updateGlobalCommitDataStruct(types.CommitData{ Leaves: committedDataFromFile.Leaves, diff --git a/cmd/vote_test.go b/cmd/vote_test.go index dd27036dc..276293f7e 100644 --- a/cmd/vote_test.go +++ b/cmd/vote_test.go @@ -318,10 +318,6 @@ func TestInitiateCommit(t *testing.T) { pathErr error commitData types.CommitData commitDataErr error - merkleTree [][][]byte - merkleTreeErr error - merkleRoot [32]byte - merkleRootErr error commitTxn common.Hash commitTxnErr error waitForBlockCompletionErr error @@ -349,9 +345,8 @@ func TestInitiateCommit(t *testing.T) { SeqAllottedCollections: nil, Leaves: nil, }, - merkleTree: [][][]byte{}, - commitTxn: common.BigToHash(big.NewInt(1)), - fileName: "", + commitTxn: common.BigToHash(big.NewInt(1)), + fileName: "", }, wantErr: false, }, @@ -385,9 +380,8 @@ func TestInitiateCommit(t *testing.T) { SeqAllottedCollections: nil, Leaves: nil, }, - merkleTree: [][][]byte{}, - commitTxn: common.BigToHash(big.NewInt(1)), - fileName: "", + commitTxn: common.BigToHash(big.NewInt(1)), + fileName: "", }, wantErr: false, }, @@ -449,7 +443,6 @@ func TestInitiateCommit(t *testing.T) { SeqAllottedCollections: nil, Leaves: nil, }, - merkleTree: [][][]byte{}, commitTxnErr: errors.New("error in commit"), }, wantErr: true, @@ -466,6 +459,7 @@ func TestInitiateCommit(t *testing.T) { SeqAllottedCollections: nil, Leaves: nil, }, + commitTxn: common.BigToHash(big.NewInt(1)), fileNameErr: errors.New("error in getting fileName"), }, wantErr: true, @@ -482,7 +476,6 @@ func TestInitiateCommit(t *testing.T) { SeqAllottedCollections: nil, Leaves: nil, }, - merkleTree: [][][]byte{}, commitTxn: common.BigToHash(big.NewInt(1)), waitForBlockCompletionErr: errors.New("transaction mining unsuccessful"), }, @@ -497,39 +490,6 @@ func TestInitiateCommit(t *testing.T) { }, wantErr: true, }, - { - name: "Test 14: When there is an error in getting merkle tree", - args: args{ - epoch: 5, - lastCommit: 2, - secret: []byte{1}, - salt: [32]byte{}, - commitData: types.CommitData{ - AssignedCollections: nil, - SeqAllottedCollections: nil, - Leaves: nil, - }, - merkleTreeErr: errors.New("merkle tree error"), - }, - wantErr: true, - }, - { - name: "Test 15: When there is an error in getting merkle root", - args: args{ - epoch: 5, - lastCommit: 2, - secret: []byte{1}, - salt: [32]byte{}, - commitData: types.CommitData{ - AssignedCollections: nil, - SeqAllottedCollections: nil, - Leaves: nil, - }, - merkleTree: [][][]byte{}, - merkleRootErr: errors.New("root error"), - }, - wantErr: true, - }, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { @@ -541,8 +501,6 @@ func TestInitiateCommit(t *testing.T) { cmdUtilsMock.On("CalculateSecret", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tt.args.signature, tt.args.secret, tt.args.secretErr) cmdUtilsMock.On("GetSalt", mock.AnythingOfType("*ethclient.Client"), mock.Anything).Return(tt.args.salt, tt.args.saltErr) cmdUtilsMock.On("HandleCommitState", mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tt.args.commitData, tt.args.commitDataErr) - merkleUtilsMock.On("CreateMerkle", mock.Anything).Return(tt.args.merkleTree, tt.args.merkleTreeErr) - merkleUtilsMock.On("GetMerkleRoot", mock.Anything).Return(tt.args.merkleRoot, tt.args.merkleRootErr) pathMock.On("GetDefaultPath").Return(tt.args.path, tt.args.pathErr) cmdUtilsMock.On("Commit", mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything, mock.Anything).Return(tt.args.commitTxn, tt.args.commitTxnErr) utilsMock.On("WaitForBlockCompletion", mock.AnythingOfType("*ethclient.Client"), mock.AnythingOfType("string")).Return(tt.args.waitForBlockCompletionErr) @@ -564,6 +522,7 @@ func TestInitiateReveal(t *testing.T) { ) randomNum := big.NewInt(1111) + globalCommitDataStruct.Epoch = 5 type args struct { staker bindings.StructsStaker @@ -657,8 +616,8 @@ func TestInitiateReveal(t *testing.T) { { name: "Test 6: When there is an error in getting fileName", args: args{ - epoch: 5, - lastReveal: 2, + epoch: 6, + lastReveal: 3, fileNameErr: errors.New("error in getting fileName"), }, wantErr: true, @@ -666,7 +625,7 @@ func TestInitiateReveal(t *testing.T) { { name: "Test 7: When there is an error in getting data from file", args: args{ - epoch: 5, + epoch: 6, lastReveal: 2, fileName: "", committedDataFromFileErr: errors.New("error in reading data from file"), @@ -676,7 +635,7 @@ func TestInitiateReveal(t *testing.T) { { name: "Test 8: When file does not contain the latest data", args: args{ - epoch: 5, + epoch: 6, lastReveal: 2, fileName: "", committedDataFromFile: types.CommitFileData{Epoch: 3}, diff --git a/utils/interface.go b/utils/interface.go index 3fbde6b2c..302126509 100644 --- a/utils/interface.go +++ b/utils/interface.go @@ -98,7 +98,7 @@ type Utils interface { GetMaxCommission(client *ethclient.Client) (uint8, error) GetEpochLimitForUpdateCommission(client *ethclient.Client) (uint16, error) GetVoteManagerWithOpts(client *ethclient.Client) (*bindings.VoteManager, bind.CallOpts) - GetCommitments(client *ethclient.Client, address string) ([32]byte, error) + GetCommitment(client *ethclient.Client, address string) (types.Commitment, error) GetVoteValue(client *ethclient.Client, epoch uint32, stakerId uint32, medianIndex uint16) (*big.Int, error) GetInfluenceSnapshot(client *ethclient.Client, stakerId uint32, epoch uint32) (*big.Int, error) GetStakeSnapshot(client *ethclient.Client, stakerId uint32, epoch uint32) (*big.Int, error) @@ -263,7 +263,7 @@ type AssetManagerUtils interface { } type VoteManagerUtils interface { - Commitments(client *ethclient.Client, stakerId uint32) (types.Commitment, error) + GetCommitment(client *ethclient.Client, stakerId uint32) (types.Commitment, error) GetVoteValue(client *ethclient.Client, epoch uint32, stakerId uint32, medianIndex uint16) (*big.Int, error) GetInfluenceSnapshot(client *ethclient.Client, epoch uint32, stakerId uint32) (*big.Int, error) GetStakeSnapshot(client *ethclient.Client, epoch uint32, stakerId uint32) (*big.Int, error) diff --git a/utils/mocks/utils.go b/utils/mocks/utils.go index 3f4032dd6..63194d5cb 100644 --- a/utils/mocks/utils.go +++ b/utils/mocks/utils.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. +// Code generated by mockery v2.30.1. DO NOT EDIT. package mocks @@ -45,6 +45,10 @@ func (_m *Utils) Aggregate(client *ethclient.Client, previousEpoch uint32, colle ret := _m.Called(client, previousEpoch, collection, localCache) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, bindings.StructsCollection, *cache.LocalCache) (*big.Int, error)); ok { + return rf(client, previousEpoch, collection, localCache) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, bindings.StructsCollection, *cache.LocalCache) *big.Int); ok { r0 = rf(client, previousEpoch, collection, localCache) } else { @@ -53,7 +57,6 @@ func (_m *Utils) Aggregate(client *ethclient.Client, previousEpoch uint32, colle } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, bindings.StructsCollection, *cache.LocalCache) error); ok { r1 = rf(client, previousEpoch, collection, localCache) } else { @@ -82,13 +85,16 @@ func (_m *Utils) AssignStakerId(flagSet *pflag.FlagSet, client *ethclient.Client ret := _m.Called(flagSet, client, address) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*pflag.FlagSet, *ethclient.Client, string) (uint32, error)); ok { + return rf(flagSet, client, address) + } if rf, ok := ret.Get(0).(func(*pflag.FlagSet, *ethclient.Client, string) uint32); ok { r0 = rf(flagSet, client, address) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*pflag.FlagSet, *ethclient.Client, string) error); ok { r1 = rf(flagSet, client, address) } else { @@ -198,6 +204,10 @@ func (_m *Utils) ConvertToNumber(num interface{}) (*big.Float, error) { ret := _m.Called(num) var r0 *big.Float + var r1 error + if rf, ok := ret.Get(0).(func(interface{}) (*big.Float, error)); ok { + return rf(num) + } if rf, ok := ret.Get(0).(func(interface{}) *big.Float); ok { r0 = rf(num) } else { @@ -206,7 +216,6 @@ func (_m *Utils) ConvertToNumber(num interface{}) (*big.Float, error) { } } - var r1 error if rf, ok := ret.Get(1).(func(interface{}) error); ok { r1 = rf(num) } else { @@ -235,6 +244,10 @@ func (_m *Utils) EstimateBlockNumberAtEpochBeginning(client *ethclient.Client, c ret := _m.Called(client, currentBlockNumber) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int) (*big.Int, error)); ok { + return rf(client, currentBlockNumber) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, *big.Int) *big.Int); ok { r0 = rf(client, currentBlockNumber) } else { @@ -243,7 +256,6 @@ func (_m *Utils) EstimateBlockNumberAtEpochBeginning(client *ethclient.Client, c } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, *big.Int) error); ok { r1 = rf(client, currentBlockNumber) } else { @@ -258,6 +270,10 @@ func (_m *Utils) FetchBalance(client *ethclient.Client, accountAddress string) ( ret := _m.Called(client, accountAddress) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, string) (*big.Int, error)); ok { + return rf(client, accountAddress) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, string) *big.Int); ok { r0 = rf(client, accountAddress) } else { @@ -266,7 +282,6 @@ func (_m *Utils) FetchBalance(client *ethclient.Client, accountAddress string) ( } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, string) error); ok { r1 = rf(client, accountAddress) } else { @@ -281,6 +296,10 @@ func (_m *Utils) FetchPreviousValue(client *ethclient.Client, epoch uint32, asse ret := _m.Called(client, epoch, assetId) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint16) (*big.Int, error)); ok { + return rf(client, epoch, assetId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint16) *big.Int); ok { r0 = rf(client, epoch, assetId) } else { @@ -289,7 +308,6 @@ func (_m *Utils) FetchPreviousValue(client *ethclient.Client, epoch uint32, asse } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint16) error); ok { r1 = rf(client, epoch, assetId) } else { @@ -304,13 +322,16 @@ func (_m *Utils) GetActiveCollection(client *ethclient.Client, collectionId uint ret := _m.Called(client, collectionId) var r0 bindings.StructsCollection + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) (bindings.StructsCollection, error)); ok { + return rf(client, collectionId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) bindings.StructsCollection); ok { r0 = rf(client, collectionId) } else { r0 = ret.Get(0).(bindings.StructsCollection) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16) error); ok { r1 = rf(client, collectionId) } else { @@ -325,6 +346,10 @@ func (_m *Utils) GetActiveCollectionIds(client *ethclient.Client) ([]uint16, err ret := _m.Called(client) var r0 []uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) ([]uint16, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) []uint16); ok { r0 = rf(client) } else { @@ -333,7 +358,6 @@ func (_m *Utils) GetActiveCollectionIds(client *ethclient.Client) ([]uint16, err } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -348,13 +372,16 @@ func (_m *Utils) GetActiveJob(client *ethclient.Client, jobId uint16) (bindings. ret := _m.Called(client, jobId) var r0 bindings.StructsJob + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) (bindings.StructsJob, error)); ok { + return rf(client, jobId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) bindings.StructsJob); ok { r0 = rf(client, jobId) } else { r0 = ret.Get(0).(bindings.StructsJob) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16) error); ok { r1 = rf(client, jobId) } else { @@ -369,6 +396,10 @@ func (_m *Utils) GetAggregatedDataOfCollection(client *ethclient.Client, collect ret := _m.Called(client, collectionId, epoch, localCache) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16, uint32, *cache.LocalCache) (*big.Int, error)); ok { + return rf(client, collectionId, epoch, localCache) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16, uint32, *cache.LocalCache) *big.Int); ok { r0 = rf(client, collectionId, epoch, localCache) } else { @@ -377,7 +408,6 @@ func (_m *Utils) GetAggregatedDataOfCollection(client *ethclient.Client, collect } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16, uint32, *cache.LocalCache) error); ok { r1 = rf(client, collectionId, epoch, localCache) } else { @@ -392,6 +422,10 @@ func (_m *Utils) GetAllCollections(client *ethclient.Client) ([]bindings.Structs ret := _m.Called(client) var r0 []bindings.StructsCollection + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) ([]bindings.StructsCollection, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) []bindings.StructsCollection); ok { r0 = rf(client) } else { @@ -400,7 +434,6 @@ func (_m *Utils) GetAllCollections(client *ethclient.Client) ([]bindings.Structs } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -415,6 +448,11 @@ func (_m *Utils) GetAssignedCollections(client *ethclient.Client, numActiveColle ret := _m.Called(client, numActiveCollections, seed) var r0 map[int]bool + var r1 []*big.Int + var r2 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16, []byte) (map[int]bool, []*big.Int, error)); ok { + return rf(client, numActiveCollections, seed) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16, []byte) map[int]bool); ok { r0 = rf(client, numActiveCollections, seed) } else { @@ -423,7 +461,6 @@ func (_m *Utils) GetAssignedCollections(client *ethclient.Client, numActiveColle } } - var r1 []*big.Int if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16, []byte) []*big.Int); ok { r1 = rf(client, numActiveCollections, seed) } else { @@ -432,7 +469,6 @@ func (_m *Utils) GetAssignedCollections(client *ethclient.Client, numActiveColle } } - var r2 error if rf, ok := ret.Get(2).(func(*ethclient.Client, uint16, []byte) error); ok { r2 = rf(client, numActiveCollections, seed) } else { @@ -447,13 +483,16 @@ func (_m *Utils) GetBlock(client *ethclient.Client, epoch uint32) (bindings.Stru ret := _m.Called(client, epoch) var r0 bindings.StructsBlock + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (bindings.StructsBlock, error)); ok { + return rf(client, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) bindings.StructsBlock); ok { r0 = rf(client, epoch) } else { r0 = ret.Get(0).(bindings.StructsBlock) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, epoch) } else { @@ -468,13 +507,16 @@ func (_m *Utils) GetBlockIndexToBeConfirmed(client *ethclient.Client) (int8, err ret := _m.Called(client) var r0 int8 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (int8, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) int8); ok { r0 = rf(client) } else { r0 = ret.Get(0).(int8) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -505,6 +547,10 @@ func (_m *Utils) GetBlockManagerWithOpts(client *ethclient.Client) (*bindings.Bl ret := _m.Called(client) var r0 *bindings.BlockManager + var r1 bind.CallOpts + if rf, ok := ret.Get(0).(func(*ethclient.Client) (*bindings.BlockManager, bind.CallOpts)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) *bindings.BlockManager); ok { r0 = rf(client) } else { @@ -513,7 +559,6 @@ func (_m *Utils) GetBlockManagerWithOpts(client *ethclient.Client) (*bindings.Bl } } - var r1 bind.CallOpts if rf, ok := ret.Get(1).(func(*ethclient.Client) bind.CallOpts); ok { r1 = rf(client) } else { @@ -528,13 +573,16 @@ func (_m *Utils) GetBufferedState(client *ethclient.Client, buffer int32) (int64 ret := _m.Called(client, buffer) var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, int32) (int64, error)); ok { + return rf(client, buffer) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, int32) int64); ok { r0 = rf(client, buffer) } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, int32) error); ok { r1 = rf(client, buffer) } else { @@ -549,13 +597,16 @@ func (_m *Utils) GetCollection(client *ethclient.Client, collectionId uint16) (b ret := _m.Called(client, collectionId) var r0 bindings.StructsCollection + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) (bindings.StructsCollection, error)); ok { + return rf(client, collectionId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) bindings.StructsCollection); ok { r0 = rf(client, collectionId) } else { r0 = ret.Get(0).(bindings.StructsCollection) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16) error); ok { r1 = rf(client, collectionId) } else { @@ -570,13 +621,16 @@ func (_m *Utils) GetCollectionIdFromIndex(client *ethclient.Client, medianIndex ret := _m.Called(client, medianIndex) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) (uint16, error)); ok { + return rf(client, medianIndex) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) uint16); ok { r0 = rf(client, medianIndex) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16) error); ok { r1 = rf(client, medianIndex) } else { @@ -591,13 +645,16 @@ func (_m *Utils) GetCollectionIdFromLeafId(client *ethclient.Client, leafId uint ret := _m.Called(client, leafId) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) (uint16, error)); ok { + return rf(client, leafId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) uint16); ok { r0 = rf(client, leafId) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16) error); ok { r1 = rf(client, leafId) } else { @@ -628,6 +685,10 @@ func (_m *Utils) GetCollectionManagerWithOpts(client *ethclient.Client) (*bindin ret := _m.Called(client) var r0 *bindings.CollectionManager + var r1 bind.CallOpts + if rf, ok := ret.Get(0).(func(*ethclient.Client) (*bindings.CollectionManager, bind.CallOpts)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) *bindings.CollectionManager); ok { r0 = rf(client) } else { @@ -636,7 +697,6 @@ func (_m *Utils) GetCollectionManagerWithOpts(client *ethclient.Client) (*bindin } } - var r1 bind.CallOpts if rf, ok := ret.Get(1).(func(*ethclient.Client) bind.CallOpts); ok { r1 = rf(client) } else { @@ -646,20 +706,21 @@ func (_m *Utils) GetCollectionManagerWithOpts(client *ethclient.Client) (*bindin return r0, r1 } -// GetCommitments provides a mock function with given fields: client, address -func (_m *Utils) GetCommitments(client *ethclient.Client, address string) ([32]byte, error) { +// GetCommitment provides a mock function with given fields: client, address +func (_m *Utils) GetCommitment(client *ethclient.Client, address string) (types.Commitment, error) { ret := _m.Called(client, address) - var r0 [32]byte - if rf, ok := ret.Get(0).(func(*ethclient.Client, string) [32]byte); ok { + var r0 types.Commitment + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, string) (types.Commitment, error)); ok { + return rf(client, address) + } + if rf, ok := ret.Get(0).(func(*ethclient.Client, string) types.Commitment); ok { r0 = rf(client, address) } else { - if ret.Get(0) != nil { - r0 = ret.Get(0).([32]byte) - } + r0 = ret.Get(0).(types.Commitment) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, string) error); ok { r1 = rf(client, address) } else { @@ -674,6 +735,10 @@ func (_m *Utils) GetDataFromAPI(url string, localCache *cache.LocalCache) ([]byt ret := _m.Called(url, localCache) var r0 []byte + var r1 error + if rf, ok := ret.Get(0).(func(string, *cache.LocalCache) ([]byte, error)); ok { + return rf(url, localCache) + } if rf, ok := ret.Get(0).(func(string, *cache.LocalCache) []byte); ok { r0 = rf(url, localCache) } else { @@ -682,7 +747,6 @@ func (_m *Utils) GetDataFromAPI(url string, localCache *cache.LocalCache) ([]byt } } - var r1 error if rf, ok := ret.Get(1).(func(string, *cache.LocalCache) error); ok { r1 = rf(url, localCache) } else { @@ -697,6 +761,10 @@ func (_m *Utils) GetDataFromJSON(jsonObject map[string]interface{}, selector str ret := _m.Called(jsonObject, selector) var r0 interface{} + var r1 error + if rf, ok := ret.Get(0).(func(map[string]interface{}, string) (interface{}, error)); ok { + return rf(jsonObject, selector) + } if rf, ok := ret.Get(0).(func(map[string]interface{}, string) interface{}); ok { r0 = rf(jsonObject, selector) } else { @@ -705,7 +773,6 @@ func (_m *Utils) GetDataFromJSON(jsonObject map[string]interface{}, selector str } } - var r1 error if rf, ok := ret.Get(1).(func(map[string]interface{}, string) error); ok { r1 = rf(jsonObject, selector) } else { @@ -720,13 +787,16 @@ func (_m *Utils) GetDataFromXHTML(url string, selector string) (string, error) { ret := _m.Called(url, selector) var r0 string + var r1 error + if rf, ok := ret.Get(0).(func(string, string) (string, error)); ok { + return rf(url, selector) + } if rf, ok := ret.Get(0).(func(string, string) string); ok { r0 = rf(url, selector) } else { r0 = ret.Get(0).(string) } - var r1 error if rf, ok := ret.Get(1).(func(string, string) error); ok { r1 = rf(url, selector) } else { @@ -741,6 +811,10 @@ func (_m *Utils) GetDataToCommitFromJob(job bindings.StructsJob, localCache *cac ret := _m.Called(job, localCache) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(bindings.StructsJob, *cache.LocalCache) (*big.Int, error)); ok { + return rf(job, localCache) + } if rf, ok := ret.Get(0).(func(bindings.StructsJob, *cache.LocalCache) *big.Int); ok { r0 = rf(job, localCache) } else { @@ -749,7 +823,6 @@ func (_m *Utils) GetDataToCommitFromJob(job bindings.StructsJob, localCache *cac } } - var r1 error if rf, ok := ret.Get(1).(func(bindings.StructsJob, *cache.LocalCache) error); ok { r1 = rf(job, localCache) } else { @@ -764,6 +837,11 @@ func (_m *Utils) GetDataToCommitFromJobs(jobs []bindings.StructsJob, localCache ret := _m.Called(jobs, localCache) var r0 []*big.Int + var r1 []uint8 + var r2 error + if rf, ok := ret.Get(0).(func([]bindings.StructsJob, *cache.LocalCache) ([]*big.Int, []uint8, error)); ok { + return rf(jobs, localCache) + } if rf, ok := ret.Get(0).(func([]bindings.StructsJob, *cache.LocalCache) []*big.Int); ok { r0 = rf(jobs, localCache) } else { @@ -772,7 +850,6 @@ func (_m *Utils) GetDataToCommitFromJobs(jobs []bindings.StructsJob, localCache } } - var r1 []uint8 if rf, ok := ret.Get(1).(func([]bindings.StructsJob, *cache.LocalCache) []uint8); ok { r1 = rf(jobs, localCache) } else { @@ -781,7 +858,6 @@ func (_m *Utils) GetDataToCommitFromJobs(jobs []bindings.StructsJob, localCache } } - var r2 error if rf, ok := ret.Get(2).(func([]bindings.StructsJob, *cache.LocalCache) error); ok { r2 = rf(jobs, localCache) } else { @@ -796,13 +872,16 @@ func (_m *Utils) GetEpoch(client *ethclient.Client) (uint32, error) { ret := _m.Called(client) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint32, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint32); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -817,13 +896,16 @@ func (_m *Utils) GetEpochLastCommitted(client *ethclient.Client, stakerId uint32 ret := _m.Called(client, stakerId) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (uint32, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) uint32); ok { r0 = rf(client, stakerId) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -838,13 +920,16 @@ func (_m *Utils) GetEpochLastProposed(client *ethclient.Client, stakerId uint32) ret := _m.Called(client, stakerId) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (uint32, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) uint32); ok { r0 = rf(client, stakerId) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -859,13 +944,16 @@ func (_m *Utils) GetEpochLastRevealed(client *ethclient.Client, stakerId uint32) ret := _m.Called(client, stakerId) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (uint32, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) uint32); ok { r0 = rf(client, stakerId) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -880,13 +968,16 @@ func (_m *Utils) GetEpochLimitForUpdateCommission(client *ethclient.Client) (uin ret := _m.Called(client) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint16, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint16); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -901,6 +992,10 @@ func (_m *Utils) GetInfluenceSnapshot(client *ethclient.Client, stakerId uint32, ret := _m.Called(client, stakerId, epoch) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) (*big.Int, error)); ok { + return rf(client, stakerId, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) *big.Int); ok { r0 = rf(client, stakerId, epoch) } else { @@ -909,7 +1004,6 @@ func (_m *Utils) GetInfluenceSnapshot(client *ethclient.Client, stakerId uint32, } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint32) error); ok { r1 = rf(client, stakerId, epoch) } else { @@ -924,6 +1018,10 @@ func (_m *Utils) GetJobs(client *ethclient.Client) ([]bindings.StructsJob, error ret := _m.Called(client) var r0 []bindings.StructsJob + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) ([]bindings.StructsJob, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) []bindings.StructsJob); ok { r0 = rf(client) } else { @@ -932,7 +1030,6 @@ func (_m *Utils) GetJobs(client *ethclient.Client) ([]bindings.StructsJob, error } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -947,13 +1044,16 @@ func (_m *Utils) GetLeafIdOfACollection(client *ethclient.Client, collectionId u ret := _m.Called(client, collectionId) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) (uint16, error)); ok { + return rf(client, collectionId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint16) uint16); ok { r0 = rf(client, collectionId) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint16) error); ok { r1 = rf(client, collectionId) } else { @@ -968,13 +1068,16 @@ func (_m *Utils) GetLock(client *ethclient.Client, address string, stakerId uint ret := _m.Called(client, address, stakerId, lockType) var r0 types.Locks + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, string, uint32, uint8) (types.Locks, error)); ok { + return rf(client, address, stakerId, lockType) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, string, uint32, uint8) types.Locks); ok { r0 = rf(client, address, stakerId, lockType) } else { r0 = ret.Get(0).(types.Locks) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, string, uint32, uint8) error); ok { r1 = rf(client, address, stakerId, lockType) } else { @@ -989,13 +1092,16 @@ func (_m *Utils) GetMaxAltBlocks(client *ethclient.Client) (uint8, error) { ret := _m.Called(client) var r0 uint8 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint8, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint8); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint8) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1010,13 +1116,16 @@ func (_m *Utils) GetMaxCommission(client *ethclient.Client) (uint8, error) { ret := _m.Called(client) var r0 uint8 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint8, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint8); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint8) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1031,6 +1140,10 @@ func (_m *Utils) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) { ret := _m.Called(client) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (*big.Int, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) *big.Int); ok { r0 = rf(client) } else { @@ -1039,7 +1152,6 @@ func (_m *Utils) GetMinSafeRazor(client *ethclient.Client) (*big.Int, error) { } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1054,6 +1166,10 @@ func (_m *Utils) GetMinStakeAmount(client *ethclient.Client) (*big.Int, error) { ret := _m.Called(client) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (*big.Int, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) *big.Int); ok { r0 = rf(client) } else { @@ -1062,7 +1178,6 @@ func (_m *Utils) GetMinStakeAmount(client *ethclient.Client) (*big.Int, error) { } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1077,13 +1192,16 @@ func (_m *Utils) GetNumActiveCollections(client *ethclient.Client) (uint16, erro ret := _m.Called(client) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint16, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint16); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1098,13 +1216,16 @@ func (_m *Utils) GetNumCollections(client *ethclient.Client) (uint16, error) { ret := _m.Called(client) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint16, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint16); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1119,13 +1240,16 @@ func (_m *Utils) GetNumberOfProposedBlocks(client *ethclient.Client, epoch uint3 ret := _m.Called(client, epoch) var r0 uint8 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (uint8, error)); ok { + return rf(client, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) uint8); ok { r0 = rf(client, epoch) } else { r0 = ret.Get(0).(uint8) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, epoch) } else { @@ -1140,13 +1264,16 @@ func (_m *Utils) GetNumberOfStakers(client *ethclient.Client) (uint32, error) { ret := _m.Called(client) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint32, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint32); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1175,13 +1302,16 @@ func (_m *Utils) GetProposedBlock(client *ethclient.Client, epoch uint32, propos ret := _m.Called(client, epoch, proposedBlockId) var r0 bindings.StructsBlock + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) (bindings.StructsBlock, error)); ok { + return rf(client, epoch, proposedBlockId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) bindings.StructsBlock); ok { r0 = rf(client, epoch, proposedBlockId) } else { r0 = ret.Get(0).(bindings.StructsBlock) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint32) error); ok { r1 = rf(client, epoch, proposedBlockId) } else { @@ -1196,13 +1326,16 @@ func (_m *Utils) GetRemainingTimeOfCurrentState(client *ethclient.Client, buffer ret := _m.Called(client, bufferPercent) var r0 int64 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, int32) (int64, error)); ok { + return rf(client, bufferPercent) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, int32) int64); ok { r0 = rf(client, bufferPercent) } else { r0 = ret.Get(0).(int64) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, int32) error); ok { r1 = rf(client, bufferPercent) } else { @@ -1233,13 +1366,16 @@ func (_m *Utils) GetSortedProposedBlockId(client *ethclient.Client, epoch uint32 ret := _m.Called(client, epoch, index) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, *big.Int) (uint32, error)); ok { + return rf(client, epoch, index) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, *big.Int) uint32); ok { r0 = rf(client, epoch, index) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, *big.Int) error); ok { r1 = rf(client, epoch, index) } else { @@ -1254,6 +1390,10 @@ func (_m *Utils) GetSortedProposedBlockIds(client *ethclient.Client, epoch uint3 ret := _m.Called(client, epoch) var r0 []uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) ([]uint32, error)); ok { + return rf(client, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) []uint32); ok { r0 = rf(client, epoch) } else { @@ -1262,7 +1402,6 @@ func (_m *Utils) GetSortedProposedBlockIds(client *ethclient.Client, epoch uint3 } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, epoch) } else { @@ -1277,6 +1416,10 @@ func (_m *Utils) GetStake(client *ethclient.Client, stakerId uint32) (*big.Int, ret := _m.Called(client, stakerId) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (*big.Int, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) *big.Int); ok { r0 = rf(client, stakerId) } else { @@ -1285,7 +1428,6 @@ func (_m *Utils) GetStake(client *ethclient.Client, stakerId uint32) (*big.Int, } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -1316,6 +1458,10 @@ func (_m *Utils) GetStakeManagerWithOpts(client *ethclient.Client) (*bindings.St ret := _m.Called(client) var r0 *bindings.StakeManager + var r1 bind.CallOpts + if rf, ok := ret.Get(0).(func(*ethclient.Client) (*bindings.StakeManager, bind.CallOpts)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) *bindings.StakeManager); ok { r0 = rf(client) } else { @@ -1324,7 +1470,6 @@ func (_m *Utils) GetStakeManagerWithOpts(client *ethclient.Client) (*bindings.St } } - var r1 bind.CallOpts if rf, ok := ret.Get(1).(func(*ethclient.Client) bind.CallOpts); ok { r1 = rf(client) } else { @@ -1339,6 +1484,10 @@ func (_m *Utils) GetStakeSnapshot(client *ethclient.Client, stakerId uint32, epo ret := _m.Called(client, stakerId, epoch) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) (*big.Int, error)); ok { + return rf(client, stakerId, epoch) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) *big.Int); ok { r0 = rf(client, stakerId, epoch) } else { @@ -1347,7 +1496,6 @@ func (_m *Utils) GetStakeSnapshot(client *ethclient.Client, stakerId uint32, epo } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint32) error); ok { r1 = rf(client, stakerId, epoch) } else { @@ -1378,6 +1526,10 @@ func (_m *Utils) GetStakedTokenManagerWithOpts(client *ethclient.Client, tokenAd ret := _m.Called(client, tokenAddress) var r0 *bindings.StakedToken + var r1 bind.CallOpts + if rf, ok := ret.Get(0).(func(*ethclient.Client, common.Address) (*bindings.StakedToken, bind.CallOpts)); ok { + return rf(client, tokenAddress) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, common.Address) *bindings.StakedToken); ok { r0 = rf(client, tokenAddress) } else { @@ -1386,7 +1538,6 @@ func (_m *Utils) GetStakedTokenManagerWithOpts(client *ethclient.Client, tokenAd } } - var r1 bind.CallOpts if rf, ok := ret.Get(1).(func(*ethclient.Client, common.Address) bind.CallOpts); ok { r1 = rf(client, tokenAddress) } else { @@ -1401,13 +1552,16 @@ func (_m *Utils) GetStaker(client *ethclient.Client, stakerId uint32) (bindings. ret := _m.Called(client, stakerId) var r0 bindings.StructsStaker + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (bindings.StructsStaker, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) bindings.StructsStaker); ok { r0 = rf(client, stakerId) } else { r0 = ret.Get(0).(bindings.StructsStaker) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -1422,13 +1576,16 @@ func (_m *Utils) GetStakerId(client *ethclient.Client, address string) (uint32, ret := _m.Called(client, address) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, string) (uint32, error)); ok { + return rf(client, address) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, string) uint32); ok { r0 = rf(client, address) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, string) error); ok { r1 = rf(client, address) } else { @@ -1443,6 +1600,10 @@ func (_m *Utils) GetStakerSRZRBalance(client *ethclient.Client, staker bindings. ret := _m.Called(client, staker) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, bindings.StructsStaker) (*big.Int, error)); ok { + return rf(client, staker) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, bindings.StructsStaker) *big.Int); ok { r0 = rf(client, staker) } else { @@ -1451,7 +1612,6 @@ func (_m *Utils) GetStakerSRZRBalance(client *ethclient.Client, staker bindings. } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, bindings.StructsStaker) error); ok { r1 = rf(client, staker) } else { @@ -1466,13 +1626,16 @@ func (_m *Utils) GetStateBuffer(client *ethclient.Client) (uint64, error) { ret := _m.Called(client) var r0 uint64 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint64, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint64); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint64) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1503,6 +1666,10 @@ func (_m *Utils) GetTotalInfluenceRevealed(client *ethclient.Client, epoch uint3 ret := _m.Called(client, epoch, medianIndex) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint16) (*big.Int, error)); ok { + return rf(client, epoch, medianIndex) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint16) *big.Int); ok { r0 = rf(client, epoch, medianIndex) } else { @@ -1511,7 +1678,6 @@ func (_m *Utils) GetTotalInfluenceRevealed(client *ethclient.Client, epoch uint3 } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint16) error); ok { r1 = rf(client, epoch, medianIndex) } else { @@ -1542,13 +1708,16 @@ func (_m *Utils) GetUint32(flagSet *pflag.FlagSet, name string) (uint32, error) ret := _m.Called(flagSet, name) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*pflag.FlagSet, string) (uint32, error)); ok { + return rf(flagSet, name) + } if rf, ok := ret.Get(0).(func(*pflag.FlagSet, string) uint32); ok { r0 = rf(flagSet, name) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*pflag.FlagSet, string) error); ok { r1 = rf(flagSet, name) } else { @@ -1579,6 +1748,10 @@ func (_m *Utils) GetVoteManagerWithOpts(client *ethclient.Client) (*bindings.Vot ret := _m.Called(client) var r0 *bindings.VoteManager + var r1 bind.CallOpts + if rf, ok := ret.Get(0).(func(*ethclient.Client) (*bindings.VoteManager, bind.CallOpts)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) *bindings.VoteManager); ok { r0 = rf(client) } else { @@ -1587,7 +1760,6 @@ func (_m *Utils) GetVoteManagerWithOpts(client *ethclient.Client) (*bindings.Vot } } - var r1 bind.CallOpts if rf, ok := ret.Get(1).(func(*ethclient.Client) bind.CallOpts); ok { r1 = rf(client) } else { @@ -1602,6 +1774,10 @@ func (_m *Utils) GetVoteValue(client *ethclient.Client, epoch uint32, stakerId u ret := _m.Called(client, epoch, stakerId, medianIndex) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32, uint16) (*big.Int, error)); ok { + return rf(client, epoch, stakerId, medianIndex) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32, uint16) *big.Int); ok { r0 = rf(client, epoch, stakerId, medianIndex) } else { @@ -1610,7 +1786,6 @@ func (_m *Utils) GetVoteValue(client *ethclient.Client, epoch uint32, stakerId u } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint32, uint16) error); ok { r1 = rf(client, epoch, stakerId, medianIndex) } else { @@ -1625,13 +1800,16 @@ func (_m *Utils) GetWithdrawInitiationPeriod(client *ethclient.Client) (uint16, ret := _m.Called(client) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint16, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint16); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1646,6 +1824,10 @@ func (_m *Utils) HandleOfficialJobsFromJSONFile(client *ethclient.Client, collec ret := _m.Called(client, collection, dataString) var r0 []bindings.StructsJob + var r1 []uint16 + if rf, ok := ret.Get(0).(func(*ethclient.Client, bindings.StructsCollection, string) ([]bindings.StructsJob, []uint16)); ok { + return rf(client, collection, dataString) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, bindings.StructsCollection, string) []bindings.StructsJob); ok { r0 = rf(client, collection, dataString) } else { @@ -1654,7 +1836,6 @@ func (_m *Utils) HandleOfficialJobsFromJSONFile(client *ethclient.Client, collec } } - var r1 []uint16 if rf, ok := ret.Get(1).(func(*ethclient.Client, bindings.StructsCollection, string) []uint16); ok { r1 = rf(client, collection, dataString) } else { @@ -1745,6 +1926,10 @@ func (_m *Utils) ReadJSONData(fileName string) (map[string]*types.StructsJob, er ret := _m.Called(fileName) var r0 map[string]*types.StructsJob + var r1 error + if rf, ok := ret.Get(0).(func(string) (map[string]*types.StructsJob, error)); ok { + return rf(fileName) + } if rf, ok := ret.Get(0).(func(string) map[string]*types.StructsJob); ok { r0 = rf(fileName) } else { @@ -1753,7 +1938,6 @@ func (_m *Utils) ReadJSONData(fileName string) (map[string]*types.StructsJob, er } } - var r1 error if rf, ok := ret.Get(1).(func(string) error); ok { r1 = rf(fileName) } else { @@ -1782,13 +1966,16 @@ func (_m *Utils) ToAssign(client *ethclient.Client) (uint16, error) { ret := _m.Called(client) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint16, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint16); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -1831,13 +2018,12 @@ func (_m *Utils) WriteDataToJSON(fileName string, data map[string]*types.Structs return r0 } -type mockConstructorTestingTNewUtils interface { +// NewUtils creates a new instance of Utils. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewUtils(t interface { mock.TestingT Cleanup(func()) -} - -// NewUtils creates a new instance of Utils. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewUtils(t mockConstructorTestingTNewUtils) *Utils { +}) *Utils { mock := &Utils{} mock.Mock.Test(t) diff --git a/utils/mocks/vote_manager_utils.go b/utils/mocks/vote_manager_utils.go index ac1baf9ba..c94b1b57f 100644 --- a/utils/mocks/vote_manager_utils.go +++ b/utils/mocks/vote_manager_utils.go @@ -1,4 +1,4 @@ -// Code generated by mockery v2.14.0. DO NOT EDIT. +// Code generated by mockery v2.30.1. DO NOT EDIT. package mocks @@ -16,18 +16,21 @@ type VoteManagerUtils struct { mock.Mock } -// Commitments provides a mock function with given fields: client, stakerId -func (_m *VoteManagerUtils) Commitments(client *ethclient.Client, stakerId uint32) (types.Commitment, error) { +// GetCommitment provides a mock function with given fields: client, stakerId +func (_m *VoteManagerUtils) GetCommitment(client *ethclient.Client, stakerId uint32) (types.Commitment, error) { ret := _m.Called(client, stakerId) var r0 types.Commitment + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (types.Commitment, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) types.Commitment); ok { r0 = rf(client, stakerId) } else { r0 = ret.Get(0).(types.Commitment) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -42,13 +45,16 @@ func (_m *VoteManagerUtils) GetEpochLastCommitted(client *ethclient.Client, stak ret := _m.Called(client, stakerId) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (uint32, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) uint32); ok { r0 = rf(client, stakerId) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -63,13 +69,16 @@ func (_m *VoteManagerUtils) GetEpochLastRevealed(client *ethclient.Client, stake ret := _m.Called(client, stakerId) var r0 uint32 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) (uint32, error)); ok { + return rf(client, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32) uint32); ok { r0 = rf(client, stakerId) } else { r0 = ret.Get(0).(uint32) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32) error); ok { r1 = rf(client, stakerId) } else { @@ -84,6 +93,10 @@ func (_m *VoteManagerUtils) GetInfluenceSnapshot(client *ethclient.Client, epoch ret := _m.Called(client, epoch, stakerId) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) (*big.Int, error)); ok { + return rf(client, epoch, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) *big.Int); ok { r0 = rf(client, epoch, stakerId) } else { @@ -92,7 +105,6 @@ func (_m *VoteManagerUtils) GetInfluenceSnapshot(client *ethclient.Client, epoch } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint32) error); ok { r1 = rf(client, epoch, stakerId) } else { @@ -107,6 +119,10 @@ func (_m *VoteManagerUtils) GetSaltFromBlockchain(client *ethclient.Client) ([32 ret := _m.Called(client) var r0 [32]byte + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) ([32]byte, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) [32]byte); ok { r0 = rf(client) } else { @@ -115,7 +131,6 @@ func (_m *VoteManagerUtils) GetSaltFromBlockchain(client *ethclient.Client) ([32 } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -130,6 +145,10 @@ func (_m *VoteManagerUtils) GetStakeSnapshot(client *ethclient.Client, epoch uin ret := _m.Called(client, epoch, stakerId) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) (*big.Int, error)); ok { + return rf(client, epoch, stakerId) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32) *big.Int); ok { r0 = rf(client, epoch, stakerId) } else { @@ -138,7 +157,6 @@ func (_m *VoteManagerUtils) GetStakeSnapshot(client *ethclient.Client, epoch uin } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint32) error); ok { r1 = rf(client, epoch, stakerId) } else { @@ -153,6 +171,10 @@ func (_m *VoteManagerUtils) GetTotalInfluenceRevealed(client *ethclient.Client, ret := _m.Called(client, epoch, medianIndex) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint16) (*big.Int, error)); ok { + return rf(client, epoch, medianIndex) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint16) *big.Int); ok { r0 = rf(client, epoch, medianIndex) } else { @@ -161,7 +183,6 @@ func (_m *VoteManagerUtils) GetTotalInfluenceRevealed(client *ethclient.Client, } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint16) error); ok { r1 = rf(client, epoch, medianIndex) } else { @@ -176,6 +197,10 @@ func (_m *VoteManagerUtils) GetVoteValue(client *ethclient.Client, epoch uint32, ret := _m.Called(client, epoch, stakerId, medianIndex) var r0 *big.Int + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32, uint16) (*big.Int, error)); ok { + return rf(client, epoch, stakerId, medianIndex) + } if rf, ok := ret.Get(0).(func(*ethclient.Client, uint32, uint32, uint16) *big.Int); ok { r0 = rf(client, epoch, stakerId, medianIndex) } else { @@ -184,7 +209,6 @@ func (_m *VoteManagerUtils) GetVoteValue(client *ethclient.Client, epoch uint32, } } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client, uint32, uint32, uint16) error); ok { r1 = rf(client, epoch, stakerId, medianIndex) } else { @@ -199,13 +223,16 @@ func (_m *VoteManagerUtils) ToAssign(client *ethclient.Client) (uint16, error) { ret := _m.Called(client) var r0 uint16 + var r1 error + if rf, ok := ret.Get(0).(func(*ethclient.Client) (uint16, error)); ok { + return rf(client) + } if rf, ok := ret.Get(0).(func(*ethclient.Client) uint16); ok { r0 = rf(client) } else { r0 = ret.Get(0).(uint16) } - var r1 error if rf, ok := ret.Get(1).(func(*ethclient.Client) error); ok { r1 = rf(client) } else { @@ -215,13 +242,12 @@ func (_m *VoteManagerUtils) ToAssign(client *ethclient.Client) (uint16, error) { return r0, r1 } -type mockConstructorTestingTNewVoteManagerUtils interface { +// NewVoteManagerUtils creates a new instance of VoteManagerUtils. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. +// The first argument is typically a *testing.T value. +func NewVoteManagerUtils(t interface { mock.TestingT Cleanup(func()) -} - -// NewVoteManagerUtils creates a new instance of VoteManagerUtils. It also registers a testing interface on the mock and a cleanup function to assert the mocks expectations. -func NewVoteManagerUtils(t mockConstructorTestingTNewVoteManagerUtils) *VoteManagerUtils { +}) *VoteManagerUtils { mock := &VoteManagerUtils{} mock.Mock.Test(t) diff --git a/utils/struct-utils.go b/utils/struct-utils.go index ed80fa601..4eb404a85 100644 --- a/utils/struct-utils.go +++ b/utils/struct-utils.go @@ -456,11 +456,11 @@ func (a AssetManagerStruct) Jobs(client *ethclient.Client, id uint16) (bindings. return job, nil } -func (v VoteManagerStruct) Commitments(client *ethclient.Client, stakerId uint32) (coretypes.Commitment, error) { +func (v VoteManagerStruct) GetCommitment(client *ethclient.Client, stakerId uint32) (coretypes.Commitment, error) { voteManager, opts := UtilsInterface.GetVoteManagerWithOpts(client) returnedValues := InvokeFunctionWithTimeout(voteManager, "Commitments", &opts, stakerId) returnedError := CheckIfAnyError(returnedValues) - if returnedValues != nil { + if returnedError != nil { return coretypes.Commitment{}, returnedError } commitment := returnedValues[0].Interface().(struct { diff --git a/utils/vote.go b/utils/vote.go index 59248704b..b5d2f0616 100644 --- a/utils/vote.go +++ b/utils/vote.go @@ -13,17 +13,17 @@ func (*UtilsStruct) GetVoteManagerWithOpts(client *ethclient.Client) (*bindings. return UtilsInterface.GetVoteManager(client), UtilsInterface.GetOptions() } -func (*UtilsStruct) GetCommitments(client *ethclient.Client, address string) ([32]byte, error) { +func (*UtilsStruct) GetCommitment(client *ethclient.Client, address string) (types.Commitment, error) { stakerId, err := UtilsInterface.GetStakerId(client, address) if err != nil { - return [32]byte{}, err + return types.Commitment{}, err } - returnedValues, err := InvokeFunctionWithRetryAttempts(VoteManagerInterface, "Commitments", client, stakerId) + returnedValues, err := InvokeFunctionWithRetryAttempts(VoteManagerInterface, "GetCommitment", client, stakerId) if err != nil { - return [32]byte{}, err + return types.Commitment{}, err } commitment := returnedValues[0].Interface().(types.Commitment) - return commitment.CommitmentHash, nil + return commitment, nil } func (*UtilsStruct) GetVoteValue(client *ethclient.Client, epoch uint32, stakerId uint32, medianIndex uint16) (*big.Int, error) { diff --git a/utils/vote_test.go b/utils/vote_test.go index 145777a90..df90c568b 100644 --- a/utils/vote_test.go +++ b/utils/vote_test.go @@ -29,16 +29,16 @@ func TestGetCommitments(t *testing.T) { tests := []struct { name string args args - want [32]byte + want types.Commitment wantErr bool }{ { - name: "Test 1: When GetCommitments() executes successfully", + name: "Test 1: When GetCommitment() executes successfully", args: args{ stakerId: 1, commitments: types.Commitment{}, }, - want: [32]byte{}, + want: types.Commitment{}, wantErr: false, }, { @@ -47,7 +47,7 @@ func TestGetCommitments(t *testing.T) { stakerIdErr: errors.New("stakerId error"), commitments: types.Commitment{}, }, - want: [32]byte{}, + want: types.Commitment{}, wantErr: true, }, { @@ -56,7 +56,7 @@ func TestGetCommitments(t *testing.T) { stakerId: 1, commitmentErr: errors.New("commitments error"), }, - want: [32]byte{}, + want: types.Commitment{}, wantErr: true, }, } @@ -75,16 +75,16 @@ func TestGetCommitments(t *testing.T) { utilsMock.On("GetOptions").Return(callOpts) utilsMock.On("GetStakerId", mock.AnythingOfType("*ethclient.Client"), mock.AnythingOfType("string")).Return(tt.args.stakerId, tt.args.stakerIdErr) - voteManagerMock.On("Commitments", mock.AnythingOfType("*ethclient.Client"), mock.AnythingOfType("uint32")).Return(tt.args.commitments, tt.args.commitmentErr) + voteManagerMock.On("GetCommitment", mock.AnythingOfType("*ethclient.Client"), mock.AnythingOfType("uint32")).Return(tt.args.commitments, tt.args.commitmentErr) retryMock.On("RetryAttempts", mock.AnythingOfType("uint")).Return(retry.Attempts(1)) - got, err := utils.GetCommitments(client, address) + got, err := utils.GetCommitment(client, address) if (err != nil) != tt.wantErr { - t.Errorf("GetCommitments() error = %v, wantErr %v", err, tt.wantErr) + t.Errorf("GetCommitment() error = %v, wantErr %v", err, tt.wantErr) return } if !reflect.DeepEqual(got, tt.want) { - t.Errorf("GetCommitments() got = %v, want %v", got, tt.want) + t.Errorf("GetCommitment() got = %v, want %v", got, tt.want) } }) }