Skip to content

Commit

Permalink
Fix race condition in test suite where we don't actually wait for slo…
Browse files Browse the repository at this point in the history
…ts to be committed. Through the faster weight propagation this seemed to occur consistently now, whereas before it was hidden by too slow execution
  • Loading branch information
jonastheis committed Mar 28, 2024
1 parent 23710b2 commit 3ece0d1
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions pkg/testsuite/testsuite_issue_blocks.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)...)
}
}
Expand Down

0 comments on commit 3ece0d1

Please sign in to comment.