26 lines
507 B
Go
26 lines
507 B
Go
package tests
|
|
|
|
import (
|
|
"lux/net"
|
|
"testing"
|
|
)
|
|
|
|
func TestNonces(t *testing.T) {
|
|
list := net.NewLuxNonceList()
|
|
for i := 0; i < 129; i++ {
|
|
if !list.RotateOrFail(net.GenerateLuxNonce()) {
|
|
t.Fatal("duplicate 64bit nonce per 129 items")
|
|
}
|
|
}
|
|
|
|
// sanity checks
|
|
if list.Get(0) == list.Get(1) {
|
|
t.Fatal("list.Get(0) == list.Get(1)")
|
|
}
|
|
if list.Get(0) == list.Get(127) {
|
|
t.Fatal("list.Get(0) == list.Get(127)")
|
|
}
|
|
if list.Get(126) == list.Get(127) {
|
|
t.Fatal("list.Get(26) == list.Get(127)")
|
|
}
|
|
}
|