Skip to content
Snippets Groups Projects
Commit b64155f9 authored by Jake Taylor's avatar Jake Taylor
Browse files

clean up e2e manager partner

parent 2773031b
No related branches found
No related tags found
3 merge requests!510Release,!207WIP: Client Restructure,!203Symmetric broadcast
...@@ -9,7 +9,6 @@ package partner ...@@ -9,7 +9,6 @@ package partner
import ( import (
"bytes" "bytes"
"encoding/base64"
"math/rand" "math/rand"
"reflect" "reflect"
"testing" "testing"
...@@ -23,7 +22,6 @@ import ( ...@@ -23,7 +22,6 @@ import (
"gitlab.com/elixxir/crypto/fastRNG" "gitlab.com/elixxir/crypto/fastRNG"
"gitlab.com/xx_network/crypto/csprng" "gitlab.com/xx_network/crypto/csprng"
"gitlab.com/xx_network/primitives/id" "gitlab.com/xx_network/primitives/id"
"golang.org/x/crypto/blake2b"
) )
// Tests happy path of newManager. // Tests happy path of newManager.
...@@ -336,73 +334,11 @@ func TestManager_TriggerNegotiations(t *testing.T) { ...@@ -336,73 +334,11 @@ func TestManager_TriggerNegotiations(t *testing.T) {
} }
} }
// Unit test of Manager.GetRelationshipFingerprint.
func TestManager_GetRelationshipFingerprint(t *testing.T) {
m, _ := newTestManager(t)
m.receive.fingerprint = []byte{5}
m.send.fingerprint = []byte{10}
h, _ := blake2b.New256(nil)
h.Write(append(m.receive.fingerprint, m.send.fingerprint...))
expected := base64.StdEncoding.EncodeToString(h.Sum(nil))[:relationshipFpLength]
fp := m.ConnectionFingerprint()
if fp != expected {
t.Errorf("ConnectionFingerprint did not return the expected "+
"fingerprint.\nexpected: %s\nreceived: %s", expected, fp)
}
// Flip the order and show that the output is the same.
m.receive.fingerprint, m.send.fingerprint = m.send.fingerprint, m.receive.fingerprint
fp = m.ConnectionFingerprint()
if fp != expected {
t.Errorf("ConnectionFingerprint did not return the expected "+
"fingerprint.\nexpected: %s\nreceived: %s", expected, fp)
}
}
// Tests the consistency of the output of Manager.GetRelationshipFingerprint.
func TestManager_GetRelationshipFingerprint_Consistency(t *testing.T) {
m, _ := newTestManager(t)
prng := rand.New(rand.NewSource(42))
expectedFps := []string{
"GmeTCfxGOqRqeID", "gbpJjHd3tIe8BKy", "2/ZdG+WNzODJBiF",
"+V1ySeDLQfQNSkv", "23OMC+rBmCk+gsu", "qHu5MUVs83oMqy8",
"kuXqxsezI0kS9Bc", "SlEhsoZ4BzAMTtr", "yG8m6SPQfV/sbTR",
"j01ZSSm762TH7mj", "SKFDbFvsPcohKPw", "6JB5HK8DHGwS4uX",
"dU3mS1ujduGD+VY", "BDXAy3trbs8P4mu", "I4HoXW45EwWR0oD",
"661YH2l2jfOkHbA", "cSS9ZyTOQKVx67a", "ojfubzDIsMNYc/t",
"2WrEw83Yz6Rhq9I", "TQILxBIUWMiQS2j", "rEqdieDTXJfCQ6I",
}
for i, expected := range expectedFps {
prng.Read(m.receive.fingerprint)
prng.Read(m.send.fingerprint)
fp := m.ConnectionFingerprint()
if fp != expected {
t.Errorf("ConnectionFingerprint did not return the expected "+
"fingerprint (%d).\nexpected: %s\nreceived: %s", i, expected, fp)
}
// Flip the order and show that the output is the same.
m.receive.fingerprint, m.send.fingerprint = m.send.fingerprint, m.receive.fingerprint
fp = m.ConnectionFingerprint()
if fp != expected {
t.Errorf("ConnectionFingerprint did not return the expected "+
"fingerprint (%d).\nexpected: %s\nreceived: %s", i, expected, fp)
}
// fmt.Printf("\"%s\",\n", fp) // Uncomment to reprint expected values
}
}
func TestManager_MakeService(t *testing.T) { func TestManager_MakeService(t *testing.T) {
m, _ := newTestManager(t) m, _ := newTestManager(t)
tag := "hunter2" tag := "hunter2"
expected := message.Service{ expected := message.Service{
Identifier: m.ConnectionFingerprintBytes(), Identifier: m.ConnectionFingerprint().Bytes(),
Tag: tag, Tag: tag,
Metadata: m.partner[:], Metadata: m.partner[:],
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment