Skip to content

Commit

Permalink
Fix node initialization in test
Browse files Browse the repository at this point in the history
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 <yacov.manevich@avalabs.org>
  • Loading branch information
yacovm committed Sep 18, 2024
1 parent 42d0cff commit 2ca9a58
Showing 1 changed file with 1 addition and 7 deletions.
8 changes: 1 addition & 7 deletions snow/consensus/snowman/network_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,26 +74,20 @@ 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(),
}
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)
Expand Down

0 comments on commit 2ca9a58

Please # to comment.