Skip to content

Commit 76fc984

Browse files
rootulpclaude
andcommitted
fix(nodebuilder/tests): fix TestShrexFromLights and TestArchivalBlobSync flakes
TestShrexFromLights: restructure to start light node after blocks are filled so initial header exchange sync fetches all needed headers without relying on gossipsub (same pattern that fixed TestShrexFromLightsWithBadFulls). TestArchivalBlobSync: close the stopped archivalBN's host so that future createPeer/LinkAll calls don't re-link new nodes to it. Without this, new nodes may inadvertently reach archivalBN via shrex and get "protocols not supported" errors since its handlers are gone after Stop(). Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent c9e3e3d commit 76fc984

File tree

2 files changed

+26
-10
lines changed

2 files changed

+26
-10
lines changed

nodebuilder/tests/prune_test.go

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,15 @@ func TestArchivalBlobSync(t *testing.T) {
102102
require.NoError(t, err)
103103
err = archivalBN.Stop(ctx)
104104
require.NoError(t, err)
105+
// Close the stopped archivalBN's host so that future createPeer/LinkAll
106+
// calls don't re-link new nodes to it. Without this, new nodes may try
107+
// to reach archivalBN via shrex and get "protocols not supported" errors
108+
// since its handlers are gone.
109+
err = archivalBN.Host.Close()
110+
require.NoError(t, err)
105111

106112
// Reset bootstrappers to exclude the stopped archivalBN. Keep only archivalFN
107-
// so new nodes don't attempt connections to the stopped node (which causes
108-
// "protocol not supported" errors).
113+
// so new nodes don't attempt connections to the stopped node.
109114
sw.Bootstrappers = sw.Bootstrappers[:0]
110115
sw.SetBootstrapper(t, archivalFN)
111116

nodebuilder/tests/shrex_test.go

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -41,22 +41,33 @@ func TestShrexFromLights(t *testing.T) {
4141
bridge := sw.NewBridgeNode()
4242
sw.SetBootstrapper(t, bridge)
4343

44-
cfg := sw.DefaultTestConfig(node.Light)
45-
cfg.Share.Discovery.PeersLimit = 1
46-
light := sw.NewNodeWithConfig(node.Light, cfg)
47-
4844
err := bridge.Start(ctx)
4945
require.NoError(t, err)
50-
err = light.Start(ctx)
51-
require.NoError(t, err)
5246

5347
bridgeClient := getAdminClient(ctx, bridge, t)
54-
lightClient := getAdminClient(ctx, light, t)
5548

5649
// wait for chain to be filled
5750
require.NoError(t, <-fillDn)
5851

59-
for i := range heightsCh {
52+
// Collect all filled block heights and wait for bridge to sync them
53+
heights := make([]uint64, 0, blocks)
54+
for h := range heightsCh {
55+
heights = append(heights, h)
56+
}
57+
_, err = bridgeClient.Header.WaitForHeight(ctx, heights[len(heights)-1])
58+
require.NoError(t, err)
59+
60+
// Start the light node after blocks are filled so its initial header
61+
// exchange sync fetches all needed headers without relying on gossipsub.
62+
cfg := sw.DefaultTestConfig(node.Light)
63+
cfg.Share.Discovery.PeersLimit = 1
64+
light := sw.NewNodeWithConfig(node.Light, cfg)
65+
err = light.Start(ctx)
66+
require.NoError(t, err)
67+
68+
lightClient := getAdminClient(ctx, light, t)
69+
70+
for _, i := range heights {
6071
h, err := bridgeClient.Header.GetByHeight(ctx, i)
6172
require.NoError(t, err)
6273

0 commit comments

Comments
 (0)