]> Cypherpunks.ru repositories - govpn.git/commitdiff
Prefix testing-related global variables for clarity
authorSergey Matveev <stargrave@stargrave.org>
Wed, 6 Jan 2016 15:30:29 +0000 (18:30 +0300)
committerSergey Matveev <stargrave@stargrave.org>
Wed, 6 Jan 2016 15:30:29 +0000 (18:30 +0300)
Signed-off-by: Sergey Matveev <stargrave@stargrave.org>
src/govpn/handshake_test.go
src/govpn/peer_test.go

index 228f58b1130a3b5d34ce8dcd24d484519db67e9a..20bafae5f4fd7271808ece0b65fed0be6bc9f2fd 100644 (file)
@@ -24,56 +24,56 @@ import (
 
 func TestHandshakeSymmetric(t *testing.T) {
        // initial values are taken from peer_test.go's init()
-       v := VerifierNew(DefaultM, DefaultT, DefaultP, &peerId)
-       conf.Verifier = v
-       conf.DSAPriv = v.PasswordApply("does not matter")
-       hsS := NewHandshake("server", Dummy{&ciphertext}, conf)
-       hsC := HandshakeStart("client", Dummy{&ciphertext}, conf)
-       hsS.Server(ciphertext)
-       hsC.Client(ciphertext)
-       if hsS.Server(ciphertext) == nil {
+       v := VerifierNew(DefaultM, DefaultT, DefaultP, &testPeerId)
+       testConf.Verifier = v
+       testConf.DSAPriv = v.PasswordApply("does not matter")
+       hsS := NewHandshake("server", Dummy{&testCt}, testConf)
+       hsC := HandshakeStart("client", Dummy{&testCt}, testConf)
+       hsS.Server(testCt)
+       hsC.Client(testCt)
+       if hsS.Server(testCt) == nil {
                t.Fail()
        }
-       if hsC.Client(ciphertext) == nil {
+       if hsC.Client(testCt) == nil {
                t.Fail()
        }
 }
 
 func TestHandshakeNoiseSymmetric(t *testing.T) {
        // initial values are taken from peer_test.go's init()
-       v := VerifierNew(DefaultM, DefaultT, DefaultP, &peerId)
-       conf.Verifier = v
-       conf.DSAPriv = v.PasswordApply("does not matter")
-       conf.Noise = true
-       hsS := NewHandshake("server", Dummy{&ciphertext}, conf)
-       hsC := HandshakeStart("client", Dummy{&ciphertext}, conf)
-       hsS.Server(ciphertext)
-       hsC.Client(ciphertext)
-       if hsS.Server(ciphertext) == nil {
+       v := VerifierNew(DefaultM, DefaultT, DefaultP, &testPeerId)
+       testConf.Verifier = v
+       testConf.DSAPriv = v.PasswordApply("does not matter")
+       testConf.Noise = true
+       hsS := NewHandshake("server", Dummy{&testCt}, testConf)
+       hsC := HandshakeStart("client", Dummy{&testCt}, testConf)
+       hsS.Server(testCt)
+       hsC.Client(testCt)
+       if hsS.Server(testCt) == nil {
                t.Fail()
        }
-       if hsC.Client(ciphertext) == nil {
+       if hsC.Client(testCt) == nil {
                t.Fail()
        }
-       conf.Noise = false
+       testConf.Noise = false
 }
 func TestHandshakeEnclessSymmetric(t *testing.T) {
        // initial values are taken from peer_test.go's init()
-       v := VerifierNew(DefaultM, DefaultT, DefaultP, &peerId)
-       conf.Verifier = v
-       conf.DSAPriv = v.PasswordApply("does not matter")
-       conf.Encless = true
-       conf.Noise = true
-       hsS := NewHandshake("server", Dummy{&ciphertext}, conf)
-       hsC := HandshakeStart("client", Dummy{&ciphertext}, conf)
-       hsS.Server(ciphertext)
-       hsC.Client(ciphertext)
-       if hsS.Server(ciphertext) == nil {
+       v := VerifierNew(DefaultM, DefaultT, DefaultP, &testPeerId)
+       testConf.Verifier = v
+       testConf.DSAPriv = v.PasswordApply("does not matter")
+       testConf.Encless = true
+       testConf.Noise = true
+       hsS := NewHandshake("server", Dummy{&testCt}, testConf)
+       hsC := HandshakeStart("client", Dummy{&testCt}, testConf)
+       hsS.Server(testCt)
+       hsC.Client(testCt)
+       if hsS.Server(testCt) == nil {
                t.Fail()
        }
-       if hsC.Client(ciphertext) == nil {
+       if hsC.Client(testCt) == nil {
                t.Fail()
        }
-       conf.Encless = false
-       conf.Noise = false
+       testConf.Encless = false
+       testConf.Noise = false
 }
index c39106029249172d91f3354b8e2bbf55df64d7ab..7fa8aab8438a7fd04eaccf53972064edd91b8792 100644 (file)
@@ -25,11 +25,11 @@ import (
 )
 
 var (
-       peer       *Peer
-       plaintext  []byte
-       ciphertext []byte
-       peerId     PeerId
-       conf       *PeerConf
+       testPeer   *Peer
+       testPt     []byte
+       testCt     []byte
+       testPeerId PeerId
+       testConf   *PeerConf
 )
 
 type Dummy struct {
@@ -45,24 +45,24 @@ func (d Dummy) Write(b []byte) (int, error) {
 
 func init() {
        id := new([IDSize]byte)
-       peerId = PeerId(*id)
-       conf = &PeerConf{
-               Id:      &peerId,
+       testPeerId = PeerId(*id)
+       testConf = &PeerConf{
+               Id:      &testPeerId,
                MTU:     MTUDefault,
                Timeout: time.Second * time.Duration(TimeoutDefault),
        }
-       peer = newPeer(true, "foo", Dummy{&ciphertext}, conf, new([SSize]byte))
-       plaintext = make([]byte, 789)
+       testPeer = newPeer(true, "foo", Dummy{&testCt}, testConf, new([SSize]byte))
+       testPt = make([]byte, 789)
 }
 
 func TestTransportSymmetric(t *testing.T) {
-       peerd := newPeer(true, "foo", Dummy{nil}, conf, new([SSize]byte))
+       peerd := newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
        f := func(payload []byte) bool {
                if len(payload) == 0 {
                        return true
                }
-               peer.EthProcess(payload)
-               return peerd.PktProcess(ciphertext, Dummy{nil}, true)
+               testPeer.EthProcess(payload)
+               return peerd.PktProcess(testCt, Dummy{nil}, true)
        }
        if err := quick.Check(f, nil); err != nil {
                t.Error(err)
@@ -70,61 +70,61 @@ func TestTransportSymmetric(t *testing.T) {
 }
 
 func TestTransportSymmetricNoise(t *testing.T) {
-       peerd := newPeer(true, "foo", Dummy{nil}, conf, new([SSize]byte))
-       peer.NoiseEnable = true
+       peerd := newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
+       testPeer.NoiseEnable = true
        peerd.NoiseEnable = true
        f := func(payload []byte) bool {
                if len(payload) == 0 {
                        return true
                }
-               peer.EthProcess(payload)
-               return peerd.PktProcess(ciphertext, Dummy{nil}, true)
+               testPeer.EthProcess(payload)
+               return peerd.PktProcess(testCt, Dummy{nil}, true)
        }
        if err := quick.Check(f, nil); err != nil {
                t.Error(err)
        }
-       peer.NoiseEnable = true
+       testPeer.NoiseEnable = true
 }
 
 func TestTransportSymmetricEncless(t *testing.T) {
-       peerd := newPeer(true, "foo", Dummy{nil}, conf, new([SSize]byte))
-       peer.Encless = true
-       peer.NoiseEnable = true
+       peerd := newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
+       testPeer.Encless = true
+       testPeer.NoiseEnable = true
        peerd.Encless = true
        peerd.NoiseEnable = true
        f := func(payload []byte) bool {
                if len(payload) == 0 {
                        return true
                }
-               peer.EthProcess(payload)
-               return peerd.PktProcess(ciphertext, Dummy{nil}, true)
+               testPeer.EthProcess(payload)
+               return peerd.PktProcess(testCt, Dummy{nil}, true)
        }
        if err := quick.Check(f, nil); err != nil {
                t.Error(err)
        }
-       peer.NoiseEnable = false
-       peer.Encless = false
+       testPeer.NoiseEnable = false
+       testPeer.Encless = false
 }
 
 func BenchmarkEnc(b *testing.B) {
        b.ResetTimer()
        for i := 0; i < b.N; i++ {
-               peer.EthProcess(plaintext)
+               testPeer.EthProcess(testPt)
        }
 }
 
 func BenchmarkDec(b *testing.B) {
-       peer = newPeer(true, "foo", Dummy{&ciphertext}, conf, new([SSize]byte))
-       peer.EthProcess(plaintext)
-       peer = newPeer(true, "foo", Dummy{nil}, conf, new([SSize]byte))
-       orig := make([]byte, len(ciphertext))
-       copy(orig, ciphertext)
+       testPeer = newPeer(true, "foo", Dummy{&testCt}, testConf, new([SSize]byte))
+       testPeer.EthProcess(testPt)
+       testPeer = newPeer(true, "foo", Dummy{nil}, testConf, new([SSize]byte))
+       orig := make([]byte, len(testCt))
+       copy(orig, testCt)
        b.ResetTimer()
        for i := 0; i < b.N; i++ {
-               peer.nonceBucket0 = make(map[uint64]struct{}, 1)
-               peer.nonceBucket1 = make(map[uint64]struct{}, 1)
-               copy(ciphertext, orig)
-               if !peer.PktProcess(ciphertext, Dummy{nil}, true) {
+               testPeer.nonceBucket0 = make(map[uint64]struct{}, 1)
+               testPeer.nonceBucket1 = make(map[uint64]struct{}, 1)
+               copy(testCt, orig)
+               if !testPeer.PktProcess(testCt, Dummy{nil}, true) {
                        b.Fail()
                }
        }
@@ -133,5 +133,5 @@ func BenchmarkDec(b *testing.B) {
 func TestTransportBigger(t *testing.T) {
        tmp := make([]byte, MTUMax*4)
        Rand.Read(tmp)
-       peer.PktProcess(tmp, Dummy{nil}, true)
+       testPeer.PktProcess(tmp, Dummy{nil}, true)
 }