From 60d21ba97ad8f1a8491d8b2ac822d996e88db2e3 Mon Sep 17 00:00:00 2001 From: Oliver Bundalo Date: Tue, 14 May 2024 14:34:53 +0200 Subject: [PATCH 1/2] e2e fixes --- e2e-polybft/e2e/bridge_test.go | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/e2e-polybft/e2e/bridge_test.go b/e2e-polybft/e2e/bridge_test.go index fe46ddaff0..c53818bf32 100644 --- a/e2e-polybft/e2e/bridge_test.go +++ b/e2e-polybft/e2e/bridge_test.go @@ -837,10 +837,11 @@ func TestE2E_Bridge_ChildchainTokensTransfer(t *testing.T) { // check that balances on the child chain are correct for i, receiver := range depositors { + temp := big.NewInt(0) balance := erc20BalanceOf(t, receiver, contracts.NativeERC20TokenContract, childchainTxRelayer) t.Log("Attempt", it+1, "Balance before", balancesBefore[i], "Balance after", balance) - if balance.Cmp(balancesBefore[i].Add(balancesBefore[i], big.NewInt(amount))) != 0 { + if balance.Cmp(temp.Add(balancesBefore[i], big.NewInt(amount))) != 0 { allSuccessful = false break @@ -1252,9 +1253,8 @@ func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) { var ( epochSize = 10 stateSyncedLogsCount = 2 + numberOfAttempts = 4 numBlockConfirmations = uint64(2) - sprintSize = uint64(5) - numberOfAttempts = uint64(4) exitEventsCount = uint64(2) tokensToTransfer = ethgo.Gwei(10) bigZero = big.NewInt(0) @@ -1444,14 +1444,15 @@ func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) { currentBlock, err := childEthEndpoint.GetBlockByNumber(jsonrpc.LatestBlockNumber, false) require.NoError(t, err) - // wait for a couple of sprints - finalBlockNum := currentBlock.Header.Number + 5*sprintSize + // wait for couple of epoches + finalBlockNum := currentBlock.Header.Number + uint64(2*epochSize) + require.NoError(t, cluster.WaitForBlock(finalBlockNum, 2*time.Minute)) // the transaction is processed and there should be a success event var stateSyncedResult contractsapi.StateSyncResultEvent - for i := uint64(0); i < numberOfAttempts; i++ { - logs, err := getFilteredLogs(stateSyncedResult.Sig(), 0, finalBlockNum+i*sprintSize, childEthEndpoint) + for i := 0; i < numberOfAttempts; i++ { + logs, err := getFilteredLogs(stateSyncedResult.Sig(), 0, finalBlockNum+uint64(i*epochSize), childEthEndpoint) require.NoError(t, err) if len(logs) == stateSyncedLogsCount || i == numberOfAttempts-1 { @@ -1461,7 +1462,7 @@ func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) { break } - require.NoError(t, cluster.WaitForBlock(finalBlockNum+(i+1)*sprintSize, 2*time.Minute)) + require.NoError(t, cluster.WaitForBlock(finalBlockNum+uint64((i+1)*epochSize), time.Minute)) } }) } From 67293d49c7c12a1d891798f42574620faf6e1260 Mon Sep 17 00:00:00 2001 From: Oliver Bundalo Date: Tue, 14 May 2024 16:03:54 +0200 Subject: [PATCH 2/2] PR fixes --- e2e-polybft/e2e/bridge_test.go | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/e2e-polybft/e2e/bridge_test.go b/e2e-polybft/e2e/bridge_test.go index c53818bf32..2bac118325 100644 --- a/e2e-polybft/e2e/bridge_test.go +++ b/e2e-polybft/e2e/bridge_test.go @@ -837,11 +837,10 @@ func TestE2E_Bridge_ChildchainTokensTransfer(t *testing.T) { // check that balances on the child chain are correct for i, receiver := range depositors { - temp := big.NewInt(0) balance := erc20BalanceOf(t, receiver, contracts.NativeERC20TokenContract, childchainTxRelayer) t.Log("Attempt", it+1, "Balance before", balancesBefore[i], "Balance after", balance) - if balance.Cmp(temp.Add(balancesBefore[i], big.NewInt(amount))) != 0 { + if balance.Cmp(new(big.Int).Add(balancesBefore[i], big.NewInt(amount))) != 0 { allSuccessful = false break @@ -1251,9 +1250,9 @@ func TestE2E_Bridge_Transfers_AccessLists(t *testing.T) { func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) { var ( - epochSize = 10 stateSyncedLogsCount = 2 - numberOfAttempts = 4 + epochSize = uint64(10) + numberOfAttempts = uint64(4) numBlockConfirmations = uint64(2) exitEventsCount = uint64(2) tokensToTransfer = ethgo.Gwei(10) @@ -1276,7 +1275,7 @@ func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) { // with london fork enabled cluster := framework.NewTestCluster(t, 5, framework.WithBridge(), - framework.WithEpochSize(epochSize), + framework.WithEpochSize(int(epochSize)), framework.WithNumBlockConfirmations(numBlockConfirmations), framework.WithNativeTokenConfig(nativeTokenNonMintableConfig), // this enables London (EIP-1559) fork @@ -1445,14 +1444,14 @@ func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) { require.NoError(t, err) // wait for couple of epoches - finalBlockNum := currentBlock.Header.Number + uint64(2*epochSize) + finalBlockNum := currentBlock.Header.Number + 2*epochSize require.NoError(t, cluster.WaitForBlock(finalBlockNum, 2*time.Minute)) // the transaction is processed and there should be a success event var stateSyncedResult contractsapi.StateSyncResultEvent - for i := 0; i < numberOfAttempts; i++ { - logs, err := getFilteredLogs(stateSyncedResult.Sig(), 0, finalBlockNum+uint64(i*epochSize), childEthEndpoint) + for i := uint64(0); i < numberOfAttempts; i++ { + logs, err := getFilteredLogs(stateSyncedResult.Sig(), 0, finalBlockNum+i*epochSize, childEthEndpoint) require.NoError(t, err) if len(logs) == stateSyncedLogsCount || i == numberOfAttempts-1 { @@ -1462,7 +1461,7 @@ func TestE2E_Bridge_NonMintableERC20Token_WithPremine(t *testing.T) { break } - require.NoError(t, cluster.WaitForBlock(finalBlockNum+uint64((i+1)*epochSize), time.Minute)) + require.NoError(t, cluster.WaitForBlock(finalBlockNum+(i+1)*epochSize, time.Minute)) } }) }