From bfb3b1d302d7df4c93b15abea5cc76f5ec40bae0 Mon Sep 17 00:00:00 2001
From: Jake Taylor <jake@elixxir.io>
Date: Wed, 12 Oct 2022 13:01:27 -0500
Subject: [PATCH] enhance delete message test case

---
 indexedDb/implementation_test.go | 17 +++++++++--------
 1 file changed, 9 insertions(+), 8 deletions(-)

diff --git a/indexedDb/implementation_test.go b/indexedDb/implementation_test.go
index 12e9358a..61c55033 100644
--- a/indexedDb/implementation_test.go
+++ b/indexedDb/implementation_test.go
@@ -229,16 +229,17 @@ func TestWasmModel_deleteMsgByChannel(t *testing.T) {
 
 	// Store some test messages
 	cid := channel.Identity{}
-	for i := 0; i < expectedMessages; i++ {
-		testStr := testString + strconv.Itoa(i)
-		testMsgId := channel.MakeMessageID([]byte(testStr), &id.ID{1})
-		eventModel.ReceiveMessage(deleteChannel, testMsgId, testStr,
-			testStr, cid, time.Now(), time.Second, rounds.Round{ID: id.Round(0)}, 0, channels.Sent)
-	}
-	for i := expectedMessages; i < totalMessages; i++ {
+	for i := 0; i < totalMessages; i++ {
 		testStr := testString + strconv.Itoa(i)
+
+		// Interleave the channel id to ensure cursor is behaving intelligently
+		thisChannel := deleteChannel
+		if i%2 == 0 {
+			thisChannel = keepChannel
+		}
+
 		testMsgId := channel.MakeMessageID([]byte(testStr), &id.ID{1})
-		eventModel.ReceiveMessage(keepChannel, testMsgId, testStr,
+		eventModel.ReceiveMessage(thisChannel, testMsgId, testStr,
 			testStr, cid, time.Now(), time.Second, rounds.Round{ID: id.Round(0)}, 0, channels.Sent)
 	}
 
-- 
GitLab