From 3ece0d12c50ab2912db97f4034b5e859a6e7fc01 Mon Sep 17 00:00:00 2001 From: jonastheis <4181434+jonastheis@users.noreply.github.com> Date: Thu, 28 Mar 2024 18:28:09 +0800 Subject: [PATCH] Fix race condition in test suite where we don't actually wait for slots to be committed. Through the faster weight propagation this seemed to occur consistently now, whereas before it was hidden by too slow execution --- pkg/testsuite/testsuite_issue_blocks.go | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/pkg/testsuite/testsuite_issue_blocks.go b/pkg/testsuite/testsuite_issue_blocks.go index e86ee04c8..b66eb687a 100644 --- a/pkg/testsuite/testsuite_issue_blocks.go +++ b/pkg/testsuite/testsuite_issue_blocks.go @@ -221,21 +221,23 @@ func (t *TestSuite) IssueBlocksAtSlots(prefix string, slots []iotago.SlotIndex, lastBlockRowIssued = lastRowInSlot if waitForSlotsCommitted { - if slot > t.API.ProtocolParameters().MinCommittableAge() { - if useCommitmentAtMinCommittableAge { - // Make sure that all nodes create blocks throughout the slot that commit to the same commitment at slot-minCommittableAge-1. - commitmentSlot := slot - t.API.ProtocolParameters().MinCommittableAge() - t.AssertCommitmentSlotIndexExists(commitmentSlot, t.ClientsForNodes(nodes...)...) - for _, node := range nodes { - commitment, err := node.Protocol.Engines.Main.Get().Storage.Commitments().Load(commitmentSlot) - require.NoError(t.Testing, err) - - issuingOptions[node.Name] = []options.Option[mock.BlockHeaderParams]{ - mock.WithSlotCommitment(commitment.Commitment()), - } + if useCommitmentAtMinCommittableAge && slot > t.API.ProtocolParameters().MinCommittableAge() { + // Make sure that all nodes create blocks throughout the slot that commit to the same commitment at slot-minCommittableAge-1. + commitmentSlot := slot - t.API.ProtocolParameters().MinCommittableAge() + t.AssertCommitmentSlotIndexExists(commitmentSlot, t.ClientsForNodes(nodes...)...) + for _, node := range nodes { + commitment, err := node.Protocol.Engines.Main.Get().Storage.Commitments().Load(commitmentSlot) + require.NoError(t.Testing, err) + + issuingOptions[node.Name] = []options.Option[mock.BlockHeaderParams]{ + mock.WithSlotCommitment(commitment.Commitment()), } } + } else if slot > t.API.ProtocolParameters().MaxCommittableAge()+1 { + commitmentSlot := slot - t.API.ProtocolParameters().MaxCommittableAge() + 1 + t.AssertCommitmentSlotIndexExists(commitmentSlot, t.ClientsForNodes(nodes...)...) } + t.AssertBlocksExist(blocksInSlot, true, t.ClientsForNodes(nodes...)...) } }