Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invert logical condition in WaitUntil functions #1123

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions e2e-polybft/bridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ func TestE2E_CheckpointSubmission(t *testing.T) {

t.Logf("Checkpoint block: %d\n", actualCheckpointBlock)

return actualCheckpointBlock < expectedCheckpointBlock, nil
return actualCheckpointBlock == expectedCheckpointBlock, nil
}

// wait for a single epoch to be checkpointed
Expand Down Expand Up @@ -590,7 +590,6 @@ func TestE2E_Bridge_ChangeVotingPower(t *testing.T) {

t.Logf("Checkpoint block: %d\n", actualCheckpointBlock)

// waiting until condition is true (namely when block 20 gets checkpointed)
return actualCheckpointBlock < finalBlockNumber, nil
return actualCheckpointBlock == finalBlockNumber, nil
}))
}
2 changes: 1 addition & 1 deletion e2e-polybft/framework/test-bridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ func (t *TestBridge) WaitUntil(pollFrequency, timeout time.Duration, handler fun
return err
}

if !isConditionMet {
if isConditionMet {
return nil
}
}
Expand Down
9 changes: 5 additions & 4 deletions e2e-polybft/framework/test-cluster.go
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ func (c *TestCluster) WaitUntil(dur time.Duration, handler func() bool) error {
case <-time.After(2 * time.Second):
}

if !handler() {
if handler() {
return nil
}
}
Expand Down Expand Up @@ -484,12 +484,13 @@ func (c *TestCluster) WaitForBlock(n uint64, timeout time.Duration) error {
func (c *TestCluster) WaitForGeneric(dur time.Duration, fn func(*TestServer) bool) error {
return c.WaitUntil(dur, func() bool {
for _, srv := range c.Servers {
if srv.isRunning() && !fn(srv) { // if server is stopped - skip it
return true
// query only running servers
if srv.isRunning() && !fn(srv) {
return false
}
}

return false
return true
})
}

Expand Down
6 changes: 3 additions & 3 deletions e2e-polybft/txpool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,11 +71,11 @@ func TestE2E_TxPool_Transfer(t *testing.T) {
}
t.Logf("Balance %s %s", receiver, balance)
if balance.Uint64() != uint64(sendAmount) {
return true
return false
}
}

return false
return true
})
require.NoError(t, err)
}
Expand Down Expand Up @@ -104,7 +104,7 @@ func TestE2E_TxPool_Transfer_Linear(t *testing.T) {
return true
}

return balance.Cmp(big.NewInt(0)) == 0
return balance.Cmp(big.NewInt(0)) > 0
})

return err
Expand Down