package node import ( "bytes" "crypto/rand" "testing" "golang.org/x/crypto/nacl/sign" ) func TestLocalDiscoveryPacketSigning(t *testing.T) { localIP = 32 var ( buf1 = make([]byte, bufferSize) buf2 = make([]byte, bufferSize) pubSignKey, privSigKey, _ = sign.GenerateKey(rand.Reader) ) privSignKey = privSigKey[:] route := routingTable[localIP].Load() route.IP = byte(localIP) route.PubSignKey = pubSignKey[0:32] routingTable[localIP].Store(route) out := buildLocalDiscoveryPacket(buf1, buf2) h, ok := openLocalDiscoveryPacket(bytes.Clone(out), buf1) if !ok { t.Fatal(h, ok) } if h.StreamID != controlStreamID || h.SourceIP != localIP || h.DestIP != 255 { t.Fatal(h) } }