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

Tests: Fix flakey incentive e2e tests #5986

Merged
merged 4 commits into from
Apr 30, 2024
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
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)
gmalouf marked this conversation as resolved.
Show resolved Hide resolved
// <= 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
Loading