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

TestSPWithCounterReset make it more tolerant #4366

Merged
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
17 changes: 12 additions & 5 deletions test/e2e-go/features/stateproofs/stateproofs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -877,7 +877,10 @@ func TestSPWithTXPoolFull(t *testing.T) {
continue
}
require.Equal(t, string(protocol.StateProofTx), b.Transactions.Transactions[0].Type)
require.Equal(t, uint64(8), b.Transactions.Transactions[0].StateProof.StateProofIntervalLatestRound)
var msg stateproofmsg.Message
err = protocol.Decode(b.Transactions.Transactions[0].StateProof.StateProofMessage, &msg)
require.NoError(t, err)
require.Equal(t, uint64(8), msg.LastAttestedRound)
break
}
require.Less(t, round, uint64(20))
Expand Down Expand Up @@ -983,7 +986,7 @@ func TestSPWithCounterReset(t *testing.T) {
// Check that the first 2 stateproofs are added to the blockchain
round := uint64(0)
expectedSPRound := consensusParams.StateProofInterval * 2
for round < consensusParams.StateProofInterval*5 {
for round < consensusParams.StateProofInterval*10 {
round = params.LastRound

err := fixture.WaitForRound(round+1, 6*time.Second)
Expand All @@ -1005,7 +1008,12 @@ func TestSPWithCounterReset(t *testing.T) {
for ; tid < len(b.Transactions.Transactions); tid++ {
if b.Transactions.Transactions[tid].Type == string(protocol.StateProofTx) {
require.Equal(t, string(protocol.StateProofTx), b.Transactions.Transactions[tid].Type)
require.Equal(t, int(expectedSPRound), int(b.Transactions.Transactions[tid].StateProof.StateProofIntervalLatestRound))

var msg stateproofmsg.Message
err = protocol.Decode(b.Transactions.Transactions[tid].StateProof.StateProofMessage, &msg)
require.NoError(t, err)
require.Equal(t, int(expectedSPRound), int(msg.LastAttestedRound))

expectedSPRound = expectedSPRound + consensusParams.StateProofInterval
break
}
Expand All @@ -1015,7 +1023,7 @@ func TestSPWithCounterReset(t *testing.T) {
}
}
// If waited till round 20 and did not yet get the stateproof with last round 12, fail the test
require.Less(t, round, consensusParams.StateProofInterval*5)
require.Less(t, round, consensusParams.StateProofInterval*10)
}

func getWellformedSPTransaction(round uint64, genesisHash crypto.Digest, consensusParams config.ConsensusParams, t *testing.T) (stxn transactions.SignedTxn) {
Expand All @@ -1029,7 +1037,6 @@ func getWellformedSPTransaction(round uint64, genesisHash crypto.Digest, consens
stxn.Txn.FirstValid = basics.Round(round)
stxn.Txn.LastValid = basics.Round(round + 1000)
stxn.Txn.GenesisHash = genesisHash
stxn.Txn.StateProofIntervalLastRound = basics.Round(round - 1)
stxn.Txn.StateProofType = protocol.StateProofBasic
stxn.Txn.StateProof = *proof
stxn.Txn.Message = msg
Expand Down