diff --git a/pkg/node/node_test.go b/pkg/node/node_test.go index 6f445f1d..3f35ce23 100644 --- a/pkg/node/node_test.go +++ b/pkg/node/node_test.go @@ -12,7 +12,7 @@ func TestNodes_Add(t *testing.T) { const nNodes = 10000 for i := 0; i < nNodes; i++ { 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) } if n.Len() != nNodes { @@ -26,7 +26,7 @@ func TestNodes_DeleteByID(t *testing.T) { var e error for i := 0; i < nNodes; i++ { var nn *Node - nn, _ = New(nil, nil, nil, transport.NewSim(0)) + nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0)) n.Add(nn) } for i := range n { @@ -42,7 +42,7 @@ func TestNodes_DeleteByAddrPort(t *testing.T) { var e error for i := 0; i < nNodes; i++ { var nn *Node - nn, _ = New(nil, nil, nil, transport.NewSim(0)) + nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0)) n.Add(nn) } for i := range n { @@ -57,7 +57,7 @@ func TestNodes_FindByID(t *testing.T) { const nNodes = 10000 for i := 0; i < nNodes; i++ { var nn *Node - nn, _ = New(nil, nil, nil, transport.NewSim(0)) + nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0)) n.Add(nn) } for i := range n { @@ -73,7 +73,7 @@ func TestNodes_FindByAddrPort(t *testing.T) { const nNodes = 10000 for i := 0; i < nNodes; i++ { var nn *Node - nn, _ = New(nil, nil, nil, transport.NewSim(0)) + nn, _ = New(nil, nil, nil, nil, nil, transport.NewSim(0)) n.Add(nn) } for i := range n { diff --git a/pkg/slice/slice.go b/pkg/slice/slice.go index 96c8ca01..06090fbf 100644 --- a/pkg/slice/slice.go +++ b/pkg/slice/slice.go @@ -7,6 +7,8 @@ package slice import ( "crypto/rand" "encoding/binary" + "fmt" + "net/netip" "reflect" "unsafe" @@ -234,3 +236,16 @@ func (u U64Slice) ToMessage() (m Bytes) { header.Cap = mLen 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 +} diff --git a/pkg/testutils/testutils.go b/pkg/testutils/testutils.go index 131d698e..f8529269 100644 --- a/pkg/testutils/testutils.go +++ b/pkg/testutils/testutils.go @@ -2,14 +2,11 @@ package testutils import ( "crypto/rand" - "fmt" - "net/netip" "github.com/Indra-Labs/indra" "github.com/Indra-Labs/indra/pkg/key/prv" "github.com/Indra-Labs/indra/pkg/key/pub" "github.com/Indra-Labs/indra/pkg/sha256" - "github.com/Indra-Labs/indra/pkg/slice" 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) 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 -} diff --git a/pkg/wire/onion_test.go b/pkg/wire/onion_test.go index d8af07f7..62a6a3ae 100644 --- a/pkg/wire/onion_test.go +++ b/pkg/wire/onion_test.go @@ -9,7 +9,6 @@ import ( "github.com/Indra-Labs/indra/pkg/node" "github.com/Indra-Labs/indra/pkg/nonce" "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/wire/confirmation" "github.com/Indra-Labs/indra/pkg/wire/forward" @@ -29,7 +28,7 @@ func TestPing(t *testing.T) { prv1, prv2 := GetTwoPrvKeys(t) pub1, pub2 := pub.Derive(prv1), pub.Derive(prv2) var n nonce.ID - hop[i], n = node.New(testutils.GenerateRandomAddrPortIPv4(), + hop[i], n = node.New(slice.GenerateRandomAddrPortIPv4(), pub1, pub2, prv1, prv2, nil) _ = n } @@ -37,7 +36,7 @@ func TestPing(t *testing.T) { cpub1, cpub2 := pub.Derive(cprv1), pub.Derive(cprv2) var n nonce.ID var client *node.Node - client, n = node.New(testutils.GenerateRandomAddrPortIPv4(), + client, n = node.New(slice.GenerateRandomAddrPortIPv4(), cpub1, cpub2, cprv1, cprv2, nil) on := Ping(n, client, hop, ks) b := EncodeOnion(on) diff --git a/version.go b/version.go index 6c224316..9dedafe6 100644 --- a/version.go +++ b/version.go @@ -10,11 +10,11 @@ var ( // GitRef is the gitref, as in refs/heads/branchname. GitRef = "refs/heads/main" // ParentGitCommit is the commit hash of the parent HEAD. - ParentGitCommit = "57575b09b08dc97c8e281d3433d032905ddeb485" + ParentGitCommit = "55481bcb3e6bb110675f4e0503699775631d1a66" // 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 = "v0.0.240" + SemVer = "v0.0.242" // PathBase is the path base returned from runtime caller. PathBase = "/home/loki/src/github.com/Indra-Labs/indra/" // Major is the major number from the tag. @@ -22,7 +22,7 @@ var ( // Minor is the minor number from the tag. Minor = 0 // Patch is the patch version number from the tag. - Patch = 240 + Patch = 242 ) // Version returns a pretty printed version information string.