From 48313305925ce0cc17f5be23b0e7152d577e8726 Mon Sep 17 00:00:00 2001 From: Francisco de Borja Aranda Castillejo Date: Wed, 16 Oct 2024 11:05:27 +0200 Subject: [PATCH] GH3005: disable stake, unstake and moveStake --- cmd/zetae2e/local/local.go | 4 +- precompiles/staking/staking.go | 96 +- precompiles/staking/staking_test.go | 1698 +++++++++++++-------------- 3 files changed, 899 insertions(+), 899 deletions(-) diff --git a/cmd/zetae2e/local/local.go b/cmd/zetae2e/local/local.go index 2d404ba391..8081ba6759 100644 --- a/cmd/zetae2e/local/local.go +++ b/cmd/zetae2e/local/local.go @@ -329,8 +329,8 @@ func localE2ETest(cmd *cobra.Command, _ []string) { precompiledContractTests = []string{ e2etests.TestPrecompilesPrototypeName, e2etests.TestPrecompilesPrototypeThroughContractName, - e2etests.TestPrecompilesStakingName, - e2etests.TestPrecompilesStakingThroughContractName, + // e2etests.TestPrecompilesStakingName, + // e2etests.TestPrecompilesStakingThroughContractName, e2etests.TestPrecompilesBankName, e2etests.TestPrecompilesBankFailName, e2etests.TestPrecompilesBankThroughContractName, diff --git a/precompiles/staking/staking.go b/precompiles/staking/staking.go index f3a01a541e..665a8f8060 100644 --- a/precompiles/staking/staking.go +++ b/precompiles/staking/staking.go @@ -414,54 +414,54 @@ func (c *Contract) Run(evm *vm.EVM, contract *vm.Contract, readOnly bool) ([]byt return nil, err } return res, nil - case StakeMethodName: - if readOnly { - return nil, ptypes.ErrWriteMethod{ - Method: method.Name, - } - } - - var res []byte - execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error { - res, err = c.Stake(ctx, evm, contract, method, args) - return err - }) - if execErr != nil { - return nil, err - } - return res, nil - case UnstakeMethodName: - if readOnly { - return nil, ptypes.ErrWriteMethod{ - Method: method.Name, - } - } - - var res []byte - execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error { - res, err = c.Unstake(ctx, evm, contract, method, args) - return err - }) - if execErr != nil { - return nil, err - } - return res, nil - case MoveStakeMethodName: - if readOnly { - return nil, ptypes.ErrWriteMethod{ - Method: method.Name, - } - } - - var res []byte - execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error { - res, err = c.MoveStake(ctx, evm, contract, method, args) - return err - }) - if execErr != nil { - return nil, err - } - return res, nil + // case StakeMethodName: + // if readOnly { + // return nil, ptypes.ErrWriteMethod{ + // Method: method.Name, + // } + // } + + // var res []byte + // execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error { + // res, err = c.Stake(ctx, evm, contract, method, args) + // return err + // }) + // if execErr != nil { + // return nil, err + // } + // return res, nil + // case UnstakeMethodName: + // if readOnly { + // return nil, ptypes.ErrWriteMethod{ + // Method: method.Name, + // } + // } + + // var res []byte + // execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error { + // res, err = c.Unstake(ctx, evm, contract, method, args) + // return err + // }) + // if execErr != nil { + // return nil, err + // } + // return res, nil + // case MoveStakeMethodName: + // if readOnly { + // return nil, ptypes.ErrWriteMethod{ + // Method: method.Name, + // } + // } + + // var res []byte + // execErr := stateDB.ExecuteNativeAction(contract.Address(), nil, func(ctx sdk.Context) error { + // res, err = c.MoveStake(ctx, evm, contract, method, args) + // return err + // }) + // if execErr != nil { + // return nil, err + // } + // return res, nil default: return nil, ptypes.ErrInvalidMethod{ diff --git a/precompiles/staking/staking_test.go b/precompiles/staking/staking_test.go index 94c1a432c1..05b5f00e87 100644 --- a/precompiles/staking/staking_test.go +++ b/precompiles/staking/staking_test.go @@ -237,855 +237,855 @@ func Test_InvalidABI(t *testing.T) { initABI() } -func Test_Stake(t *testing.T) { - t.Run("should fail if validator doesn't exist", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - mockVMContract.Input = packInputArgs(t, methodID, args...) - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should stake", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - mockVMContract.Input = packInputArgs(t, methodID, args...) - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.NoError(t, err) - }) - - t.Run("should fail if no input args", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - mockVMContract.Input = methodID.ID - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if caller is not staker", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - - nonStakerAddr := common.BytesToAddress(sample.Bech32AccAddress().Bytes()) - args := []interface{}{nonStakerAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - mockVMContract.Input = packInputArgs(t, methodID, args...) - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.ErrorContains(t, err, "caller is not staker address") - }) - - t.Run("should fail if staking fails", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - // staker without funds - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - mockVMContract.Input = packInputArgs(t, methodID, args...) - - // ACT - _, err := contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if wrong args amount", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{stakerEthAddr, validator.OperatorAddress} - - // ACT - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if staker is not eth addr", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{staker, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - - // ACT - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if validator is not valid string", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{stakerEthAddr, 42, coins.AmountOf(config.BaseDenom).BigInt()} - - // ACT - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if amount is not int64", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[StakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).Uint64()} - - // ACT - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) -} - -func Test_Unstake(t *testing.T) { - t.Run("should fail if validator doesn't exist", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - mockVMContract.Input = packInputArgs(t, methodID, args...) - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should unstake", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - - // stake first - stakeMethodID := abi.Methods[StakeMethodName] - mockVMContract.Input = packInputArgs(t, stakeMethodID, args...) - _, err = contract.Run(mockEVM, mockVMContract, false) - require.NoError(t, err) - - // ACT - mockVMContract.Input = packInputArgs(t, methodID, args...) - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.NoError(t, err) - }) - - t.Run("should fail if caller is not staker", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - // stake first - stakeMethodID := abi.Methods[StakeMethodName] - mockVMContract.Input = packInputArgs(t, stakeMethodID, args...) - _, err = contract.Run(mockEVM, mockVMContract, false) - require.NoError(t, err) - - callerEthAddr := common.BytesToAddress(sample.Bech32AccAddress().Bytes()) - mockVMContract.CallerAddress = callerEthAddr - mockVMContract.Input = packInputArgs(t, methodID, args...) - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.ErrorContains(t, err, "caller is not staker address") - }) - - t.Run("should fail if no previous staking", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - mockVMContract.Input = packInputArgs(t, methodID, args...) - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if wrong args amount", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{stakerEthAddr, validator.OperatorAddress} - - // ACT - _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if staker is not eth addr", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{staker, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} - - // ACT - _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if validator is not valid string", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{stakerEthAddr, 42, coins.AmountOf(config.BaseDenom).BigInt()} - - // ACT - _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if amount is not int64", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[UnstakeMethodName] - r := rand.New(rand.NewSource(42)) - validator := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validator) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).Uint64()} - - // ACT - _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) - - // ASSERT - require.Error(t, err) - }) -} - -func Test_MoveStake(t *testing.T) { - t.Run("should fail if validator dest doesn't exist", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - mockVMContract.Input = packInputArgs(t, stakeMethodID, argsStake...) - _, err = contract.Run(mockEVM, mockVMContract, false) - require.NoError(t, err) - - argsMoveStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - validatorDest.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - mockVMContract.Input = packInputArgs(t, methodID, argsMoveStake...) - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should move stake", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - mockVMContract.Input = packInputArgs(t, stakeMethodID, argsStake...) - _, err = contract.Run(mockEVM, mockVMContract, false) - require.NoError(t, err) - - argsMoveStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - validatorDest.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - mockVMContract.Input = packInputArgs(t, methodID, argsMoveStake...) - - // ACT - // move stake to validator dest - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.NoError(t, err) - }) - - t.Run("should fail if staker is invalid arg", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) - require.NoError(t, err) - - argsMoveStake := []interface{}{ - 42, - validatorSrc.OperatorAddress, - validatorDest.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // ACT - _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if validator src is invalid arg", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) - require.NoError(t, err) - - argsMoveStake := []interface{}{ - stakerEthAddr, - 42, - validatorDest.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // ACT - _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if validator dest is invalid arg", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) - require.NoError(t, err) - - argsMoveStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - 42, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // ACT - _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if amount is invalid arg", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) - require.NoError(t, err) - - argsMoveStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - validatorDest.OperatorAddress, - coins.AmountOf(config.BaseDenom).Uint64(), - } - - // ACT - _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if wrong args amount", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) - require.NoError(t, err) - - argsMoveStake := []interface{}{stakerEthAddr, validatorSrc.OperatorAddress, validatorDest.OperatorAddress} - - // ACT - _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) - - // ASSERT - require.Error(t, err) - }) - - t.Run("should fail if caller is not staker", func(t *testing.T) { - // ARRANGE - ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) - methodID := abi.Methods[MoveStakeMethodName] - r := rand.New(rand.NewSource(42)) - validatorSrc := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) - validatorDest := sample.Validator(t, r) - sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) - - staker := sample.Bech32AccAddress() - stakerEthAddr := common.BytesToAddress(staker.Bytes()) - coins := sample.Coins() - err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) - require.NoError(t, err) - err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) - require.NoError(t, err) - - stakerAddr := common.BytesToAddress(staker.Bytes()) - mockVMContract.CallerAddress = stakerAddr - argsStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - - // stake to validator src - stakeMethodID := abi.Methods[StakeMethodName] - mockVMContract.Input = packInputArgs(t, stakeMethodID, argsStake...) - _, err = contract.Run(mockEVM, mockVMContract, false) - require.NoError(t, err) - - argsMoveStake := []interface{}{ - stakerEthAddr, - validatorSrc.OperatorAddress, - validatorDest.OperatorAddress, - coins.AmountOf(config.BaseDenom).BigInt(), - } - mockVMContract.Input = packInputArgs(t, methodID, argsMoveStake...) - - callerEthAddr := common.BytesToAddress(sample.Bech32AccAddress().Bytes()) - mockVMContract.CallerAddress = callerEthAddr - - // ACT - _, err = contract.Run(mockEVM, mockVMContract, false) - - // ASSERT - require.ErrorContains(t, err, "caller is not staker") - }) -} +// func Test_Stake(t *testing.T) { +// t.Run("should fail if validator doesn't exist", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} +// mockVMContract.Input = packInputArgs(t, methodID, args...) + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should stake", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} +// mockVMContract.Input = packInputArgs(t, methodID, args...) + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.NoError(t, err) +// }) + +// t.Run("should fail if no input args", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr +// mockVMContract.Input = methodID.ID + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if caller is not staker", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr + +// nonStakerAddr := common.BytesToAddress(sample.Bech32AccAddress().Bytes()) +// args := []interface{}{nonStakerAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} +// mockVMContract.Input = packInputArgs(t, methodID, args...) + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.ErrorContains(t, err, "caller is not staker address") +// }) + +// t.Run("should fail if staking fails", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// // staker without funds +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} +// mockVMContract.Input = packInputArgs(t, methodID, args...) + +// // ACT +// _, err := contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if wrong args amount", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress} + +// // ACT +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if staker is not eth addr", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{staker, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} + +// // ACT +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if validator is not valid string", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{stakerEthAddr, 42, coins.AmountOf(config.BaseDenom).BigInt()} + +// // ACT +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if amount is not int64", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[StakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).Uint64()} + +// // ACT +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) +// } + +// func Test_Unstake(t *testing.T) { +// t.Run("should fail if validator doesn't exist", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} +// mockVMContract.Input = packInputArgs(t, methodID, args...) + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should unstake", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} + +// // stake first +// stakeMethodID := abi.Methods[StakeMethodName] +// mockVMContract.Input = packInputArgs(t, stakeMethodID, args...) +// _, err = contract.Run(mockEVM, mockVMContract, false) +// require.NoError(t, err) + +// // ACT +// mockVMContract.Input = packInputArgs(t, methodID, args...) +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.NoError(t, err) +// }) + +// t.Run("should fail if caller is not staker", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} +// // stake first +// stakeMethodID := abi.Methods[StakeMethodName] +// mockVMContract.Input = packInputArgs(t, stakeMethodID, args...) +// _, err = contract.Run(mockEVM, mockVMContract, false) +// require.NoError(t, err) + +// callerEthAddr := common.BytesToAddress(sample.Bech32AccAddress().Bytes()) +// mockVMContract.CallerAddress = callerEthAddr +// mockVMContract.Input = packInputArgs(t, methodID, args...) + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.ErrorContains(t, err, "caller is not staker address") +// }) + +// t.Run("should fail if no previous staking", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} +// mockVMContract.Input = packInputArgs(t, methodID, args...) + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if wrong args amount", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress} + +// // ACT +// _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if staker is not eth addr", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{staker, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).BigInt()} + +// // ACT +// _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if validator is not valid string", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{stakerEthAddr, 42, coins.AmountOf(config.BaseDenom).BigInt()} + +// // ACT +// _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if amount is not int64", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[UnstakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validator := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validator) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// args := []interface{}{stakerEthAddr, validator.OperatorAddress, coins.AmountOf(config.BaseDenom).Uint64()} + +// // ACT +// _, err = contract.Unstake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, args) + +// // ASSERT +// require.Error(t, err) +// }) +// } + +// func Test_MoveStake(t *testing.T) { +// t.Run("should fail if validator dest doesn't exist", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr + +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// mockVMContract.Input = packInputArgs(t, stakeMethodID, argsStake...) +// _, err = contract.Run(mockEVM, mockVMContract, false) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// validatorDest.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } +// mockVMContract.Input = packInputArgs(t, methodID, argsMoveStake...) + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should move stake", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// mockVMContract.Input = packInputArgs(t, stakeMethodID, argsStake...) +// _, err = contract.Run(mockEVM, mockVMContract, false) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// validatorDest.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } +// mockVMContract.Input = packInputArgs(t, methodID, argsMoveStake...) + +// // ACT +// // move stake to validator dest +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.NoError(t, err) +// }) + +// t.Run("should fail if staker is invalid arg", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{ +// 42, +// validatorSrc.OperatorAddress, +// validatorDest.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // ACT +// _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if validator src is invalid arg", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{ +// stakerEthAddr, +// 42, +// validatorDest.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // ACT +// _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if validator dest is invalid arg", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// 42, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // ACT +// _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if amount is invalid arg", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// validatorDest.OperatorAddress, +// coins.AmountOf(config.BaseDenom).Uint64(), +// } + +// // ACT +// _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if wrong args amount", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, _ := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) + +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// _, err = contract.Stake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &stakeMethodID, argsStake) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{stakerEthAddr, validatorSrc.OperatorAddress, validatorDest.OperatorAddress} + +// // ACT +// _, err = contract.MoveStake(ctx, mockEVM, &vm.Contract{CallerAddress: stakerAddr}, &methodID, argsMoveStake) + +// // ASSERT +// require.Error(t, err) +// }) + +// t.Run("should fail if caller is not staker", func(t *testing.T) { +// // ARRANGE +// ctx, contract, abi, sdkKeepers, mockEVM, mockVMContract := setup(t) +// methodID := abi.Methods[MoveStakeMethodName] +// r := rand.New(rand.NewSource(42)) +// validatorSrc := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorSrc) +// validatorDest := sample.Validator(t, r) +// sdkKeepers.StakingKeeper.SetValidator(ctx, validatorDest) + +// staker := sample.Bech32AccAddress() +// stakerEthAddr := common.BytesToAddress(staker.Bytes()) +// coins := sample.Coins() +// err := sdkKeepers.BankKeeper.MintCoins(ctx, fungibletypes.ModuleName, sample.Coins()) +// require.NoError(t, err) +// err = sdkKeepers.BankKeeper.SendCoinsFromModuleToAccount(ctx, fungibletypes.ModuleName, staker, coins) +// require.NoError(t, err) + +// stakerAddr := common.BytesToAddress(staker.Bytes()) +// mockVMContract.CallerAddress = stakerAddr +// argsStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } + +// // stake to validator src +// stakeMethodID := abi.Methods[StakeMethodName] +// mockVMContract.Input = packInputArgs(t, stakeMethodID, argsStake...) +// _, err = contract.Run(mockEVM, mockVMContract, false) +// require.NoError(t, err) + +// argsMoveStake := []interface{}{ +// stakerEthAddr, +// validatorSrc.OperatorAddress, +// validatorDest.OperatorAddress, +// coins.AmountOf(config.BaseDenom).BigInt(), +// } +// mockVMContract.Input = packInputArgs(t, methodID, argsMoveStake...) + +// callerEthAddr := common.BytesToAddress(sample.Bech32AccAddress().Bytes()) +// mockVMContract.CallerAddress = callerEthAddr + +// // ACT +// _, err = contract.Run(mockEVM, mockVMContract, false) + +// // ASSERT +// require.ErrorContains(t, err, "caller is not staker") +// }) +// } func Test_GetAllValidators(t *testing.T) { t.Run("should return empty array if validators not set", func(t *testing.T) {