Test now ensures that expected hops are found in correct order
This commit is contained in:
@@ -81,6 +81,9 @@ func TestClient_GenerateCircuit(t *testing.T) {
|
||||
// Create the onion
|
||||
var lastMsg ifc.Message
|
||||
lastMsg, _, e = testutils.GenerateTestMessage(32)
|
||||
original := make([]byte, 32)
|
||||
copy(original, lastMsg)
|
||||
// log.I.S(lastMsg)
|
||||
// log.I.Ln(len(ci.Hops))
|
||||
for i := range ci.Hops {
|
||||
// progress through the hops in reverse
|
||||
@@ -106,14 +109,14 @@ func TestClient_GenerateCircuit(t *testing.T) {
|
||||
t.FailNow()
|
||||
}
|
||||
_, _ = to, from
|
||||
log.I.S("lastMsg", lastMsg)
|
||||
// log.I.S("lastMsg", lastMsg)
|
||||
}
|
||||
// now unwrap the message
|
||||
for c := 0; c < ReturnLen; c++ {
|
||||
|
||||
var to address.Cloaked
|
||||
var from *pub.Key
|
||||
log.I.S("unwrapping", c, lastMsg)
|
||||
// log.I.S("unwrapping", c, lastMsg)
|
||||
if to, from, e = packet.GetKeys(lastMsg); check(e) {
|
||||
t.Error(e)
|
||||
t.FailNow()
|
||||
@@ -124,13 +127,17 @@ func TestClient_GenerateCircuit(t *testing.T) {
|
||||
for i := range rcvrs {
|
||||
if rcvrs[i].Match(to) {
|
||||
match = rcvrs[i]
|
||||
log.I.S(rcvrs[i].Pub)
|
||||
// log.I.S(rcvrs[i].Pub)
|
||||
hop := rcvrs[i].Pub
|
||||
cct := cl.Circuits[0].Hops
|
||||
for j := range cct {
|
||||
if cct[j].Key.Equals(hop) {
|
||||
log.I.Ln("found hop", j)
|
||||
log.I.Ln(cct[j].IP)
|
||||
// log.I.Ln("found hop", j)
|
||||
// log.I.Ln(cct[j].IP)
|
||||
if j != c {
|
||||
t.Error("did not find expected hop")
|
||||
t.FailNow()
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
@@ -143,13 +150,18 @@ func TestClient_GenerateCircuit(t *testing.T) {
|
||||
}
|
||||
var f *packet.Packet
|
||||
if f, e = packet.Decode(lastMsg, from, match.Key); check(e) {
|
||||
log.I.S()
|
||||
t.Error(e)
|
||||
t.FailNow()
|
||||
}
|
||||
rm := wire.Deserialize(f.Data)
|
||||
log.I.Ln(rm.IP)
|
||||
// log.I.Ln(rm.IP)
|
||||
// log.I.S(rm.Message)
|
||||
// log.I.Ln(lastMsg[0], net.IP(lastMsg[1:5]))
|
||||
lastMsg = rm.Message
|
||||
}
|
||||
if string(original) != string(lastMsg) {
|
||||
t.Error("failed to recover original message")
|
||||
t.FailNow()
|
||||
}
|
||||
// log.I.S(lastMsg)
|
||||
}
|
||||
|
||||
@@ -206,6 +206,6 @@ func Decode(d []byte, from *pub.Key, to *prv.Key) (f *Packet, e error) {
|
||||
f.Length = uint32(slice.DecodeUint32(length))
|
||||
f.Parity, data = data[0], data[1:]
|
||||
f.Data = data
|
||||
log.I.Ln("decode length", len(data), "length prefix", f.Length)
|
||||
// log.I.Ln("decode length", len(data), "length prefix", f.Length)
|
||||
return
|
||||
}
|
||||
|
||||
@@ -13,11 +13,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 = "c90c5949d0ec6b0ee570e6453fa41282ff7f068c"
|
||||
ParentGitCommit = "fc9afcd5681ab5b290ba00a7a511b193e9c3690b"
|
||||
// BuildTime stores the time when the current binary was built.
|
||||
BuildTime = "2022-12-03T13:07:49+01:00"
|
||||
BuildTime = "2022-12-03T13:20:41+01:00"
|
||||
// SemVer lists the (latest) git tag on the build.
|
||||
SemVer = "v0.0.143"
|
||||
SemVer = "v0.0.144"
|
||||
// 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.
|
||||
@@ -25,7 +25,7 @@ var (
|
||||
// Minor is the minor number from the tag.
|
||||
Minor = 0
|
||||
// Patch is the patch version number from the tag.
|
||||
Patch = 143
|
||||
Patch = 144
|
||||
)
|
||||
|
||||
// Version returns a pretty printed version information string.
|
||||
|
||||
Reference in New Issue
Block a user