Skip to content

Commit

Permalink
Use wait for ready on e2e test (#1324)
Browse files Browse the repository at this point in the history
* Use wait for ready on e2e test

* Pass E2E test

---------

Co-authored-by: Stefan Negovanović <stefan@ethernal.tech>
  • Loading branch information
ferranbt and Stefan-Ethernal committed Mar 23, 2023
1 parent 15deea1 commit a6fffdc
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 16 deletions.
12 changes: 4 additions & 8 deletions e2e-polybft/e2e/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,7 @@ func TestE2E_Bridge_DepositAndWithdrawERC20(t *testing.T) {
framework.WithEpochSize(epochSize))
defer cluster.Stop()

// wait for a couple of blocks
require.NoError(t, cluster.WaitForBlock(1, 10*time.Second))
cluster.WaitForReady(t)

manifest, err := polybft.LoadManifest(path.Join(cluster.Config.TmpDir, manifestFileName))
require.NoError(t, err)
Expand Down Expand Up @@ -235,8 +234,7 @@ func TestE2E_Bridge_MultipleCommitmentsPerEpoch(t *testing.T) {
manifest, err := polybft.LoadManifest(path.Join(cluster.Config.TmpDir, manifestFileName))
require.NoError(t, err)

// wait for a couple of blocks
require.NoError(t, cluster.WaitForBlock(2, 1*time.Minute))
cluster.WaitForReady(t)

// send two transactions to the bridge so that we have a minimal commitment
require.NoError(
Expand Down Expand Up @@ -412,8 +410,7 @@ func TestE2E_Bridge_L2toL1Exit(t *testing.T) {
checkpointManagerAddr := ethgo.Address(manifest.RootchainConfig.CheckpointManagerAddress)
exitHelperAddr := ethgo.Address(manifest.RootchainConfig.ExitHelperAddress)

// wait for a couple of blocks
require.NoError(t, cluster.WaitForBlock(2, 2*time.Minute))
cluster.WaitForReady(t)

// init rpc clients
l1TxRelayer, err := txrelayer.NewTxRelayer(txrelayer.WithIPAddress(txrelayer.DefaultRPCAddress))
Expand Down Expand Up @@ -511,8 +508,7 @@ func TestE2E_Bridge_L2toL1ExitMultiple(t *testing.T) {
checkpointManagerAddr := ethgo.Address(manifest.RootchainConfig.CheckpointManagerAddress)
exitHelperAddr := ethgo.Address(manifest.RootchainConfig.ExitHelperAddress)

// wait for a couple of blocks
require.NoError(t, cluster.WaitForBlock(2, 2*time.Minute))
cluster.WaitForReady(t)

// init rpc clients
l1TxRelayer, err := txrelayer.NewTxRelayer(txrelayer.WithIPAddress(txrelayer.DefaultRPCAddress))
Expand Down
6 changes: 2 additions & 4 deletions e2e-polybft/e2e/consensus_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,8 +347,7 @@ func TestE2E_Consensus_Delegation_Undelegation(t *testing.T) {
txRelayer, err := txrelayer.NewTxRelayer(txrelayer.WithIPAddress(srv.JSONRPCAddr()))
require.NoError(t, err)

// wait for consensus to start
require.NoError(t, cluster.WaitForBlock(1, 10*time.Second))
cluster.WaitForReady(t)

// extract delegator's secrets
delegatorSecretsPath := path.Join(cluster.Config.TmpDir, delegatorSecrets)
Expand Down Expand Up @@ -556,8 +555,7 @@ func TestE2E_Consensus_CorrectnessOfExtraValidatorsShouldNotDependOnDelegate(t *
_, err = cluster.InitSecrets(delegatorSecrets, 1)
require.NoError(t, err)

// wait for consensus to start
require.NoError(t, cluster.WaitForBlock(2, 20*time.Second))
cluster.WaitForReady(t)

// extract delegator's secrets
delegatorSecretsPath := path.Join(cluster.Config.TmpDir, delegatorSecrets)
Expand Down
2 changes: 1 addition & 1 deletion e2e-polybft/e2e/migration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ func TestMigration(t *testing.T) {
)
defer cluster.Stop()

require.NoError(t, cluster.WaitForBlock(5, 1*time.Minute))
cluster.WaitForReady(t)

senderBalanceAfterMigration, err := cluster.Servers[0].JSONRPC().Eth().GetBalance(userAddr, ethgo.Latest)
if err != nil {
Expand Down
4 changes: 2 additions & 2 deletions e2e-polybft/e2e/txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ func TestE2E_TxPool_Transfer(t *testing.T) {
cluster := framework.NewTestCluster(t, 5, framework.WithPremine(types.Address(sender.Address())))
defer cluster.Stop()

require.NoError(t, cluster.WaitForBlock(2, 1*time.Minute))
cluster.WaitForReady(t)

client := cluster.Servers[0].JSONRPC().Eth()

Expand Down Expand Up @@ -91,7 +91,7 @@ func TestE2E_TxPool_Transfer_Linear(t *testing.T) {
cluster := framework.NewTestCluster(t, 5, framework.WithPremine(types.Address(premine.Address())))
defer cluster.Stop()

require.NoError(t, cluster.WaitForBlock(2, 1*time.Minute))
cluster.WaitForReady(t)

client := cluster.Servers[0].JSONRPC().Eth()

Expand Down
2 changes: 1 addition & 1 deletion e2e-polybft/framework/test-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,7 +524,7 @@ func (c *TestCluster) WaitUntil(timeout, pollFrequency time.Duration, handler fu
func (c *TestCluster) WaitForReady(t *testing.T) {
t.Helper()

require.NoError(t, c.WaitForBlock(3, 1*time.Minute))
require.NoError(t, c.WaitForBlock(1, 30*time.Second))
}

func (c *TestCluster) WaitForBlock(n uint64, timeout time.Duration) error {
Expand Down

0 comments on commit a6fffdc

Please sign in to comment.