X-Git-Url: http://www.git.cypherpunks.ru/?p=nncp.git;a=blobdiff_plain;f=src%2Ftx_test.go;h=20d20ee0d1b7907b6272822e8b4b1a369d5dd1a5;hp=85a00db69a416bbd6ae19cb6e9e5b569751f026f;hb=b47dbfe6687569650fa544a4ecf3e4ea388390cb;hpb=99c6aa8d7e77b37c58d9dc0c8f3f8ed6a94352f5 diff --git a/src/tx_test.go b/src/tx_test.go index 85a00db..20d20ee 100644 --- a/src/tx_test.go +++ b/src/tx_test.go @@ -19,11 +19,11 @@ package nncp import ( "bytes" + "crypto/rand" "io" "io/ioutil" "os" "path" - "strings" "testing" "testing/quick" @@ -31,12 +31,23 @@ import ( ) func TestTx(t *testing.T) { - f := func(hops uint8, pathSrc, data string, nice, replyNice uint8, padSize int16) bool { + f := func( + hops uint8, + pathSrc string, + dataSize uint32, + nice, replyNice uint8, + minSize uint32, + ) bool { + dataSize %= 1 << 20 + data := make([]byte, dataSize) + if _, err := io.ReadFull(rand.Reader, data); err != nil { + panic(err) + } + minSize %= 1 << 20 if len(pathSrc) > int(MaxPathSize) { pathSrc = pathSrc[:MaxPathSize] } hops = hops % 4 - hops = 1 spool, err := ioutil.TempDir("", "testtx") if err != nil { panic(err) @@ -75,13 +86,14 @@ func TestTx(t *testing.T) { nodeTgt.Via = append(nodeTgt.Via, node.Id) } pkt, err := NewPkt(PktTypeExec, replyNice, []byte(pathSrc)) - src := strings.NewReader(data) - dstNode, err := ctx.Tx( + src := bytes.NewReader(data) + dstNode, _, err := ctx.Tx( nodeTgt, pkt, 123, int64(src.Len()), - int64(padSize), + int64(minSize), + MaxFileSize, src, "pktName", nil,