improving types

This commit is contained in:
Gabriel mermelstein 2025-01-16 14:07:39 +01:00
parent 26ae2611b8
commit f9c54f0888
No known key found for this signature in database
GPG Key ID: 82B8134785FEAE0D
2 changed files with 22 additions and 22 deletions

View File

@ -1,16 +1,16 @@
package common
type StoreQueryRequest struct {
RequestId string `json:"request_id"`
IncludeData bool `json:"include_data"`
PubsubTopic string `json:"pubsub_topic,omitempty"`
ContentTopics []string `json:"content_topics,omitempty"`
TimeStart *int64 `json:"time_start,omitempty"`
TimeEnd *int64 `json:"time_end,omitempty"`
MessageHashes []MessageHash `json:"message_hashes,omitempty"`
PaginationCursor MessageHash `json:"pagination_cursor,omitempty"`
PaginationForward bool `json:"pagination_forward"`
PaginationLimit *uint64 `json:"pagination_limit,omitempty"`
RequestId string `json:"request_id"`
IncludeData bool `json:"include_data"`
PubsubTopic string `json:"pubsub_topic,omitempty"`
ContentTopics *[]string `json:"content_topics,omitempty"`
TimeStart *int64 `json:"time_start,omitempty"`
TimeEnd *int64 `json:"time_end,omitempty"`
MessageHashes *[]MessageHash `json:"message_hashes,omitempty"`
PaginationCursor MessageHash `json:"pagination_cursor,omitempty"`
PaginationForward bool `json:"pagination_forward"`
PaginationLimit *uint64 `json:"pagination_limit,omitempty"`
}
type StoreMessageResponse struct {
@ -20,9 +20,9 @@ type StoreMessageResponse struct {
}
type StoreQueryResponse struct {
RequestId string `json:"requestId,omitempty"`
StatusCode *uint32 `json:"statusCode,omitempty"`
StatusDesc string `json:"statusDesc,omitempty"`
Messages []StoreMessageResponse `json:"messages,omitempty"`
PaginationCursor MessageHash `json:"paginationCursor,omitempty"`
RequestId string `json:"requestId,omitempty"`
StatusCode *uint32 `json:"statusCode,omitempty"`
StatusDesc string `json:"statusDesc,omitempty"`
Messages *[]StoreMessageResponse `json:"messages,omitempty"`
PaginationCursor MessageHash `json:"paginationCursor,omitempty"`
}

View File

@ -750,7 +750,7 @@ func TestStore(t *testing.T) {
// Now send store query
storeReq1 := common.StoreQueryRequest{
IncludeData: true,
ContentTopics: []string{"test-content-topic"},
ContentTopics: &[]string{"test-content-topic"},
PaginationLimit: proto.Uint64(uint64(paginationLimit)),
PaginationForward: true,
TimeStart: timeStart,
@ -765,7 +765,7 @@ func TestStore(t *testing.T) {
res1, err := senderNode.StoreQuery(ctx3, &storeReq1, *storeNodeAddrInfo)
require.NoError(t, err)
storedMessages1 := res1.Messages
storedMessages1 := *res1.Messages
for i := 0; i < paginationLimit; i++ {
require.True(t, storedMessages1[i].MessageHash == hashes[i], fmt.Sprintf("Stored message does not match received message for index %d", i))
}
@ -773,7 +773,7 @@ func TestStore(t *testing.T) {
// Now let's query the second page
storeReq2 := common.StoreQueryRequest{
IncludeData: true,
ContentTopics: []string{"test-content-topic"},
ContentTopics: &[]string{"test-content-topic"},
PaginationLimit: proto.Uint64(uint64(paginationLimit)),
PaginationForward: true,
TimeStart: timeStart,
@ -786,7 +786,7 @@ func TestStore(t *testing.T) {
res2, err := senderNode.StoreQuery(ctx4, &storeReq2, *storeNodeAddrInfo)
require.NoError(t, err)
storedMessages2 := res2.Messages
storedMessages2 := *res2.Messages
for i := 0; i < len(storedMessages2); i++ {
require.True(t, storedMessages2[i].MessageHash == hashes[i+paginationLimit], fmt.Sprintf("Stored message does not match received message for index %d", i))
}
@ -794,8 +794,8 @@ func TestStore(t *testing.T) {
// Now let's query for two specific message hashes
storeReq3 := common.StoreQueryRequest{
IncludeData: true,
ContentTopics: []string{"test-content-topic"},
MessageHashes: []common.MessageHash{hashes[0], hashes[2]},
ContentTopics: &[]string{"test-content-topic"},
MessageHashes: &[]common.MessageHash{hashes[0], hashes[2]},
}
ctx5, cancel5 := context.WithTimeout(context.Background(), requestTimeout)
@ -804,7 +804,7 @@ func TestStore(t *testing.T) {
res3, err := senderNode.StoreQuery(ctx5, &storeReq3, *storeNodeAddrInfo)
require.NoError(t, err)
storedMessages3 := res3.Messages
storedMessages3 := *res3.Messages
require.True(t, storedMessages3[0].MessageHash == hashes[0], "Stored message does not match queried message")
require.True(t, storedMessages3[1].MessageHash == hashes[2], "Stored message does not match queried message")