From 53e87b9b3a7e9ed78bf9c15d21ac678cc2aaad2b Mon Sep 17 00:00:00 2001 From: kevinssgh Date: Thu, 29 Feb 2024 13:45:23 -0500 Subject: [PATCH] fix tryprocessout test case --- zetaclient/evm/evm_signer.go | 4 + zetaclient/evm/evm_signer_test.go | 25 ++++-- zetaclient/testdata/cctx/cctx_56_68270.json | 85 ++++++++++----------- 3 files changed, 62 insertions(+), 52 deletions(-) diff --git a/zetaclient/evm/evm_signer.go b/zetaclient/evm/evm_signer.go index f30d397b4b..da66af9174 100644 --- a/zetaclient/evm/evm_signer.go +++ b/zetaclient/evm/evm_signer.go @@ -766,6 +766,10 @@ func (signer *Signer) SignWhitelistTx( return tx, nil } +func (signer *Signer) GetReportedTxList() *map[string]bool { + return &signer.outTxHashBeingReported +} + func getEVMRPC(endpoint string) (interfaces.EVMRPCClient, *big.Int, ethtypes.Signer, error) { if endpoint == mock.EVMRPCEnabled { chainID := big.NewInt(common.BscMainnetChain().ChainId) diff --git a/zetaclient/evm/evm_signer_test.go b/zetaclient/evm/evm_signer_test.go index 83ec275928..3cd6e57f39 100644 --- a/zetaclient/evm/evm_signer_test.go +++ b/zetaclient/evm/evm_signer_test.go @@ -41,6 +41,14 @@ func getNewEvmSigner() (*Signer, error) { ts) } +func getNewEvmChainClient() (*ChainClient, error) { + logger := common.ClientLogger{} + ts := &metrics.TelemetryServer{} + cfg := config.NewConfig() + evmcfg := config.EVMConfig{Endpoint: "http://localhost:8545"} + return NewEVMChainClient(mock.NewZetaCoreBridge(), mock.NewTSSMainnet(), "", logger, cfg, evmcfg, ts) +} + func getNewOutTxProcessor() *outtxprocessor.Processor { logger := zerolog.Logger{} return outtxprocessor.NewOutTxProcessorManager(logger) @@ -55,18 +63,21 @@ func getCCTX() (*types.CrossChainTx, error) { func TestSigner_TryProcessOutTx(t *testing.T) { evmSigner, err := getNewEvmSigner() require.NoError(t, err) - cctx, err := getCCTX() require.NoError(t, err) - processorManager := getNewOutTxProcessor() + mockChainClient, err := getNewEvmChainClient() + require.NoError(t, err) - mockChainClient := &ChainClient{ - chain: corecommon.BscMainnetChain(), - zetaClient: mock.NewZetaCoreBridge(), - Tss: mock.NewTSSMainnet(), - } evmSigner.TryProcessOutTx(cctx, processorManager, "123", mockChainClient, mock.NewZetaCoreBridge(), 123) + + //Check if cctx was processed + list := evmSigner.GetReportedTxList() + found := false + for range *list { + found = true + } + require.True(t, found) } func TestSigner_SignOutboundTx(t *testing.T) { diff --git a/zetaclient/testdata/cctx/cctx_56_68270.json b/zetaclient/testdata/cctx/cctx_56_68270.json index 1fe6789231..1c0ae6b762 100644 --- a/zetaclient/testdata/cctx/cctx_56_68270.json +++ b/zetaclient/testdata/cctx/cctx_56_68270.json @@ -1,48 +1,43 @@ { - "CrossChainTx": [ + "creator": "", + "index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", + "zeta_fees": "0", + "relayed_message": "", + "cctx_status": { + "status": 1, + "status_message": "", + "lastUpdate_timestamp": 1709145057 + }, + "inbound_tx_params": { + "sender": "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", + "sender_chain_id": 7000, + "tx_origin": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", + "coin_type": 1, + "asset": "", + "amount": "657177295293237048", + "inbound_tx_observed_hash": "0x093f4ca4c1884df0fd9dd59b75979342ded29d3c9b6861644287a2e1417b9a39", + "inbound_tx_observed_external_height": 1960153, + "inbound_tx_ballot_index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", + "inbound_tx_finalized_zeta_height": 0, + "tx_finalization_status": 0 + }, + "outbound_tx_params": [ { - "creator": "", - "index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", - "zeta_fees": "0", - "relayed_message": "", - "cctx_status": { - "status": "PendingOutbound", - "status_message": "", - "lastUpdate_timestamp": "1709145057" - }, - "inbound_tx_params": { - "sender": "0xd91b507F2A3e2D4A32d0C86Ac19FEAD2D461008D", - "sender_chain_id": "7000", - "tx_origin": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", - "coin_type": "Gas", - "asset": "", - "amount": "657177295293237048", - "inbound_tx_observed_hash": "0x093f4ca4c1884df0fd9dd59b75979342ded29d3c9b6861644287a2e1417b9a39", - "inbound_tx_observed_external_height": "1960153", - "inbound_tx_ballot_index": "0x541b570182950809f9b9077861a0fc7038af9a14ce8af4e151a83adfa308c7a9", - "inbound_tx_finalized_zeta_height": "0", - "tx_finalization_status": "NotFinalized" - }, - "outbound_tx_params": [ - { - "receiver": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", - "receiver_chainId": "56", - "coin_type": "Gas", - "amount": "657177295293237048", - "outbound_tx_tss_nonce": "68270", - "outbound_tx_gas_limit": "21000", - "outbound_tx_gas_price": "6000000000", - "outbound_tx_hash": "", - "outbound_tx_ballot_index": "", - "outbound_tx_observed_external_height": "0", - "outbound_tx_gas_used": "0", - "outbound_tx_effective_gas_price": "0", - "outbound_tx_effective_gas_limit": "0", - "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", - "tx_finalization_status": "NotFinalized" - } - ] + "receiver": "0xb0C04e07A301927672A8A7a874DB6930576C90B8", + "receiver_chainId": 56, + "coin_type": 1, + "amount": "657177295293237048", + "outbound_tx_tss_nonce": 68270, + "outbound_tx_gas_limit": 21000, + "outbound_tx_gas_price": "6000000000", + "outbound_tx_hash": "", + "outbound_tx_ballot_index": "", + "outbound_tx_observed_external_height": 0, + "outbound_tx_gas_used": 0, + "outbound_tx_effective_gas_price": "0", + "outbound_tx_effective_gas_limit": 0, + "tss_pubkey": "zetapub1addwnpepqtadxdyt037h86z60nl98t6zk56mw5zpnm79tsmvspln3hgt5phdc79kvfc", + "tx_finalization_status": 0 } - ], - "totalPending": "1" -} \ No newline at end of file + ] +}