refactor: reuse query and cursor instead of specifying each pb field (#937)

This commit is contained in:
richΛrd 2023-11-30 14:48:55 -04:00 committed by GitHub
parent e0be9857ef
commit b7105f9b9f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 17 deletions

View File

@ -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 {

View File

@ -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) {