summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorchris erway <51567+cce@users.noreply.github.com>2022-01-14 12:44:32 -0500
committerGitHub <noreply@github.com>2022-01-14 12:44:32 -0500
commitf864f9e231c2c4bf6f29a3ebfc4a4791136e0c74 (patch)
tree592fcdbf23d23a9e30fa9965c59905ab85901011
parentee988ea30c50c15f3b904ca409ea4df9fc958566 (diff)
testing: Add slightly more coverage to TestAcctUpdatesLookupRetry (#3384)
Add slightly more coverage to TestAcctUpdatesLookupRetry
-rw-r--r--ledger/acctupdates_test.go22
1 files changed, 14 insertions, 8 deletions
diff --git a/ledger/acctupdates_test.go b/ledger/acctupdates_test.go
index 5f014985c..f1434b02f 100644
--- a/ledger/acctupdates_test.go
+++ b/ledger/acctupdates_test.go
@@ -1734,7 +1734,7 @@ func TestAcctUpdatesLookupRetry(t *testing.T) {
sinkdata.Status = basics.NotParticipating
accts[0][testSinkAddr] = sinkdata
- ml := makeMockLedgerForTracker(t, false, 10, testProtocolVersion, accts)
+ ml := makeMockLedgerForTracker(t, true, 10, testProtocolVersion, accts)
defer ml.Close()
conf := config.GetDefaultLocal()
@@ -1833,19 +1833,25 @@ func TestAcctUpdatesLookupRetry(t *testing.T) {
break
}
- // release the postCommit lock, once au.lookupWithoutRewards hits au.accountsReadCond.Wait()
+ defer func() { // allow the postCommitUnlocked() handler to go through, even if test fails
+ <-stallingTracker.postCommitUnlockedEntryLock
+ stallingTracker.postCommitUnlockedReleaseLock <- struct{}{}
+ }()
+
+ // issue a LookupWithoutRewards while persistedData.round != au.cachedDBRound
+ // when synchronized=false it will fail fast
+ d, validThrough, err := au.lookupWithoutRewards(rnd, addr, false)
+ require.Equal(t, err, &MismatchingDatabaseRoundError{databaseRound: 2, memoryRound: 1})
+
+ // release the postCommit lock, once au.lookupWithoutRewards() hits au.accountsReadCond.Wait()
go func() {
time.Sleep(200 * time.Millisecond)
stallingTracker.postCommitReleaseLock <- struct{}{}
}()
- // issue a LookupWithoutRewards while persistedData.round != au.cachedDBRound
- d, validThrough, err := au.LookupWithoutRewards(rnd, addr)
+ // when synchronized=true it will wait until above goroutine releases postCommitReleaseLock
+ d, validThrough, err = au.lookupWithoutRewards(rnd, addr, true)
require.NoError(t, err)
require.Equal(t, d, data)
require.GreaterOrEqualf(t, uint64(validThrough), uint64(rnd), "validThrough: %v rnd :%v", validThrough, rnd)
-
- // allow the postCommitUnlocked() handler to go through
- <-stallingTracker.postCommitUnlockedEntryLock
- stallingTracker.postCommitUnlockedReleaseLock <- struct{}{}
}