]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/tx_test.go
Multicast areas
[nncp.git] / src / tx_test.go
index ca77d4c553fb19e9d303dadef6e7a85d21058bf3..85a00db69a416bbd6ae19cb6e9e5b569751f026f 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2019 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2021 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
@@ -28,7 +28,6 @@ import (
        "testing/quick"
 
        xdr "github.com/davecgh/go-xdr/xdr2"
-       "golang.org/x/crypto/blake2b"
 )
 
 func TestTx(t *testing.T) {
@@ -84,6 +83,8 @@ func TestTx(t *testing.T) {
                        int64(src.Len()),
                        int64(padSize),
                        src,
+                       "pktName",
+                       nil,
                )
                if err != nil {
                        return false
@@ -97,16 +98,22 @@ func TestTx(t *testing.T) {
                        return false
                }
                txJob := sentJobs[0]
-               defer txJob.Fd.Close()
+               fd, err := os.Open(txJob.Path)
+               if err != nil {
+                       panic(err)
+               }
+               defer fd.Close()
                var bufR bytes.Buffer
-               if _, err = io.Copy(&bufR, txJob.Fd); err != nil {
+               if _, err = io.Copy(&bufR, fd); err != nil {
                        panic(err)
                }
                var bufW bytes.Buffer
                vias := append(nodeTgt.Via, nodeTgt.Id)
                for i, hopId := range vias {
                        hopOur := privates[*hopId]
-                       foundNode, _, err := PktEncRead(hopOur, ctx.Neigh, &bufR, &bufW)
+                       _, foundNode, _, err := PktEncRead(
+                               hopOur, ctx.Neigh, &bufR, &bufW, true, nil,
+                       )
                        if err != nil {
                                return false
                        }
@@ -136,7 +143,7 @@ func TestTx(t *testing.T) {
                                if pkt.Type != PktTypeTrns {
                                        return false
                                }
-                               if bytes.Compare(pkt.Path[:blake2b.Size256], vias[i+1][:]) != 0 {
+                               if bytes.Compare(pkt.Path[:MTHSize], vias[i+1][:]) != 0 {
                                        return false
                                }
                        }