Skip to content
Snippets Groups Projects
Commit ce273f56 authored by Jono Wenger's avatar Jono Wenger
Browse files

Fix tests

parent 8b4c4243
No related branches found
No related tags found
No related merge requests found
......@@ -11,17 +11,20 @@ import (
func TestGenerateFakeIdentity(t *testing.T) {
rng := rand.New(rand.NewSource(42))
end, _ := json.Marshal(time.Unix(0, 1258494203759765625))
startValid, _ := json.Marshal(time.Unix(0, 1258407803759765625))
endValid, _ := json.Marshal(time.Unix(0, 1258494203759765625))
expected := "{\"EphId\":[0,0,0,0,0,0,46,197]," +
"\"Source\":[83,140,127,150,177,100,191,27,151,187,159,75,180,114," +
"232,159,91,20,132,242,82,9,201,217,52,62,146,186,9,221,157,82,3]," +
"\"End\":\"2009-11-17T13:43:23.759765625-08:00\",\"ExtraChecks\":0,"+
"\"StartValid\":\"2009-11-16T13:43:23.759765625-08:00\"," +
"\"EndValid\":\"2009-11-17T13:43:23.759765625-08:00\"," +
"\"End\":" + string(end) + ",\"ExtraChecks\":0," +
"\"StartValid\":" + string(startValid) + "," +
"\"EndValid\":" + string(endValid) + "," +
"\"RequestMask\":86400000000000,\"Ephemeral\":true," +
"\"StartRequest\":\"0001-01-01T00:00:00Z\"," +
"\"EndRequest\":\"0001-01-01T00:00:00Z\",\"Fake\":true,\"KR\":null}"
timestamp := time.Date(2009, 11, 17, 20,
34, 58, 651387237, time.UTC)
......
......@@ -48,7 +48,6 @@ func loadIdentity(kv *versioned.KV)(Identity, error){
return r, nil
}
func (i Identity) store(kv *versioned.KV) error {
//marshal the registration
regStr, err := json.Marshal(&i)
......@@ -84,3 +83,14 @@ func (i *Identity)String()string{
return strconv.FormatInt(i.EphId.Int64(), 16) + " " + i.Source.String()
}
func (i Identity) Equal(b Identity) bool {
return i.EphId == b.EphId &&
i.Source.Cmp(b.Source) &&
i.End.Equal(b.End) &&
i.ExtraChecks == b.ExtraChecks &&
i.StartValid.Equal(b.StartValid) &&
i.EndValid.Equal(b.EndValid) &&
i.RequestMask == b.RequestMask &&
i.Ephemeral == b.Ephemeral
}
......@@ -6,7 +6,6 @@ import (
"gitlab.com/xx_network/primitives/id"
"gitlab.com/xx_network/primitives/id/ephemeral"
"math/rand"
"reflect"
"testing"
"time"
)
......@@ -34,7 +33,7 @@ func TestIdentity_EncodeDecode(t *testing.T) {
t.Errorf("Failed to load: %s", err)
}
if !reflect.DeepEqual(r, rLoad){
if !r.Equal(rLoad) {
t.Errorf("The two registrations are not the same\n saved: %+v\n loaded: %+v", r, rLoad)
}
}
......@@ -68,7 +67,6 @@ func TestIdentity_Delete(t *testing.T) {
}
}
func TestIdentity_String(t *testing.T) {
rng := rand.New(rand.NewSource(42))
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment