Skip to content

Commit 3986c99

Browse files
committed
change to one function
1 parent a64f705 commit 3986c99

File tree

2 files changed

+14
-13
lines changed

2 files changed

+14
-13
lines changed

long_running_test.go

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ func TestLongRunningSimple(t *testing.T) {
1111
net := testutil.NewDefaultLongRunningNetwork(t, 5)
1212

1313
net.StartInstances()
14-
net.WaitForAllNodesToEnterRound(40)
14+
net.WaitForNodesToEnterRound(40)
1515
net.StopAndAssert(false)
1616
}
1717

@@ -22,15 +22,15 @@ func TestLongRunningReplication(t *testing.T) {
2222
}
2323
net.StartInstances()
2424

25-
net.WaitForAllNodesToEnterRound(40)
25+
net.WaitForNodesToEnterRound(40)
2626
net.NoMoreBlocks()
2727
net.DisconnectNodes(2)
2828
net.ContinueBlocks()
29-
net.WaitForCertainNodesToEnterRound(70, 1, 3, 4, 5, 6)
29+
net.WaitForNodesToEnterRound(70, 1, 3, 4, 5, 6)
3030
net.DisconnectNodes(4)
31-
net.WaitForCertainNodesToEnterRound(90, 1, 3, 5, 6, 7, 8, 9)
31+
net.WaitForNodesToEnterRound(90, 1, 3, 5, 6, 7, 8, 9)
3232
net.ConnectNodes(2, 4)
33-
net.WaitForAllNodesToEnterRound(150)
33+
net.WaitForNodesToEnterRound(150)
3434
net.StopAndAssert(false)
3535
}
3636

@@ -46,14 +46,14 @@ func TestLongRunningCrash(t *testing.T) {
4646
}
4747

4848
net.StartInstances()
49-
net.WaitForAllNodesToEnterRound(30)
49+
net.WaitForNodesToEnterRound(30)
5050
net.CrashNodes(3)
5151
crashedNodeLatestBlock := net.Instances[3].Storage.NumBlocks()
5252

53-
net.WaitForCertainNodesToEnterRound(80, 1, 2, 4, 5, 6, 7, 8, 9)
53+
net.WaitForNodesToEnterRound(80, 1, 2, 4, 5, 6, 7, 8, 9)
5454
net.RestartNodes(3)
5555

5656
waitForRound := math.Max(float64(crashedNodeLatestBlock*2), 150)
57-
net.WaitForAllNodesToEnterRound(uint64(waitForRound))
57+
net.WaitForNodesToEnterRound(uint64(waitForRound))
5858
net.StopAndAssert(false)
5959
}

testutil/long_running_network.go

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,13 +113,14 @@ func (n *LongRunningInMemoryNetwork) ContinueBlocks() {
113113
}
114114
}
115115

116-
func (n *LongRunningInMemoryNetwork) WaitForAllNodesToEnterRound(round uint64) {
117-
for _, instance := range n.Instances {
118-
WaitToEnterRoundWithTimeout(n.t, instance.E, round, 3*time.Second)
116+
func (n *LongRunningInMemoryNetwork) WaitForNodesToEnterRound(round uint64, nodeIndexes ...uint64) {
117+
// check if nodeIndexes have length 0
118+
if len(nodeIndexes) == 0 {
119+
for _, instance := range n.Instances {
120+
WaitToEnterRoundWithTimeout(n.t, instance.E, round, 3*time.Second)
121+
}
119122
}
120-
}
121123

122-
func (n *LongRunningInMemoryNetwork) WaitForCertainNodesToEnterRound(round uint64, nodeIndexes ...uint64) {
123124
for _, idx := range nodeIndexes {
124125
WaitToEnterRoundWithTimeout(n.t, n.Instances[idx].E, round, 3*time.Second)
125126
}

0 commit comments

Comments
 (0)