From 2ca9a58acd8b280483efa4b1e2bf52142a8ead21 Mon Sep 17 00:00:00 2001 From: Yacov Manevich Date: Wed, 18 Sep 2024 23:53:04 +0200 Subject: [PATCH] Fix node initialization in test The topological consensus tests were supposed to have the instances initialized with a random tree of blocks, where each block points to a random set of descendants. Instead, because of a bug that influenced the parent reference, the blocks were added to the consensus instance as a single block with the rest of the blocks as descendants. That's not what we want to test, so this commit fixes this and further simplifies the initialization logic. Signed-off-by: Yacov Manevich --- snow/consensus/snowman/network_test.go | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/snow/consensus/snowman/network_test.go b/snow/consensus/snowman/network_test.go index 27c9f411ae96..513b30bcd372 100644 --- a/snow/consensus/snowman/network_test.go +++ b/snow/consensus/snowman/network_test.go @@ -74,18 +74,13 @@ func (n *Network) AddNode(t testing.TB, sm Consensus) error { } n.shuffleColors() - deps := map[ids.ID]ids.ID{} for _, blk := range n.colors { - myDep, found := deps[blk.ParentV] - if !found { - myDep = blk.Parent() - } myBlock := &snowmantest.Block{ Decidable: snowtest.Decidable{ IDV: blk.ID(), Status: blk.Status, }, - ParentV: myDep, + ParentV: blk.ParentV, HeightV: blk.Height(), VerifyV: blk.Verify(context.Background()), BytesV: blk.Bytes(), @@ -93,7 +88,6 @@ func (n *Network) AddNode(t testing.TB, sm Consensus) error { if err := sm.Add(myBlock); err != nil { return err } - deps[myBlock.ID()] = myDep } n.nodes = append(n.nodes, sm) n.running = append(n.running, sm)