Skip to content

Commit

Permalink
update TestExpiredAccountGeneration
Browse files Browse the repository at this point in the history
  • Loading branch information
cce committed Sep 18, 2024
1 parent c24e809 commit c252d95
Showing 1 changed file with 15 additions and 44 deletions.
59 changes: 15 additions & 44 deletions ledger/eval/eval_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1266,7 +1266,7 @@ func TestExpiredAccountGenerationWithDiskFailure(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

genesisInitState, addrs, keys := ledgertesting.GenesisWithProto(10, protocol.ConsensusFuture)
genesisInitState, addrs, _ := ledgertesting.GenesisWithProto(10, protocol.ConsensusFuture)

sendAddr := addrs[0]
recvAddr := addrs[1]
Expand Down Expand Up @@ -1312,26 +1312,6 @@ func TestExpiredAccountGenerationWithDiskFailure(t *testing.T) {
eval = l.nextBlock(t)
}

genHash := l.GenesisHash()
txn := transactions.Transaction{
Type: protocol.PaymentTx,
Header: transactions.Header{
Sender: sendAddr,
Fee: minFee,
FirstValid: newBlock.Round(),
LastValid: eval.Round(),
GenesisHash: genHash,
},
PaymentTxnFields: transactions.PaymentTxnFields{
Receiver: recvAddr,
Amount: basics.MicroAlgos{Raw: 100},
},
}

st := txn.Sign(keys[0])
err = eval.Transaction(st, transactions.ApplyData{})
require.NoError(t, err)

eval.validate = true
eval.generate = false

Expand Down Expand Up @@ -1541,7 +1521,7 @@ func TestExpiredAccountGeneration(t *testing.T) {
partitiontest.PartitionTest(t)
t.Parallel()

genesisInitState, addrs, keys := ledgertesting.GenesisWithProto(10, protocol.ConsensusFuture)
genesisInitState, addrs, _ := ledgertesting.GenesisWithProto(10, protocol.ConsensusFuture)

sendAddr := addrs[0]
recvAddr := addrs[1]
Expand All @@ -1550,7 +1530,7 @@ func TestExpiredAccountGeneration(t *testing.T) {
recvAddrLastValidRound := basics.Round(2)

// the target round we want to advance the evaluator to
targetRound := basics.Round(4)
targetRound := basics.Round(2)

// Set all to online except the sending address
for _, addr := range addrs {
Expand Down Expand Up @@ -1592,31 +1572,22 @@ func TestExpiredAccountGeneration(t *testing.T) {

// Advance the evaluator a couple rounds...
for i := uint64(0); i < uint64(targetRound); i++ {
l.endBlock(t, eval)
vb := l.endBlock(t, eval)
eval = l.nextBlock(t)
}

require.Greater(t, uint64(eval.Round()), uint64(recvAddrLastValidRound))

genHash := l.GenesisHash()
txn := transactions.Transaction{
Type: protocol.PaymentTx,
Header: transactions.Header{
Sender: sendAddr,
Fee: minFee,
FirstValid: newBlock.Round(),
LastValid: eval.Round(),
GenesisHash: genHash,
},
PaymentTxnFields: transactions.PaymentTxnFields{
Receiver: recvAddr,
Amount: basics.MicroAlgos{Raw: 100},
},
expiredAddrs := make(map[basics.Address]struct{})
for _, addr := range vb.Block().ExpiredParticipationAccounts {
expiredAddrs[addr] = struct{}{}
}
// get indexes of addrs in ExpiredParticipationAccounts
for j, addr := range addrs {
if _, isExpired := expiredAddrs[addr]; isExpired {
t.Logf("round %d: addr %d %s is expired", vb.Block().Round(), j, addr)
}
}
}

st := txn.Sign(keys[0])
err = eval.Transaction(st, transactions.ApplyData{})
require.NoError(t, err)
require.Greater(t, uint64(eval.Round()), uint64(recvAddrLastValidRound))

// Make sure we validate our block as well
eval.validate = true
Expand Down

0 comments on commit c252d95

Please sign in to comment.