]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cypherpunks.ru/nncp/pkt_test.go
AEAD encryption mode and new encrypted packet format
[nncp.git] / src / cypherpunks.ru / nncp / pkt_test.go
index 6f8506a10918073fc20124b52ba2d1deb94b01e5..43602d733ac199555ce11bc5d8ec26ff4ed48daa 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2018 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2019 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
@@ -41,7 +41,7 @@ func TestPktEncWrite(t *testing.T) {
                if len(path) > int(pathSize) {
                        path = path[:int(pathSize)]
                }
-               pkt, err := NewPkt(PktTypeFile, 123, path)
+               pkt, err := NewPkt(PktTypeFile, 123, []byte(path))
                if err != nil {
                        panic(err)
                }
@@ -81,13 +81,18 @@ func TestPktEncRead(t *testing.T) {
        if err != nil {
                panic(err)
        }
-       f := func(path string, pathSize uint8, data [1 << 16]byte, size, padSize uint16, junk []byte) bool {
+       f := func(
+               path string,
+               pathSize uint8,
+               data [1 << 16]byte,
+               size, padSize uint16,
+               junk []byte) bool {
                dataR := bytes.NewReader(data[:])
                var ct bytes.Buffer
                if len(path) > int(pathSize) {
                        path = path[:int(pathSize)]
                }
-               pkt, err := NewPkt(PktTypeFile, 123, path)
+               pkt, err := NewPkt(PktTypeFile, 123, []byte(path))
                if err != nil {
                        panic(err)
                }
@@ -115,7 +120,7 @@ func TestPktEncRead(t *testing.T) {
                if *node.Id != *node1.Id {
                        return false
                }
-               if sizeGot != int64(size) {
+               if sizeGot != sizeWithTags(PktOverhead+int64(size)) {
                        return false
                }
                var pktBuf bytes.Buffer