From ee2e356a892ec3e64f3e38e3ea24d258a899b71c Mon Sep 17 00:00:00 2001
From: joshemb <josh@elixxir.io>
Date: Fri, 23 Sep 2022 13:59:19 -0700
Subject: [PATCH] Tests for identity store

---
 channels/identityStore_test.go | 46 ++++++++++++++++++++++++++++++++++
 1 file changed, 46 insertions(+)
 create mode 100644 channels/identityStore_test.go

diff --git a/channels/identityStore_test.go b/channels/identityStore_test.go
new file mode 100644
index 000000000..ec2d72f9b
--- /dev/null
+++ b/channels/identityStore_test.go
@@ -0,0 +1,46 @@
+////////////////////////////////////////////////////////////////////////////////
+// Copyright © 2022 xx foundation                                             //
+//                                                                            //
+// Use of this source code is governed by a license that can be found in the  //
+// LICENSE file                                                               //
+////////////////////////////////////////////////////////////////////////////////
+
+package channels
+
+import (
+	"bytes"
+	"encoding/base64"
+	"gitlab.com/elixxir/client/storage/versioned"
+	cryptoChannel "gitlab.com/elixxir/crypto/channel"
+	"gitlab.com/elixxir/ekv"
+	"gitlab.com/xx_network/crypto/csprng"
+	"testing"
+)
+
+func TestStoreLoadIdentity(t *testing.T) {
+	rng := &csprng.SystemRNG{}
+	privIdentity, err := cryptoChannel.GenerateIdentity(rng)
+	if err != nil {
+		t.Fatalf("GenerateIdentity error: %+v", err)
+	}
+
+	kv := versioned.NewKV(ekv.MakeMemstore())
+	err = storeIdentity(kv, privIdentity)
+	if err != nil {
+		t.Fatalf("storeIdentity error: %+v", err)
+	}
+
+	loadedIdentity, err := loadIdentity(kv)
+	if err != nil {
+		t.Fatalf("loadIdentity error: %+v", err)
+	}
+
+	if !bytes.Equal(loadedIdentity.Marshal(), privIdentity.Marshal()) {
+		t.Fatalf("Failed to load private identity."+
+			"\nExpected: %s"+
+			"\nReceived: %s",
+			base64.StdEncoding.EncodeToString(privIdentity.Marshal()),
+			base64.StdEncoding.EncodeToString(loadedIdentity.Marshal()))
+	}
+
+}
\ No newline at end of file
-- 
GitLab