From 03258aa8feb0c6378885c012f5a0cb2cb7e65e5f Mon Sep 17 00:00:00 2001 From: Lukasz Klimek <842586+lklimek@users.noreply.github.com> Date: Thu, 12 Nov 2026 19:30:01 +0000 Subject: [PATCH] test(blocksync): build handover tests against BlockResponse.Height MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit #1595 replaced the decoded block in the synchronizer's BlockResponse with its committed bytes and a Height field. The handover tests from #1618, merged after it, still set and read BlockResponse.Block, so the blocksync test package no longer compiled on dev. They only need the height, which addBlock reads from Height. 🤖 Co-authored by [Claudius the Magnificent](https://github.com/lklimek/claudius) AI Agent Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_01WunYYgi2uMsQDcBcKAwLdt --- internal/blocksync/ask_every_peer_test.go | 2 +- internal/blocksync/handover_deadline_test.go | 4 ++-- internal/blocksync/handover_late_supply_test.go | 2 +- internal/blocksync/synchronizer_test.go | 16 ++++++++-------- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/internal/blocksync/ask_every_peer_test.go b/internal/blocksync/ask_every_peer_test.go index 76f984169..ae7d66b09 100644 --- a/internal/blocksync/ask_every_peer_test.go +++ b/internal/blocksync/ask_every_peer_test.go @@ -77,7 +77,7 @@ func TestReserveNextBlockPeers(t *testing.T) { sync.AddPeer(newPeerData("late", 1, height)) require.NoError(t, sync.addBlock(BlockResponse{ PeerID: "first", - Block: &types.Block{Header: types.Header{Height: height}}, + Height: height, })) require.Empty(t, next()) require.Empty(t, next()) diff --git a/internal/blocksync/handover_deadline_test.go b/internal/blocksync/handover_deadline_test.go index 32f674a51..d616ff9df 100644 --- a/internal/blocksync/handover_deadline_test.go +++ b/internal/blocksync/handover_deadline_test.go @@ -99,7 +99,7 @@ func (r *tipRun) consume(now time.Time) bool { sync.peerStore.Update(req.peer.peerID, AddNumPending(-1), ResetFailures()) err := sync.addBlock(BlockResponse{ PeerID: req.peer.peerID, - Block: &types.Block{Header: types.Header{Height: req.height}}, + Height: req.height, }) if err != nil && !errors.Is(err, errDuplicateBlock) { r.h.suite.Require().NoError(err) @@ -109,7 +109,7 @@ func (r *tipRun) consume(now time.Time) bool { if !ok { break } - sync.advance(r.blockTimes[resp.Block.Height], defaultPrecision) + sync.advance(r.blockTimes[resp.Height], defaultPrecision) r.applied++ r.suppliedBy[resp.PeerID]++ } diff --git a/internal/blocksync/handover_late_supply_test.go b/internal/blocksync/handover_late_supply_test.go index 326d9368e..5ca29ec36 100644 --- a/internal/blocksync/handover_late_supply_test.go +++ b/internal/blocksync/handover_late_supply_test.go @@ -71,7 +71,7 @@ func (r *lateSupplyRun) apply(peer PeerData, request *serviceRequest, height int } r.h.suite.Require().NoError(sync.addBlock(BlockResponse{ PeerID: peer.peerID, - Block: &types.Block{Header: types.Header{Height: height}}, + Height: height, })) sync.advance(r.blockTimes[height], defaultPrecision) r.served++ diff --git a/internal/blocksync/synchronizer_test.go b/internal/blocksync/synchronizer_test.go index f9c308439..917acd000 100644 --- a/internal/blocksync/synchronizer_test.go +++ b/internal/blocksync/synchronizer_test.go @@ -1844,7 +1844,7 @@ func (h *waitForSyncHarness) tipBlocks(tipPeer types.NodeID, interval time.Durat h.sync.AddPeer(newPeerData(tipPeer, 1, height)) h.suite.Require().NoError(h.sync.addBlock(BlockResponse{ PeerID: tipPeer, - Block: &types.Block{Header: types.Header{Height: height}}, + Height: height, })) h.sync.advance(h.clock.Now(), defaultPrecision) } @@ -1968,13 +1968,13 @@ func (suite *SynchronizerTestSuite) TestWaitForSyncKeepsSyncingWhenASlowPeerReco const run = maxCatchupGap + 1 first := b.produce(ctx) suite.Require().NotNil(first) - suite.Require().EqualValues(1, first.Block.Height) + suite.Require().EqualValues(1, first.Height) b.timeout(ctx, slow, 1) responses := map[int64]*BlockResponse{} for len(responses) < int(run) { resp := b.produce(ctx) suite.Require().NotNil(resp) - responses[resp.Block.Height] = resp + responses[resp.Height] = resp } h := suite.startWaitForSync(b.pool, clock) @@ -2011,7 +2011,7 @@ func (suite *SynchronizerTestSuite) TestWaitForSyncKeepsSyncingBehindASoleSlowPe resp := b.produce(ctx) suite.Require().NotNil(resp) - suite.Require().EqualValues(1, resp.Block.Height) + suite.Require().EqualValues(1, resp.Height) b.timeout(ctx, slow, 1) h := suite.startWaitForSync(b.pool, fake) @@ -2052,7 +2052,7 @@ func (suite *SynchronizerTestSuite) TestWaitForSyncKeepsSyncingBehindASlowPeerWi resp := b.produce(ctx) suite.Require().NotNil(resp) - suite.Require().EqualValues(1, resp.Block.Height) + suite.Require().EqualValues(1, resp.Height) b.timeout(ctx, slow, 1) h := suite.startWaitForSync(b.pool, fake) @@ -2159,7 +2159,7 @@ func (h *waitForSyncHarness) flakySource(source types.NodeID, deliverEvery, fail if elapsed%deliverEvery == 0 { h.suite.Require().NoError(h.sync.addBlock(BlockResponse{ PeerID: source, - Block: &types.Block{Header: types.Header{Height: next}}, + Height: next, })) // a block the network committed long ago h.sync.advance(time.Time{}, defaultPrecision) @@ -2462,7 +2462,7 @@ func (suite *SynchronizerTestSuite) TestWaitForSyncHandsOverPastAFarClaimFromAPe h.sync.AddPeer(newPeerData(tipPeer, 1, next)) h.suite.Require().NoError(h.sync.addBlock(BlockResponse{ PeerID: relay, - Block: &types.Block{Header: types.Header{Height: next}}, + Height: next, })) h.sync.advance(h.clock.Now(), defaultPrecision) h.sync.peerStore.Update(relay, ResetFailures()) @@ -2520,7 +2520,7 @@ func (suite *SynchronizerTestSuite) TestWaitForSyncOnAFastChainBehindTheTip() { next, _ := h.sync.GetStatus() h.suite.Require().NoError(h.sync.addBlock(BlockResponse{ PeerID: source, - Block: &types.Block{Header: types.Header{Height: next}}, + Height: next, })) h.sync.advance(last.Add(time.Duration(next-height+1)*interval), defaultPrecision) h.sync.peerStore.Update(source, ResetFailures())