Skip to content

Commit

Permalink
fix tryprocessout test case
Browse files Browse the repository at this point in the history
  • Loading branch information
kevinssgh committed Feb 29, 2024
1 parent 32e218d commit 53e87b9
Show file tree
Hide file tree
Showing 3 changed files with 62 additions and 52 deletions.
4 changes: 4 additions & 0 deletions zetaclient/evm/evm_signer.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
25 changes: 18 additions & 7 deletions zetaclient/evm/evm_signer_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Check failure on line 49 in zetaclient/evm/evm_signer_test.go

View workflow job for this annotation

GitHub Actions / build-and-test

cannot use mock.NewZetaCoreBridge() (value of type *"github.com/zeta-chain/zetacore/zetaclient/testutils/mock".ZetaCoreBridge) as *appcontext.AppContext value in argument to NewEVMChainClient

Check failure on line 49 in zetaclient/evm/evm_signer_test.go

View workflow job for this annotation

GitHub Actions / build-and-test

cannot use mock.NewTSSMainnet() (value of type *"github.com/zeta-chain/zetacore/zetaclient/testutils/mock".TSS) as "github.com/zeta-chain/zetacore/zetaclient/interfaces".ZetaCoreBridger value in argument to NewEVMChainClient: *"github.com/zeta-chain/zetacore/zetaclient/testutils/mock".TSS does not implement "github.com/zeta-chain/zetacore/zetaclient/interfaces".ZetaCoreBridger (missing method AddTxHashToOutTxTracker)

Check failure on line 49 in zetaclient/evm/evm_signer_test.go

View workflow job for this annotation

GitHub Actions / build-and-test

cannot use "" (constant of type string) as "github.com/zeta-chain/zetacore/zetaclient/interfaces".TSSSigner value in argument to NewEVMChainClient: string does not implement "github.com/zeta-chain/zetacore/zetaclient/interfaces".TSSSigner (missing method BTCAddress)

Check failure on line 49 in zetaclient/evm/evm_signer_test.go

View workflow job for this annotation

GitHub Actions / build-and-test

cannot use logger (variable of type "github.com/zeta-chain/zetacore/zetaclient/common".ClientLogger) as string value in argument to NewEVMChainClient

Check failure on line 49 in zetaclient/evm/evm_signer_test.go

View workflow job for this annotation

GitHub Actions / build-and-test

cannot use cfg (variable of type *"github.com/zeta-chain/zetacore/zetaclient/config".Config) as "github.com/zeta-chain/zetacore/zetaclient/common".ClientLogger value in argument to NewEVMChainClient
}

func getNewOutTxProcessor() *outtxprocessor.Processor {
logger := zerolog.Logger{}
return outtxprocessor.NewOutTxProcessorManager(logger)
Expand All @@ -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) {
Expand Down
85 changes: 40 additions & 45 deletions zetaclient/testdata/cctx/cctx_56_68270.json
Original file line number Diff line number Diff line change
@@ -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"
}
]
}

0 comments on commit 53e87b9

Please sign in to comment.