Skip to content

Commit 76e1357

Browse files
committed
refactor: improve DA inclusion wait logic in E2E test for full node
1 parent 0bdfcd2 commit 76e1357

File tree

1 file changed

+14
-18
lines changed

1 file changed

+14
-18
lines changed

test/e2e/evm_full_node_e2e_test.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -424,27 +424,23 @@ func TestEvmSequencerWithFullNodeE2E(t *testing.T) {
424424

425425
t.Logf("Full node block height before DA inclusion wait: %d", fnBlockHeightBeforeWait)
426426

427-
// Wait a few seconds to allow DA inclusion to process
428-
waitTime := 4 * time.Second
429-
t.Logf("Waiting %v for DA inclusion to process...", waitTime)
430-
time.Sleep(waitTime)
431-
432-
// Get the DA included height from full node after the wait
433-
fnDAIncludedHeightBytes, err := fullNodeRPCClient.GetMetadata(fnCtx, store.DAIncludedHeightKey)
434-
require.NoError(t, err, "Should get DA included height from full node")
435-
436-
// Decode the DA included height
437-
require.Equal(t, 8, len(fnDAIncludedHeightBytes), "DA included height should be 8 bytes")
438-
fnDAIncludedHeight := binary.LittleEndian.Uint64(fnDAIncludedHeightBytes)
427+
// Wait until DA inclusion metadata exists and has caught up.
428+
var fnDAIncludedHeight uint64
429+
require.Eventually(t, func() bool {
430+
fnDAIncludedHeightBytes, err := fullNodeRPCClient.GetMetadata(fnCtx, store.DAIncludedHeightKey)
431+
if err != nil {
432+
return false
433+
}
434+
if len(fnDAIncludedHeightBytes) != 8 {
435+
return false
436+
}
437+
fnDAIncludedHeight = binary.LittleEndian.Uint64(fnDAIncludedHeightBytes)
438+
return fnDAIncludedHeight >= fnBlockHeightBeforeWait
439+
}, DefaultTestTimeout, 500*time.Millisecond,
440+
"Full node DA included height should be >= block height before wait")
439441

440442
t.Logf("After waiting, full node DA included height: %d", fnDAIncludedHeight)
441443

442-
// Verify that the DA included height is >= the full node's block height before wait
443-
// This ensures that the blocks that existed before the wait have been DA included
444-
require.GreaterOrEqual(t, fnDAIncludedHeight, fnBlockHeightBeforeWait,
445-
"Full node DA included height (%d) should be >= block height before wait (%d)",
446-
fnDAIncludedHeight, fnBlockHeightBeforeWait)
447-
448444
t.Logf("✅ DA inclusion verification passed:")
449445
t.Logf(" - Full node block height before wait: %d", fnBlockHeightBeforeWait)
450446
t.Logf(" - Full node DA included height after wait: %d", fnDAIncludedHeight)

0 commit comments

Comments
 (0)