]> Cypherpunks.ru repositories - govpn.git/blobdiff - src/govpn/peer_test.go
Input transport data size check
[govpn.git] / src / govpn / peer_test.go
index 40f6b1d4970210c8e6d0ccd45d4a2629ac24110d..c39106029249172d91f3354b8e2bbf55df64d7ab 100644 (file)
@@ -28,7 +28,7 @@ var (
        peer       *Peer
        plaintext  []byte
        ciphertext []byte
-       peerId     *PeerId
+       peerId     PeerId
        conf       *PeerConf
 )
 
@@ -44,20 +44,18 @@ func (d Dummy) Write(b []byte) (int, error) {
 }
 
 func init() {
-       MTU = 1500
        id := new([IDSize]byte)
-       peerId := PeerId(*id)
+       peerId = PeerId(*id)
        conf = &PeerConf{
                Id:      &peerId,
+               MTU:     MTUDefault,
                Timeout: time.Second * time.Duration(TimeoutDefault),
-               Noise:   false,
-               CPR:     0,
        }
        peer = newPeer(true, "foo", Dummy{&ciphertext}, conf, new([SSize]byte))
        plaintext = make([]byte, 789)
 }
 
-func TestSymmetric(t *testing.T) {
+func TestTransportSymmetric(t *testing.T) {
        peerd := newPeer(true, "foo", Dummy{nil}, conf, new([SSize]byte))
        f := func(payload []byte) bool {
                if len(payload) == 0 {
@@ -71,7 +69,7 @@ func TestSymmetric(t *testing.T) {
        }
 }
 
-func TestSymmetricNoise(t *testing.T) {
+func TestTransportSymmetricNoise(t *testing.T) {
        peerd := newPeer(true, "foo", Dummy{nil}, conf, new([SSize]byte))
        peer.NoiseEnable = true
        peerd.NoiseEnable = true
@@ -88,11 +86,11 @@ func TestSymmetricNoise(t *testing.T) {
        peer.NoiseEnable = true
 }
 
-func TestSymmetricEncLess(t *testing.T) {
+func TestTransportSymmetricEncless(t *testing.T) {
        peerd := newPeer(true, "foo", Dummy{nil}, conf, new([SSize]byte))
-       peer.EncLess = true
+       peer.Encless = true
        peer.NoiseEnable = true
-       peerd.EncLess = true
+       peerd.Encless = true
        peerd.NoiseEnable = true
        f := func(payload []byte) bool {
                if len(payload) == 0 {
@@ -105,7 +103,7 @@ func TestSymmetricEncLess(t *testing.T) {
                t.Error(err)
        }
        peer.NoiseEnable = false
-       peer.EncLess = false
+       peer.Encless = false
 }
 
 func BenchmarkEnc(b *testing.B) {
@@ -131,3 +129,9 @@ func BenchmarkDec(b *testing.B) {
                }
        }
 }
+
+func TestTransportBigger(t *testing.T) {
+       tmp := make([]byte, MTUMax*4)
+       Rand.Read(tmp)
+       peer.PktProcess(tmp, Dummy{nil}, true)
+}