From b7105f9b9f64fa12fed6ca2fb2d52ab80584a560 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?rich=CE=9Brd?= Date: Thu, 30 Nov 2023 14:48:55 -0400 Subject: [PATCH] refactor: reuse query and cursor instead of specifying each pb field (#937) --- waku/v2/protocol/store/waku_store_client.go | 18 ++---------------- .../protocol/store/waku_store_protocol_test.go | 2 +- 2 files changed, 3 insertions(+), 17 deletions(-) diff --git a/waku/v2/protocol/store/waku_store_client.go b/waku/v2/protocol/store/waku_store_client.go index fb2d2e95..56e7b52a 100644 --- a/waku/v2/protocol/store/waku_store_client.go +++ b/waku/v2/protocol/store/waku_store_client.go @@ -452,23 +452,9 @@ func (store *WakuStore) Next(ctx context.Context, r *Result) (*Result, error) { historyRequest := &pb.HistoryRPC{ RequestId: hex.EncodeToString(protocol.GenerateRequestID()), - Query: &pb.HistoryQuery{ - PubsubTopic: r.Query().PubsubTopic, - ContentFilters: r.Query().ContentFilters, - StartTime: r.Query().StartTime, - EndTime: r.Query().EndTime, - PagingInfo: &pb.PagingInfo{ - PageSize: r.Query().PagingInfo.PageSize, - Direction: r.Query().PagingInfo.Direction, - Cursor: &pb.Index{ - Digest: r.Cursor().Digest, - ReceiverTime: r.Cursor().ReceiverTime, - SenderTime: r.Cursor().SenderTime, - PubsubTopic: r.Cursor().PubsubTopic, - }, - }, - }, + Query: r.Query(), } + historyRequest.Query.PagingInfo.Cursor = r.Cursor() response, err := store.queryFrom(ctx, historyRequest, r.PeerID()) if err != nil { diff --git a/waku/v2/protocol/store/waku_store_protocol_test.go b/waku/v2/protocol/store/waku_store_protocol_test.go index ed034b55..5b67ed72 100644 --- a/waku/v2/protocol/store/waku_store_protocol_test.go +++ b/waku/v2/protocol/store/waku_store_protocol_test.go @@ -79,7 +79,7 @@ func TestWakuStoreProtocolQuery(t *testing.T) { require.NoError(t, err) require.Len(t, response.Messages, 1) - require.Equal(t, msg, response.Messages[0]) + require.True(t, proto.Equal(msg, response.Messages[0])) } func TestWakuStoreProtocolLocalQuery(t *testing.T) {