mirror of
https://github.com/ipfs/kubo.git
synced 2026-02-23 11:27:42 +08:00
24 lines
376 B
Go
24 lines
376 B
Go
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()
|
|
}
|
|
}
|