Skip to content

Commit

Permalink
Fix test to not expect empty notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
svarogg committed May 1, 2022
1 parent c5ca308 commit 696e651
Showing 1 changed file with 3 additions and 29 deletions.
32 changes: 3 additions & 29 deletions testing/integration/selected_parent_chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,36 +65,10 @@ func TestVirtualSelectedParentChain(t *testing.T) {
chain2TipHashString := chain2TipHash.String()

// For the first `blockAmountToMine - 1` blocks we don't expect
// the chain to change at all
for i := 0; i < blockAmountToMine-1; i++ {
notification := <-onVirtualSelectedParentChainChangedChan
if len(notification.RemovedChainBlockHashes) > 0 {
t.Fatalf("RemovedChainBlockHashes is unexpectedly not empty")
}
if len(notification.AddedChainBlockHashes) > 0 {
t.Fatalf("AddedChainBlockHashes is unexpectedly not empty")
}
}

// Either the next block could cause a reorg or the one
// after it
potentialReorgNotification1 := <-onVirtualSelectedParentChainChangedChan
potentialReorgNotification2 := <-onVirtualSelectedParentChainChangedChan
var reorgNotification *appmessage.VirtualSelectedParentChainChangedNotificationMessage
var nonReorgNotification *appmessage.VirtualSelectedParentChainChangedNotificationMessage
if len(potentialReorgNotification1.RemovedChainBlockHashes) > 0 {
reorgNotification = potentialReorgNotification1
nonReorgNotification = potentialReorgNotification2
} else {
reorgNotification = potentialReorgNotification2
nonReorgNotification = potentialReorgNotification1
}
// the chain to change at all, thus there will be no notifications

// Make sure that the non-reorg notification has nothing
// in `removed`
if len(nonReorgNotification.RemovedChainBlockHashes) > 0 {
t.Fatalf("nonReorgNotification.RemovedChainBlockHashes is unexpectedly not empty")
}
// Either the next block or the one after it will cause a reorg
reorgNotification := <-onVirtualSelectedParentChainChangedChan

// Make sure that the reorg notification contains exactly
// `blockAmountToMine` blocks in its `removed`
Expand Down

0 comments on commit 696e651

Please sign in to comment.