ledger_test.go 377 Bytes
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
package strategy

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()
	}
}