/*
GoVPN -- simple secure free software virtual private network daemon
-Copyright (C) 2014-2016 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2014-2017 Sergey Matveev <stargrave@stargrave.org>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
testPeer *Peer
testPt []byte
testCt []byte
- testPeerId PeerId
+ testPeerID PeerID
testConf *PeerConf
)
func init() {
id := new([IDSize]byte)
- testPeerId = PeerId(*id)
+ testPeerID = PeerID(*id)
testConf = &PeerConf{
- Id: &testPeerId,
+ ID: &testPeerID,
MTU: MTUDefault,
Timeout: time.Second * time.Duration(TimeoutDefault),
}
- testPeer = newPeer(true, "foo", Dummy{&testCt}, testConf, new([SSize]byte))
testPt = make([]byte, 789)
}
+func testPeerNew() {
+ testPeer = newPeer(true, "foo", Dummy{&testCt}, testConf, new([SSize]byte))
+}
+
func TestTransportSymmetric(t *testing.T) {
- peerd := newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
+ testPeerNew()
+ peerd := newPeer(false, "foo", Dummy{nil}, testConf, new([SSize]byte))
f := func(payload []byte) bool {
if len(payload) == 0 {
return true
}
func TestTransportSymmetricNoise(t *testing.T) {
- peerd := newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
+ testPeerNew()
+ peerd := newPeer(false, "foo", Dummy{nil}, testConf, new([SSize]byte))
testPeer.NoiseEnable = true
peerd.NoiseEnable = true
f := func(payload []byte) bool {
}
func TestTransportSymmetricEncless(t *testing.T) {
- peerd := newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
+ testPeerNew()
+ peerd := newPeer(false, "foo", Dummy{nil}, testConf, new([SSize]byte))
testPeer.Encless = true
testPeer.NoiseEnable = true
peerd.Encless = true
}
func BenchmarkEnc(b *testing.B) {
- b.ResetTimer()
for i := 0; i < b.N; i++ {
testPeer.EthProcess(testPt)
}
testPeer = newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
orig := make([]byte, len(testCt))
copy(orig, testCt)
+ nonce := new([NonceSize]byte)
+ copy(nonce[:], testCt[len(testCt)-NonceSize:])
b.ResetTimer()
for i := 0; i < b.N; i++ {
- testPeer.nonceBucket0 = make(map[uint64]struct{}, 1)
- testPeer.nonceBucket1 = make(map[uint64]struct{}, 1)
+ testPeer.nonceBucketL = make(map[[NonceSize]byte]struct{}, 1)
+ testPeer.nonceBucketM = make(map[[NonceSize]byte]struct{}, 1)
+ testPeer.nonceBucketH = make(map[[NonceSize]byte]struct{}, 1)
+ testPeer.nonceBucketL[*nonce] = struct{}{}
copy(testCt, orig)
if !testPeer.PktProcess(testCt, Dummy{nil}, true) {
b.Fail()