Skip to content

Commit

Permalink
Tests: Fix flakey incentive e2e tests (#5986)
Browse files Browse the repository at this point in the history
  • Loading branch information
jasonpaulos authored Apr 30, 2024
1 parent 5f81b7b commit d99c5c3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
27 changes: 23 additions & 4 deletions test/e2e-go/features/incentives/payouts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ func TestBasicPayouts(t *testing.T) {
}

next, err := client.AccountData(block.Proposer().String())
a.NoError(err)
a.LessOrEqual(int(status.LastRound), int(next.LastProposed))
// regardless of proposer, nobody gets paid
switch block.Proposer().String() {
Expand All @@ -137,6 +138,12 @@ func TestBasicPayouts(t *testing.T) {
a.NoError(err)
}

// all nodes are in sync
for _, c := range []libgoal.Client{c15, c01, relay} {
_, err := c.WaitForRound(status.LastRound)
a.NoError(err)
}

// Wait until each have proposed, so we can see that 01 gets paid and 15 does not (too much balance)
proposed01 := false
proposed15 := false
Expand All @@ -148,13 +155,17 @@ func TestBasicPayouts(t *testing.T) {
a.EqualValues(bonus1, block.Bonus.Raw)

next, err := client.AccountData(block.Proposer().String())
a.NoError(err)
fmt.Printf(" proposer %v has %d after proposing round %d\n", block.Proposer(), next.MicroAlgos.Raw, status.LastRound)

// all nodes agree the proposer proposed
for i, c := range []libgoal.Client{c15, c01, relay} {
_, err := c.WaitForRound(status.LastRound)
a.NoError(err)
data, err := c.AccountData(block.Proposer().String())
a.NoError(err)
a.Equal(block.Round(), data.LastProposed, i)
// <= in case one node is behind, and the others have already advanced
a.LessOrEqual(block.Round(), data.LastProposed, i)
}

// 01 would get paid (because under balance cap) 15 would not
Expand Down Expand Up @@ -211,14 +222,21 @@ func TestBasicPayouts(t *testing.T) {
a.NoError(err)

for _, c := range []libgoal.Client{c15, c01, relay} {
_, err := c.WaitForRound(status.LastRound)
a.NoError(err)
data, err = c.AccountData(block.Proposer().String())
a.NoError(err)
a.Equal(block.Round(), data.LastProposed)
a.Equal(pdata, data)
// <= in case one node is behind, and the others have already advanced
a.LessOrEqual(block.Round(), data.LastProposed)
// <= in case one node is behind, and the others have already advanced
a.LessOrEqual(pdata.MicroAlgos.Raw, data.MicroAlgos.Raw)
a.Equal(pdata.Status, data.Status)
a.True(data.IncentiveEligible)

data, err = c.AccountData(feesink.String())
a.NoError(err)
a.Equal(fdata, data)
// >= in case one node is behind, and the others have already advanced
a.GreaterOrEqual(fdata.MicroAlgos.Raw, data.MicroAlgos.Raw)
}
a.LessOrEqual(100000, int(data.MicroAlgos.Raw)) // won't go below minfee
if data.MicroAlgos.Raw == 100000 {
Expand Down Expand Up @@ -270,6 +288,7 @@ func TestBasicPayouts(t *testing.T) {

// account is gone anyway (it didn't get paid)
data, err = relay.AccountData(account01.Address)
a.NoError(err)
a.Zero(data, "%+v", data)

data, err = relay.AccountData(feesink.String())
Expand Down
4 changes: 3 additions & 1 deletion test/e2e-go/features/incentives/suspension_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,13 @@ func TestBasicSuspension(t *testing.T) {
stat, err = lg.WaitForRound(stat.LastRound + 1)
a.NoError(err)
attempts++
a.Less(attempts, suspend20, "n20 didn't propose\n")
a.Less(attempts, 2*suspend20, "n20 didn't propose\n")
}
// paranoia. see payouts_test.go for more details.
r := require.New(t)
for i, c := range []libgoal.Client{c10, c20} {
_, err := c.WaitForRound(stat.LastRound)
r.NoError(err)
account, err = c.AccountData(account20.Address)
a.NoError(err)
r.Equal(basics.Online, account.Status, i)
Expand Down

0 comments on commit d99c5c3

Please sign in to comment.