Skip to content

Commit

Permalink
test: most recent timestamp and count of msg
Browse files Browse the repository at this point in the history
  • Loading branch information
harsh-98 committed Sep 19, 2023
1 parent 247e700 commit 9f8dbff
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion waku/persistence/store_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,10 @@ func TestStoreRetention(t *testing.T) {
require.Equal(t, "test5", dbResults[0].Message.ContentTopic)
require.Equal(t, "test6", dbResults[1].Message.ContentTopic)
require.Equal(t, "test7", dbResults[2].Message.ContentTopic)
// checking the number of all the message in the db
msgCount, err := store.Count()
require.NoError(t, err)
require.Equal(t, msgCount, 3)
}

func TestQuery(t *testing.T) {
Expand Down Expand Up @@ -129,7 +133,7 @@ func TestQuery(t *testing.T) {
require.NoError(t, err)
require.Len(t, msgs, 2)

_ = store.Put(protocol.NewEnvelope(tests.CreateWakuMessage("test5", insertTime.Add(time.Second).UnixNano()), insertTime.Add(-10*time.Second).UnixNano(), "test"))
_ = store.Put(protocol.NewEnvelope(tests.CreateWakuMessage("test5", insertTime.UnixNano()), insertTime.Add(-10*time.Second).UnixNano(), "test"))

// Range [cursor-endTime]
// Check: matching ContentTopic,pubsubTopic, pageSize
Expand Down Expand Up @@ -176,4 +180,9 @@ func TestQuery(t *testing.T) {
for ind, msg := range msgs {
require.Equal(t, msg.Message.ContentTopic, fmt.Sprintf("test%d", ind+2)) // test2,test3,test4
}

// checking most recent timestamp in db
timestamp, err := store.MostRecentTimestamp()
require.NoError(t, err)
require.Equal(t, timestamp, insertTime.UnixNano())
}

0 comments on commit 9f8dbff

Please sign in to comment.