Skip to content
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
22 changes: 14 additions & 8 deletions ledger/acctupdates_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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{}{}
}