summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTsachi Herman <tsachi.herman@algorand.com>2021-12-15 12:14:38 -0500
committerGitHub <noreply@github.com>2021-12-15 12:14:38 -0500
commitde7fe4538af68a18d1a4963be1ea6b932649f579 (patch)
tree09f21b00d8ac3b8625dcec8b91e82e7c4f058bf9
parent34e2fbd1282747f662fb9f418d03c11746818080 (diff)
testing: fix random data race in TestAppAccountDataStorage (#3315)
fix random data race in unit test
-rw-r--r--ledger/applications_test.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/ledger/applications_test.go b/ledger/applications_test.go
index 43a03bfb7..5630fc19c 100644
--- a/ledger/applications_test.go
+++ b/ledger/applications_test.go
@@ -39,7 +39,18 @@ func commitRound(offset uint64, dbRound basics.Round, l *Ledger) {
l.trackers.mu.Unlock()
l.trackers.scheduleCommit(l.Latest(), l.Latest()-(dbRound+basics.Round(offset)))
- l.trackers.waitAccountsWriting()
+ // wait for the operation to complete. Once it does complete, the tr.lastFlushTime is going to be updated, so we can
+ // use that as an indicator.
+ for {
+ l.trackers.mu.Lock()
+ isDone := (!l.trackers.lastFlushTime.IsZero()) && (len(l.trackers.deferredCommits) == 0)
+ l.trackers.mu.Unlock()
+ if isDone {
+ break
+ }
+ time.Sleep(time.Millisecond)
+
+ }
}
// test ensures that