Skip to content

Commit 2149ac3

Browse files
rootulpclaude
andcommitted
fix(nodebuilder/tests): fix API and pruning integration test flakes
TestHeaderSubscription: explicitly connect bridge and light nodes via mocknet.ConnectPeers, wait for initial sync, and add a delay for gossipsub heartbeat exchange before subscribing. The bridge uses FanoutOnly mode which requires subscription metadata propagation. TestArchivalBlobSync: use assert.Eventually instead of assert.False for EDS pruning checks. Pruning FNs fetch blocks from core during catch-up and the pruner needs time to remove data outside the availability window. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 52ca35f commit 2149ac3

File tree

2 files changed

+19
-12
lines changed

2 files changed

+19
-12
lines changed

nodebuilder/tests/api_test.go

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -151,20 +151,23 @@ func TestHeaderSubscription(t *testing.T) {
151151
require.NoError(t, err)
152152
sw.SetBootstrapper(t, bridge)
153153

154-
bridgeClient := getAdminClient(ctx, bridge, t)
155-
156-
// Wait for the bridge to accumulate blocks so the light node's initial
157-
// header exchange sync generates subscription events without relying on
158-
// gossipsub (which is unreliable in mocknet with FanoutOnly bridge nodes).
159-
_, err = bridgeClient.Header.WaitForHeight(ctx, 10)
160-
require.NoError(t, err)
161-
162154
// start a light node that's connected to the bridge node
163155
light := sw.NewLightNode()
164156
err = light.Start(ctx)
165157
require.NoError(t, err)
166158

159+
// Explicitly connect bridge and light, then wait for gossipsub mesh
160+
// formation. Bridge nodes use FanoutOnly for header gossipsub, so we
161+
// need to ensure the connection is established and gossipsub has
162+
// exchanged subscription metadata before subscribing.
163+
sw.Connect(t, bridge, light)
164+
167165
lightClient := getAdminClient(ctx, light, t)
166+
// Wait for the light to sync a few headers (proves connectivity) and
167+
// give gossipsub heartbeats time to propagate subscription info.
168+
_, err = lightClient.Header.WaitForHeight(ctx, 3)
169+
require.NoError(t, err)
170+
time.Sleep(3 * time.Second)
168171

169172
// subscribe to headers via the light node's RPC header subscription
170173
subctx, subcancel := context.WithCancel(ctx)

nodebuilder/tests/prune_test.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,16 @@ func TestArchivalBlobSync(t *testing.T) {
152152
}
153153

154154
// ensure pruned FNs don't have the blocks associated
155-
// with the historical blobs
155+
// with the historical blobs. Use Eventually because the pruning FNs may
156+
// fetch blocks from core during catch-up; the pruner needs time to
157+
// remove data outside the availability window.
156158
for _, pruned := range pruningFulls {
157159
for _, b := range archivalBlobs {
158-
has, err := pruned.EDSStore.HasByHeight(ctx, b.height)
159-
require.NoError(t, err)
160-
assert.False(t, has)
160+
assert.Eventually(t, func() bool {
161+
has, err := pruned.EDSStore.HasByHeight(ctx, b.height)
162+
return err == nil && !has
163+
}, 30*time.Second, 500*time.Millisecond,
164+
"expected EDS at height %d to be pruned", b.height)
161165
}
162166
}
163167

0 commit comments

Comments
 (0)