Skip to content

Commit

Permalink
tests: fix logged panics in reproducible labels test (#4446)
Browse files Browse the repository at this point in the history
Fix an issue with consensus params not saved in forked ledgers.
Set logging level=info in tests that produce to much debug output while adding thousands of blocks.
  • Loading branch information
algorandskiy authored Aug 23, 2022
1 parent 1196dd0 commit 924d2fb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 7 deletions.
16 changes: 9 additions & 7 deletions ledger/acctupdates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,12 +120,14 @@ func (ml *mockLedgerForTracker) fork(t testing.TB) *mockLedgerForTracker {
dblogger := logging.TestingLog(t)
dblogger.SetLevel(logging.Info)
newLedgerTracker := &mockLedgerForTracker{
inMemory: false,
log: dblogger,
blocks: make([]blockEntry, len(ml.blocks)),
deltas: make([]ledgercore.StateDelta, len(ml.deltas)),
accts: make(map[basics.Address]basics.AccountData),
filename: fn,
inMemory: false,
log: dblogger,
blocks: make([]blockEntry, len(ml.blocks)),
deltas: make([]ledgercore.StateDelta, len(ml.deltas)),
accts: make(map[basics.Address]basics.AccountData),
filename: fn,
consensusParams: ml.consensusParams,
consensusVersion: ml.consensusVersion,
}
for k, v := range ml.accts {
newLedgerTracker.accts[k] = v
Expand Down Expand Up @@ -289,7 +291,7 @@ func checkAcctUpdates(t *testing.T, au *accountUpdates, ao *onlineAccounts, base
require.Error(t, err)
require.Equal(t, basics.Round(0), validThrough)

if base > 0 {
if base > 0 && base >= basics.Round(ao.maxBalLookback()) {
_, err := ao.onlineTotals(base - basics.Round(ao.maxBalLookback()))
require.Error(t, err)

Expand Down
2 changes: 2 additions & 0 deletions ledger/archival_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@ func TestArchival(t *testing.T) {
cfg := config.GetDefaultLocal()
cfg.Archival = true
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg)
require.NoError(t, err)
defer l.Close()
Expand Down Expand Up @@ -720,6 +721,7 @@ func TestArchivalFromNonArchival(t *testing.T) {
cfg.Archival = false

log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbPrefix, inMem, genesisInitState, cfg)
require.NoError(t, err)
blk := genesisInitState.Block
Expand Down
7 changes: 7 additions & 0 deletions ledger/ledger_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1388,6 +1388,7 @@ func TestLedgerBlockHdrCaching(t *testing.T) {
cfg := config.GetDefaultLocal()
cfg.Archival = true
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg)
a.NoError(err)
defer l.Close()
Expand Down Expand Up @@ -1484,6 +1485,7 @@ func TestLedgerReload(t *testing.T) {
cfg := config.GetDefaultLocal()
cfg.Archival = true
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg)
require.NoError(t, err)
defer l.Close()
Expand Down Expand Up @@ -1682,11 +1684,13 @@ func TestLedgerKeepsOldBlocksForStateProof(t *testing.T) {
cfg := config.GetDefaultLocal()
cfg.Archival = false
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg)
require.NoError(t, err)
defer l.Close()

lastBlock, err := l.Block(l.Latest())
require.NoError(t, err)
proto := config.Consensus[lastBlock.CurrentProtocol]
accounts := make(map[basics.Address]basics.AccountData, len(genesisInitState.Accounts)+maxBlocks)
keys := make(map[basics.Address]*crypto.SignatureSecrets, len(initKeys)+maxBlocks)
Expand Down Expand Up @@ -2665,6 +2669,7 @@ func TestVotersReloadFromDisk(t *testing.T) {
cfg.Archival = false
cfg.MaxAcctLookback = proto.StateProofInterval - proto.StateProofVotersLookback - 10
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg)
require.NoError(t, err)
defer l.Close()
Expand Down Expand Up @@ -2712,6 +2717,7 @@ func TestVotersReloadFromDiskAfterOneStateProofCommitted(t *testing.T) {
cfg.Archival = false
cfg.MaxAcctLookback = proto.StateProofInterval - proto.StateProofVotersLookback - 10
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg)
require.NoError(t, err)
defer l.Close()
Expand Down Expand Up @@ -2771,6 +2777,7 @@ func TestVotersReloadFromDiskPassRecoveryPeriod(t *testing.T) {
cfg.Archival = false
cfg.MaxAcctLookback = proto.StateProofInterval - proto.StateProofVotersLookback - 10
log := logging.TestingLog(t)
log.SetLevel(logging.Info)
l, err := OpenLedger(log, dbName, inMem, genesisInitState, cfg)
require.NoError(t, err)
defer l.Close()
Expand Down

0 comments on commit 924d2fb

Please sign in to comment.