-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Brian Tiger Chow
committed
Sep 11, 2014
1 parent
7bae742
commit ad30333
Showing
2 changed files
with
46 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package bitswap | ||
|
||
import ( | ||
"sync" | ||
"testing" | ||
) | ||
|
||
func TestRaceConditions(t *testing.T) { | ||
const numberOfExpectedExchanges = 10000 | ||
l := new(Ledger) | ||
var wg sync.WaitGroup | ||
for i := 0; i < numberOfExpectedExchanges; i++ { | ||
wg.Add(1) | ||
go func() { | ||
defer wg.Done() | ||
l.ReceivedBytes(1) | ||
}() | ||
} | ||
wg.Wait() | ||
if l.ExchangeCount() != numberOfExpectedExchanges { | ||
t.Fail() | ||
} | ||
} |