]> Cypherpunks.ru repositories - nncp.git/blobdiff - src/cypherpunks.ru/nncp/tx_test.go
Remote command execution
[nncp.git] / src / cypherpunks.ru / nncp / tx_test.go
index c46f057789a7b21e6ba7c2c85259011613a63ac3..6ea7ef2cb7b9613c4e78fe7020f9c6420af794c7 100644 (file)
@@ -1,6 +1,6 @@
 /*
 NNCP -- Node to Node copy, utilities for store-and-forward data exchange
-Copyright (C) 2016-2017 Sergey Matveev <stargrave@stargrave.org>
+Copyright (C) 2016-2018 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
@@ -33,7 +33,7 @@ import (
 )
 
 func TestTx(t *testing.T) {
-       f := func(hops uint8, pathSrc, data string, nice uint8, padSize int16) bool {
+       f := func(hops uint8, pathSrc, data string, nice, replyNice uint8, padSize int16) bool {
                if len(pathSrc) > int(MaxPathSize) {
                        pathSrc = pathSrc[:MaxPathSize]
                }
@@ -58,6 +58,7 @@ func TestTx(t *testing.T) {
                        LogPath: path.Join(spool, "log.log"),
                        Debug:   true,
                        Self:    nodeOur,
+                       SelfId:  nodeOur.Id,
                        Neigh:   make(map[NodeId]*Node, hops),
                        Alias:   make(map[string]*NodeId),
                }
@@ -75,7 +76,7 @@ func TestTx(t *testing.T) {
                        privates[*node.Id] = node
                        nodeTgt.Via = append(nodeTgt.Via, node.Id)
                }
-               pkt, err := NewPkt(PktTypeMail, pathSrc)
+               pkt, err := NewPkt(PktTypeExec, replyNice, []byte(pathSrc))
                src := strings.NewReader(data)
                dstNode, err := ctx.Tx(
                        nodeTgt,
@@ -120,7 +121,10 @@ func TestTx(t *testing.T) {
                                return false
                        }
                        if *hopId == *nodeTgt.Id {
-                               if pkt.Type != PktTypeMail {
+                               if pkt.Type != PktTypeExec {
+                                       return false
+                               }
+                               if pkt.Nice != replyNice {
                                        return false
                                }
                                if !bytes.HasPrefix(pkt.Path[:], []byte(pathSrc)) {