package internal

import (
	"sync"
	"testing"

	"github.com/stretchr/testify/assert"
)

func TestNonceCounter(t *testing.T) {
	var wg sync.WaitGroup
	for i := 0; i < 10000; i++ {
		wg.Add(1)
		go func() {
			for i := 0; i < 10000; i++ {
				nonceCounter.LoadAndAdd(1)
			}
			wg.Done()
		}()
	}
	wg.Wait()
	assert.Equal(t, nonceCounter.n, uint64(10000)*10000)
}
