From 6613bf116c920cc07145929897b78e34cb81992b Mon Sep 17 00:00:00 2001
From: "Richard T. Carback III" <rick.carback@gmail.com>
Date: Tue, 25 Oct 2022 19:17:43 +0000
Subject: [PATCH] Fix tests

---
 channels/joinedChannel_test.go | 39 +++++++++++++++++++++++++---------
 1 file changed, 29 insertions(+), 10 deletions(-)

diff --git a/channels/joinedChannel_test.go b/channels/joinedChannel_test.go
index e26807719..5b77b6a01 100644
--- a/channels/joinedChannel_test.go
+++ b/channels/joinedChannel_test.go
@@ -11,6 +11,13 @@ import (
 	"bytes"
 	"crypto/ed25519"
 	"encoding/binary"
+	"math/rand"
+	"reflect"
+	"sort"
+	"strconv"
+	"testing"
+	"time"
+
 	"gitlab.com/elixxir/client/broadcast"
 	clientCmix "gitlab.com/elixxir/client/cmix"
 	"gitlab.com/elixxir/client/cmix/message"
@@ -24,12 +31,6 @@ import (
 	"gitlab.com/xx_network/crypto/csprng"
 	"gitlab.com/xx_network/primitives/id"
 	"gitlab.com/xx_network/primitives/id/ephemeral"
-	"math/rand"
-	"reflect"
-	"sort"
-	"strconv"
-	"testing"
-	"time"
 )
 
 // Tests that manager.store stores the channel list in the ekv.
@@ -143,9 +144,19 @@ func Test_manager_loadChannels(t *testing.T) {
 			t.Errorf("Channel %s does not exist.", &chID)
 		}
 
-		if !reflect.DeepEqual(ch.broadcast, loadedCh.broadcast) {
+		expected := ch.broadcast.Get()
+		received := loadedCh.broadcast.Get()
+
+		// NOTE: Times don't compare properly after
+		// marshalling due to the monotonic counter
+		if expected.Created.Equal(received.Created) {
+			expected.Created = received.Created
+		}
+
+		if !reflect.DeepEqual(expected, received) {
 			t.Errorf("Channel %s does not match loaded channel."+
-				"\nexpected: %+v\nreceived: %+v", &chID, ch.broadcast, loadedCh.broadcast)
+				"\nexpected: %+v\nreceived: %+v", &chID,
+				expected, received)
 		}
 	}
 }
@@ -507,9 +518,17 @@ func Test_loadJoinedChannel(t *testing.T) {
 		t.Errorf("Failed to load joinedChannel: %+v", err)
 	}
 
-	if !reflect.DeepEqual(ch, loadedJc.broadcast.Get()) {
+	expected := *ch
+	received := *loadedJc.broadcast.Get()
+	// NOTE: Times don't compare properly after marshalling due to the
+	// monotonic counter
+	if expected.Created.Equal(received.Created) {
+		expected.Created = received.Created
+	}
+
+	if !reflect.DeepEqual(expected, received) {
 		t.Errorf("Loaded joinedChannel does not match original."+
-			"\nexpected: %+v\nreceived: %+v", ch, loadedJc.broadcast.Get())
+			"\nexpected: %+v\nreceived: %+v", expected, received)
 	}
 }
 
-- 
GitLab