From 0e3fda925f6c3936a3a9efcc310e2c10a918bd40 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Negovanovi=C4=87?= Date: Thu, 25 May 2023 20:59:37 +0200 Subject: [PATCH] Fix e2e tests --- e2e-polybft/e2e/bridge_test.go | 24 +++++++++++++++++------- e2e-polybft/e2e/consensus_test.go | 6 ++++-- 2 files changed, 21 insertions(+), 9 deletions(-) diff --git a/e2e-polybft/e2e/bridge_test.go b/e2e-polybft/e2e/bridge_test.go index f9c03b9039..f13a2ccfe7 100644 --- a/e2e-polybft/e2e/bridge_test.go +++ b/e2e-polybft/e2e/bridge_test.go @@ -154,7 +154,9 @@ func TestE2E_Bridge_Transfers(t *testing.T) { childJSONRPC := validatorSrv.JSONRPCAddr() for i := uint64(0); i < transfersCount; i++ { - exitEventID := i + 1 + // because first exit event is the one + // where native token is mapped on RootMintableERC20Predicate + exitEventID := i + 2 // send exit transaction to exit helper err = cluster.Bridge.SendExitTransaction(exitHelper, exitEventID, rootJSONRPC, childJSONRPC) @@ -421,15 +423,18 @@ func TestE2E_Bridge_DepositAndWithdrawERC721(t *testing.T) { rootJSONRPC := cluster.Bridge.JSONRPCAddr() childJSONRPC := validatorSrv.JSONRPCAddr() - for i := uint64(1); i <= txnCount; i++ { + for i := uint64(0); i < txnCount; i++ { + // because first exit event is the one + // where native token is mapped on RootMintableERC20Predicate + exitEventID := i + 2 // send exit transaction to exit helper - err = cluster.Bridge.SendExitTransaction(exitHelper, i, rootJSONRPC, childJSONRPC) + err = cluster.Bridge.SendExitTransaction(exitHelper, exitEventID, rootJSONRPC, childJSONRPC) require.NoError(t, err) // make sure exit event is processed successfully - isProcessed, err := isExitEventProcessed(i, ethgo.Address(exitHelper), rootchainTxRelayer) + isProcessed, err := isExitEventProcessed(exitEventID, ethgo.Address(exitHelper), rootchainTxRelayer) require.NoError(t, err) - require.True(t, isProcessed, fmt.Sprintf("exit event with ID %d was not processed", i)) + require.True(t, isProcessed, fmt.Sprintf("exit event with ID %d was not processed", exitEventID)) } // assert that owners of given token ids are the accounts on the root chain ERC 721 token @@ -602,7 +607,10 @@ func TestE2E_Bridge_DepositAndWithdrawERC1155(t *testing.T) { rootJSONRPC := cluster.Bridge.JSONRPCAddr() childJSONRPC := validatorSrv.JSONRPCAddr() - for exitEventID := uint64(1); exitEventID <= txnCount; exitEventID++ { + for i := uint64(0); i < txnCount; i++ { + // because first exit event is the one + // where native token is mapped on RootMintableERC20Predicate + exitEventID := i + 2 // send exit transaction to exit helper err = cluster.Bridge.SendExitTransaction(exitHelper, exitEventID, rootJSONRPC, childJSONRPC) require.NoError(t, err) @@ -967,7 +975,9 @@ func TestE2E_Bridge_Transfers_AccessLists(t *testing.T) { childJSONRPC := validatorSrv.JSONRPCAddr() for i := uint64(0); i < transfersCount; i++ { - exitEventID := i + 1 + // because first exit event is the one + // where native token is mapped on RootMintableERC20Predicate + exitEventID := i + 2 // send exit transaction to exit helper err = cluster.Bridge.SendExitTransaction(exitHelper, exitEventID, rootJSONRPC, childJSONRPC) diff --git a/e2e-polybft/e2e/consensus_test.go b/e2e-polybft/e2e/consensus_test.go index 85a6ef0533..493d6e0eb3 100644 --- a/e2e-polybft/e2e/consensus_test.go +++ b/e2e-polybft/e2e/consensus_test.go @@ -370,12 +370,14 @@ func TestE2E_Consensus_Validator_Unstake(t *testing.T) { require.NoError(t, waitForRootchainEpoch(currentEpoch, time.Minute, rootChainRelayer, polybftCfg.Bridge.CheckpointManagerAddr)) + exitEventID := uint64(2) + // send exit transaction to exit helper - err = cluster.Bridge.SendExitTransaction(polybftCfg.Bridge.ExitHelperAddr, 1, srv.BridgeJSONRPCAddr(), srv.JSONRPCAddr()) + err = cluster.Bridge.SendExitTransaction(polybftCfg.Bridge.ExitHelperAddr, exitEventID, srv.BridgeJSONRPCAddr(), srv.JSONRPCAddr()) require.NoError(t, err) // make sure exit event is processed successfully - isProcessed, err := isExitEventProcessed(1, ethgo.Address(polybftCfg.Bridge.ExitHelperAddr), rootChainRelayer) + isProcessed, err := isExitEventProcessed(exitEventID, ethgo.Address(polybftCfg.Bridge.ExitHelperAddr), rootChainRelayer) require.NoError(t, err) require.True(t, isProcessed, "exit event with was not processed")