diff --git a/tests/crosschain_suite.go b/tests/crosschain_suite.go index 80d60e9c..b4ab2b9b 100644 --- a/tests/crosschain_suite.go +++ b/tests/crosschain_suite.go @@ -27,12 +27,13 @@ import ( type CrosschainTestSuite struct { EvmTestSuite - params crosschaintypes.Params - chainName string - oraclePrivKey cryptotypes.PrivKey - bridgerPrivKey cryptotypes.PrivKey - externalPrivKey *ecdsa.PrivateKey - privKey cryptotypes.PrivKey + params crosschaintypes.Params + chainName string + oraclePrivKey cryptotypes.PrivKey + bridgerPrivKey cryptotypes.PrivKey + externalPrivKey *ecdsa.PrivateKey + privKey cryptotypes.PrivKey + executeClaimPrivKey cryptotypes.PrivKey } func NewCrosschainWithTestSuite(chainName string, ts *TestSuite) CrosschainTestSuite { @@ -41,12 +42,13 @@ func NewCrosschainWithTestSuite(chainName string, ts *TestSuite) CrosschainTestS panic(err.Error()) } return CrosschainTestSuite{ - EvmTestSuite: NewEvmTestSuite(ts), - chainName: chainName, - oraclePrivKey: helpers.NewPriKey(), - bridgerPrivKey: helpers.NewPriKey(), - externalPrivKey: externalPrivKey, - privKey: helpers.NewEthPrivKey(), + EvmTestSuite: NewEvmTestSuite(ts), + chainName: chainName, + oraclePrivKey: helpers.NewPriKey(), + bridgerPrivKey: helpers.NewPriKey(), + externalPrivKey: externalPrivKey, + privKey: helpers.NewEthPrivKey(), + executeClaimPrivKey: helpers.NewEthPrivKey(), } } @@ -54,6 +56,7 @@ func (suite *CrosschainTestSuite) Init() { suite.TestSuite.Send(suite.OracleAddr(), suite.NewCoin(sdkmath.NewInt(10_100).MulRaw(1e18))) suite.TestSuite.Send(suite.BridgerAddr(), suite.NewCoin(sdkmath.NewInt(1_000).MulRaw(1e18))) suite.TestSuite.Send(suite.AccAddress(), suite.NewCoin(sdkmath.NewInt(1_000).MulRaw(1e18))) + suite.TestSuite.Send(suite.ExecuteClaimAccAddress(), suite.NewCoin(sdkmath.NewInt(1_000).MulRaw(1e18))) suite.params = suite.QueryParams() } @@ -74,6 +77,10 @@ func (suite *CrosschainTestSuite) AccAddress() sdk.AccAddress { return suite.privKey.PubKey().Address().Bytes() } +func (suite *CrosschainTestSuite) ExecuteClaimAccAddress() sdk.AccAddress { + return suite.executeClaimPrivKey.PubKey().Address().Bytes() +} + func (suite *CrosschainTestSuite) HexAddress() gethcommon.Address { return gethcommon.BytesToAddress(suite.privKey.PubKey().Address()) } @@ -260,6 +267,7 @@ func (suite *CrosschainTestSuite) SendOracleSetConfirm() { }, ) suite.NoError(err) + suite.NotEmpty(queryResponse.OracleSets) for _, oracleSet := range queryResponse.OracleSets { var signature []byte @@ -307,6 +315,7 @@ func (suite *CrosschainTestSuite) BridgeCallClaim(to string, tokens []string, am BridgerAddress: suite.BridgerAddr().String(), TxOrigin: suite.HexAddressString(), }) + suite.ExecuteClaim() } func (suite *CrosschainTestSuite) SendToTxClaimWithReceiver(receiver sdk.AccAddress, token string, amount sdkmath.Int, targetIbc string) { @@ -321,6 +330,7 @@ func (suite *CrosschainTestSuite) SendToTxClaimWithReceiver(receiver sdk.AccAddr BridgerAddress: suite.BridgerAddr().String(), ChainName: suite.chainName, }) + suite.ExecuteClaim() bridgeToken, err := suite.CrosschainQuery().TokenToDenom(suite.ctx, &crosschaintypes.QueryTokenToDenomRequest{ ChainName: suite.chainName, Token: token, @@ -642,6 +652,7 @@ func (suite *CrosschainTestSuite) BridgeCallConfirm(nonce uint64, isSuccess bool Cause: "", }, ) + suite.ExecuteClaim() } func (suite *CrosschainTestSuite) SignatureCheckpoint(checkpoint []byte) []byte { @@ -697,7 +708,7 @@ func (suite *CrosschainTestSuite) ExecuteClaim() *ethtypes.Transaction { suite.Require().NoError(err) address := crosschaintypes.GetAddress() - ethTx, err := client.BuildEthTransaction(suite.ctx, suite.EthClient(), suite.privKey, &address, nil, pack) + ethTx, err := client.BuildEthTransaction(suite.ctx, suite.EthClient(), suite.executeClaimPrivKey, &address, nil, pack) suite.Require().NoError(err) suite.SendTransaction(ethTx) diff --git a/tests/crosschain_test.go b/tests/crosschain_test.go index 22ff632b..12b1e155 100644 --- a/tests/crosschain_test.go +++ b/tests/crosschain_test.go @@ -60,7 +60,6 @@ func (suite *IntegrationTest) CrossChainTest() { chain.CheckBalance(ibcTransferAddr, sdk.NewCoin(bridgeDenom, sdkmath.NewInt(0))) } chain.SendToFxClaim(tokenAddress, sdkmath.NewInt(100), "") - chain.ExecuteClaim() chain.CheckBalance(chain.AccAddress(), sdk.NewCoin(bridgeDenom, sdkmath.NewInt(100))) txId := chain.SendToExternal(5, sdk.NewCoin(bridgeDenom, sdkmath.NewInt(10))) diff --git a/x/crosschain/precompile/execute_claim.go b/x/crosschain/precompile/execute_claim.go index 097bca71..d7ef9060 100644 --- a/x/crosschain/precompile/execute_claim.go +++ b/x/crosschain/precompile/execute_claim.go @@ -2,6 +2,7 @@ package precompile import ( "errors" + "math/big" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/ethereum/go-ethereum/accounts/abi" @@ -60,7 +61,7 @@ func (m *ExecuteClaimMethod) Run(evm *vm.EVM, contract *vm.Contract) ([]byte, er if err = crosschainKeeper.ExecuteClaim(ctx, args.EventNonce.Uint64()); err != nil { return err } - data, topic, err := m.NewExecuteClaimEvent(contract.Caller(), args.EventNonce.Uint64(), args.DstChain) + data, topic, err := m.NewExecuteClaimEvent(contract.Caller(), args.EventNonce, args.DstChain) if err != nil { return err } @@ -75,7 +76,7 @@ func (m *ExecuteClaimMethod) Run(evm *vm.EVM, contract *vm.Contract) ([]byte, er return m.PackOutput(true) } -func (m *ExecuteClaimMethod) NewExecuteClaimEvent(sender common.Address, eventNonce uint64, dstChain string) (data []byte, topic []common.Hash, err error) { +func (m *ExecuteClaimMethod) NewExecuteClaimEvent(sender common.Address, eventNonce *big.Int, dstChain string) (data []byte, topic []common.Hash, err error) { data, topic, err = evmtypes.PackTopicData(m.Event, []common.Hash{sender.Hash()}, eventNonce, dstChain) if err != nil { return nil, nil, err diff --git a/x/crosschain/types/contract.go b/x/crosschain/types/contract.go index e9f4305b..973f18c3 100644 --- a/x/crosschain/types/contract.go +++ b/x/crosschain/types/contract.go @@ -185,7 +185,7 @@ func (args *AddPendingPoolRewardArgs) Validate() error { } type ExecuteClaimArgs struct { - DstChain string `abi:"_dstChain"` + DstChain string `abi:"_dstChainId"` EventNonce *big.Int `abi:"_eventNonce"` }