Skip to content

Commit

Permalink
Fix e2e tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Stefan-Ethernal committed May 28, 2023
1 parent 6363587 commit 0e3fda9
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
24 changes: 17 additions & 7 deletions e2e-polybft/e2e/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
6 changes: 4 additions & 2 deletions e2e-polybft/e2e/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 0e3fda9

Please sign in to comment.