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

add unit test of generation of connection fingerprints

parent 7de5e3cd
No related branches found
No related tags found
2 merge requests!65Updates for Channel Support,!37Restructure
package e2e
import (
"bytes"
"golang.org/x/crypto/blake2b"
"testing"
)
// Unit test of GenerateConnectionFingerprint.
func TestGenerateConnectionFingerprint(t *testing.T) {
receiveFp := []byte{5}
sendFp := []byte{10}
h, _ := blake2b.New256(nil)
h.Write(append(receiveFp, sendFp...))
expected := h.Sum(nil)
fp := GenerateConnectionFingerprint(sendFp, receiveFp)
if !bytes.Equal(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.
receiveFp, sendFp = sendFp, receiveFp
fp = GenerateConnectionFingerprint(sendFp, receiveFp)
if !bytes.Equal(fp, expected) {
t.Errorf("ConnectionFingerprint did not return the expected "+
"fingerprint.\nexpected: %s\nreceived: %s", expected, fp)
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment