Fixed broken tests
This commit is contained in:
@@ -12,7 +12,7 @@ func TestNodes_Add(t *testing.T) {
|
|||||||
const nNodes = 10000
|
const nNodes = 10000
|
||||||
for i := 0; i < nNodes; i++ {
|
for i := 0; i < nNodes; i++ {
|
||||||
var nn *Node
|
var nn *Node
|
||||||
nn, _ = New(nil, nil, nil, transport.NewSim(0))
|
nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0))
|
||||||
n = n.Add(nn)
|
n = n.Add(nn)
|
||||||
}
|
}
|
||||||
if n.Len() != nNodes {
|
if n.Len() != nNodes {
|
||||||
@@ -26,7 +26,7 @@ func TestNodes_DeleteByID(t *testing.T) {
|
|||||||
var e error
|
var e error
|
||||||
for i := 0; i < nNodes; i++ {
|
for i := 0; i < nNodes; i++ {
|
||||||
var nn *Node
|
var nn *Node
|
||||||
nn, _ = New(nil, nil, nil, transport.NewSim(0))
|
nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0))
|
||||||
n.Add(nn)
|
n.Add(nn)
|
||||||
}
|
}
|
||||||
for i := range n {
|
for i := range n {
|
||||||
@@ -42,7 +42,7 @@ func TestNodes_DeleteByAddrPort(t *testing.T) {
|
|||||||
var e error
|
var e error
|
||||||
for i := 0; i < nNodes; i++ {
|
for i := 0; i < nNodes; i++ {
|
||||||
var nn *Node
|
var nn *Node
|
||||||
nn, _ = New(nil, nil, nil, transport.NewSim(0))
|
nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0))
|
||||||
n.Add(nn)
|
n.Add(nn)
|
||||||
}
|
}
|
||||||
for i := range n {
|
for i := range n {
|
||||||
@@ -57,7 +57,7 @@ func TestNodes_FindByID(t *testing.T) {
|
|||||||
const nNodes = 10000
|
const nNodes = 10000
|
||||||
for i := 0; i < nNodes; i++ {
|
for i := 0; i < nNodes; i++ {
|
||||||
var nn *Node
|
var nn *Node
|
||||||
nn, _ = New(nil, nil, nil, transport.NewSim(0))
|
nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0))
|
||||||
n.Add(nn)
|
n.Add(nn)
|
||||||
}
|
}
|
||||||
for i := range n {
|
for i := range n {
|
||||||
@@ -73,7 +73,7 @@ func TestNodes_FindByAddrPort(t *testing.T) {
|
|||||||
const nNodes = 10000
|
const nNodes = 10000
|
||||||
for i := 0; i < nNodes; i++ {
|
for i := 0; i < nNodes; i++ {
|
||||||
var nn *Node
|
var nn *Node
|
||||||
nn, _ = New(nil, nil, nil, transport.NewSim(0))
|
nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0))
|
||||||
n.Add(nn)
|
n.Add(nn)
|
||||||
}
|
}
|
||||||
for i := range n {
|
for i := range n {
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ package slice
|
|||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"encoding/binary"
|
"encoding/binary"
|
||||||
|
"fmt"
|
||||||
|
"net/netip"
|
||||||
"reflect"
|
"reflect"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
@@ -234,3 +236,16 @@ func (u U64Slice) ToMessage() (m Bytes) {
|
|||||||
header.Cap = mLen
|
header.Cap = mLen
|
||||||
return m
|
return m
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func GenerateRandomAddrPortIPv4() (ap *netip.AddrPort) {
|
||||||
|
a := netip.AddrPort{}
|
||||||
|
b := make([]byte, 7)
|
||||||
|
_, e := rand.Read(b)
|
||||||
|
if check(e) {
|
||||||
|
log.E.Ln(e)
|
||||||
|
}
|
||||||
|
port := DecodeUint16(b[5:7])
|
||||||
|
str := fmt.Sprintf("%d.%d.%d.%d:%d", b[1], b[2], b[3], b[4], port)
|
||||||
|
a, e = netip.ParseAddrPort(str)
|
||||||
|
return &a
|
||||||
|
}
|
||||||
|
|||||||
@@ -2,14 +2,11 @@ package testutils
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
|
||||||
"net/netip"
|
|
||||||
|
|
||||||
"github.com/Indra-Labs/indra"
|
"github.com/Indra-Labs/indra"
|
||||||
"github.com/Indra-Labs/indra/pkg/key/prv"
|
"github.com/Indra-Labs/indra/pkg/key/prv"
|
||||||
"github.com/Indra-Labs/indra/pkg/key/pub"
|
"github.com/Indra-Labs/indra/pkg/key/pub"
|
||||||
"github.com/Indra-Labs/indra/pkg/sha256"
|
"github.com/Indra-Labs/indra/pkg/sha256"
|
||||||
"github.com/Indra-Labs/indra/pkg/slice"
|
|
||||||
log2 "github.com/cybriq/proc/pkg/log"
|
log2 "github.com/cybriq/proc/pkg/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -40,16 +37,3 @@ func GenerateTestKeyPairs() (sp, rp *prv.Key, sP, rP *pub.Key, e error) {
|
|||||||
rP = pub.Derive(rp)
|
rP = pub.Derive(rp)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
func GenerateRandomAddrPortIPv4() (ap *netip.AddrPort) {
|
|
||||||
a := netip.AddrPort{}
|
|
||||||
b := make([]byte, 7)
|
|
||||||
_, e := rand.Read(b)
|
|
||||||
if check(e) {
|
|
||||||
log.E.Ln(e)
|
|
||||||
}
|
|
||||||
port := slice.DecodeUint16(b[5:7])
|
|
||||||
str := fmt.Sprintf("%d.%d.%d.%d:%d", b[1], b[2], b[3], b[4], port)
|
|
||||||
a, e = netip.ParseAddrPort(str)
|
|
||||||
return &a
|
|
||||||
}
|
|
||||||
|
|||||||
@@ -9,7 +9,6 @@ import (
|
|||||||
"github.com/Indra-Labs/indra/pkg/node"
|
"github.com/Indra-Labs/indra/pkg/node"
|
||||||
"github.com/Indra-Labs/indra/pkg/nonce"
|
"github.com/Indra-Labs/indra/pkg/nonce"
|
||||||
"github.com/Indra-Labs/indra/pkg/slice"
|
"github.com/Indra-Labs/indra/pkg/slice"
|
||||||
"github.com/Indra-Labs/indra/pkg/testutils"
|
|
||||||
"github.com/Indra-Labs/indra/pkg/types"
|
"github.com/Indra-Labs/indra/pkg/types"
|
||||||
"github.com/Indra-Labs/indra/pkg/wire/confirmation"
|
"github.com/Indra-Labs/indra/pkg/wire/confirmation"
|
||||||
"github.com/Indra-Labs/indra/pkg/wire/forward"
|
"github.com/Indra-Labs/indra/pkg/wire/forward"
|
||||||
@@ -29,7 +28,7 @@ func TestPing(t *testing.T) {
|
|||||||
prv1, prv2 := GetTwoPrvKeys(t)
|
prv1, prv2 := GetTwoPrvKeys(t)
|
||||||
pub1, pub2 := pub.Derive(prv1), pub.Derive(prv2)
|
pub1, pub2 := pub.Derive(prv1), pub.Derive(prv2)
|
||||||
var n nonce.ID
|
var n nonce.ID
|
||||||
hop[i], n = node.New(testutils.GenerateRandomAddrPortIPv4(),
|
hop[i], n = node.New(slice.GenerateRandomAddrPortIPv4(),
|
||||||
pub1, pub2, prv1, prv2, nil)
|
pub1, pub2, prv1, prv2, nil)
|
||||||
_ = n
|
_ = n
|
||||||
}
|
}
|
||||||
@@ -37,7 +36,7 @@ func TestPing(t *testing.T) {
|
|||||||
cpub1, cpub2 := pub.Derive(cprv1), pub.Derive(cprv2)
|
cpub1, cpub2 := pub.Derive(cprv1), pub.Derive(cprv2)
|
||||||
var n nonce.ID
|
var n nonce.ID
|
||||||
var client *node.Node
|
var client *node.Node
|
||||||
client, n = node.New(testutils.GenerateRandomAddrPortIPv4(),
|
client, n = node.New(slice.GenerateRandomAddrPortIPv4(),
|
||||||
cpub1, cpub2, cprv1, cprv2, nil)
|
cpub1, cpub2, cprv1, cprv2, nil)
|
||||||
on := Ping(n, client, hop, ks)
|
on := Ping(n, client, hop, ks)
|
||||||
b := EncodeOnion(on)
|
b := EncodeOnion(on)
|
||||||
|
|||||||
@@ -10,11 +10,11 @@ var (
|
|||||||
// GitRef is the gitref, as in refs/heads/branchname.
|
// GitRef is the gitref, as in refs/heads/branchname.
|
||||||
GitRef = "refs/heads/main"
|
GitRef = "refs/heads/main"
|
||||||
// ParentGitCommit is the commit hash of the parent HEAD.
|
// ParentGitCommit is the commit hash of the parent HEAD.
|
||||||
ParentGitCommit = "57575b09b08dc97c8e281d3433d032905ddeb485"
|
ParentGitCommit = "55481bcb3e6bb110675f4e0503699775631d1a66"
|
||||||
// BuildTime stores the time when the current binary was built.
|
// BuildTime stores the time when the current binary was built.
|
||||||
BuildTime = "2022-12-27T14:11:54Z"
|
BuildTime = "2022-12-27T14:19:23Z"
|
||||||
// SemVer lists the (latest) git tag on the build.
|
// SemVer lists the (latest) git tag on the build.
|
||||||
SemVer = "v0.0.240"
|
SemVer = "v0.0.242"
|
||||||
// PathBase is the path base returned from runtime caller.
|
// PathBase is the path base returned from runtime caller.
|
||||||
PathBase = "/home/loki/src/github.com/Indra-Labs/indra/"
|
PathBase = "/home/loki/src/github.com/Indra-Labs/indra/"
|
||||||
// Major is the major number from the tag.
|
// Major is the major number from the tag.
|
||||||
@@ -22,7 +22,7 @@ var (
|
|||||||
// Minor is the minor number from the tag.
|
// Minor is the minor number from the tag.
|
||||||
Minor = 0
|
Minor = 0
|
||||||
// Patch is the patch version number from the tag.
|
// Patch is the patch version number from the tag.
|
||||||
Patch = 240
|
Patch = 242
|
||||||
)
|
)
|
||||||
|
|
||||||
// Version returns a pretty printed version information string.
|
// Version returns a pretty printed version information string.
|
||||||
|
|||||||
Reference in New Issue
Block a user