refactor(tests): group waku store test suite files

This commit is contained in:
Lorenzo Delgado 2023-01-27 14:31:58 +01:00 committed by GitHub
parent 93a07babf2
commit a590575a6a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 50 additions and 45 deletions

View File

@ -1,11 +1,11 @@
## Waku common test suite
import
# Waku common test suite
./v2/test_envvar_serialization,
./v2/test_confutils_envvar,
./v2/test_sqlite_migrations
## Waku archive test suite
import
# Waku archive test suite
./v2/waku_archive/test_driver_queue_index,
./v2/waku_archive/test_driver_queue_pagination,
./v2/waku_archive/test_driver_queue_query,
@ -15,14 +15,21 @@ import
./v2/waku_archive/test_retention_policy,
./v2/waku_archive/test_waku_archive
## Waku store test suite
import
./v2/waku_store/test_rpc_codec,
./v2/waku_store/test_waku_store,
./v2/waku_store/test_wakunode_store
when defined(waku_exp_store_resume):
# TODO: Review store resume test cases (#1282)
import ./v2/waku_store/test_resume
import
# Waku v2 tests
./v2/test_wakunode,
./v2/test_wakunode_relay,
# Waku Store
./v2/test_waku_store_rpc_codec,
./v2/test_waku_store,
./v2/test_wakunode_store,
# Waku LightPush
./v2/test_waku_lightpush,
./v2/test_wakunode_lightpush,
@ -66,9 +73,6 @@ when defined(rln):
./v2/test_wakunode_rln_relay,
./v2/test_waku_rln_relay_onchain
when defined(waku_exp_store_resume):
# TODO: Review store resume test cases (#1282)
import ./v2/test_waku_store_resume
# TODO: Only enable this once swap module is integrated more nicely as a dependency, i.e. as submodule with CI etc

View File

@ -5,14 +5,15 @@ import
testutils/unittests,
chronos
import
../../waku/v2/protocol/waku_store/rpc,
../../waku/v2/protocol/waku_store/rpc_codec,
../../waku/v2/utils/time,
./testlib/common
../../../waku/common/protobuf,
../../../waku/v2/protocol/waku_store/rpc,
../../../waku/v2/protocol/waku_store/rpc_codec,
../../../waku/v2/utils/time,
../testlib/common
procSuite "Waku Store - RPC codec":
test "PagingIndexRPC protobuf codec":
## Given
let index = PagingIndexRPC.compute(fakeWakuMessage(), receivedTime=ts(), pubsubTopic=DefaultPubsubTopic)
@ -24,7 +25,7 @@ procSuite "Waku Store - RPC codec":
## Then
check:
decodedIndexRes.isOk()
let decodedIndex = decodedIndexRes.tryGet()
check:
# The fields of decodedIndex must be the same as the original index
@ -33,14 +34,14 @@ procSuite "Waku Store - RPC codec":
test "PagingIndexRPC protobuf codec - empty index":
## Given
let emptyIndex = PagingIndexRPC()
let encodedIndex = emptyIndex.encode()
let decodedIndexRes = PagingIndexRPC.decode(encodedIndex.buffer)
## Then
check:
decodedIndexRes.isOk()
let decodedIndex = decodedIndexRes.tryGet()
check:
# Check the correctness of init and encode for an empty PagingIndexRPC
@ -51,7 +52,7 @@ procSuite "Waku Store - RPC codec":
let
index = PagingIndexRPC.compute(fakeWakuMessage(), receivedTime=ts(), pubsubTopic=DefaultPubsubTopic)
pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.FORWARD))
## When
let pb = pagingInfo.encode()
let decodedPagingInfo = PagingInfoRPC.decode(pb.buffer)
@ -64,11 +65,11 @@ procSuite "Waku Store - RPC codec":
# The fields of decodedPagingInfo must be the same as the original pagingInfo
decodedPagingInfo.value == pagingInfo
decodedPagingInfo.value.direction == pagingInfo.direction
test "PagingInfoRPC protobuf codec - empty paging info":
## Given
let emptyPagingInfo = PagingInfoRPC()
## When
let pb = emptyPagingInfo.encode()
let decodedEmptyPagingInfo = PagingInfoRPC.decode(pb.buffer)
@ -80,7 +81,7 @@ procSuite "Waku Store - RPC codec":
check:
# check the correctness of init and encode for an empty PagingInfoRPC
decodedEmptyPagingInfo.value == emptyPagingInfo
test "HistoryQueryRPC protobuf codec":
## Given
let
@ -88,11 +89,11 @@ procSuite "Waku Store - RPC codec":
pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.BACKWARD))
query = HistoryQueryRPC(
contentFilters: @[HistoryContentFilterRPC(contentTopic: DefaultContentTopic), HistoryContentFilterRPC(contentTopic: DefaultContentTopic)],
pagingInfo: some(pagingInfo),
startTime: some(Timestamp(10)),
pagingInfo: some(pagingInfo),
startTime: some(Timestamp(10)),
endTime: some(Timestamp(11))
)
## When
let pb = query.encode()
let decodedQuery = HistoryQueryRPC.decode(pb.buffer)
@ -120,7 +121,7 @@ procSuite "Waku Store - RPC codec":
check:
# check the correctness of init and encode for an empty HistoryQueryRPC
decodedEmptyQuery.value == emptyQuery
test "HistoryResponseRPC protobuf codec":
## Given
let
@ -128,7 +129,7 @@ procSuite "Waku Store - RPC codec":
index = PagingIndexRPC.compute(message, receivedTime=ts(), pubsubTopic=DefaultPubsubTopic)
pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.BACKWARD))
res = HistoryResponseRPC(messages: @[message], pagingInfo: some(pagingInfo), error: HistoryResponseErrorRPC.INVALID_CURSOR)
## When
let pb = res.encode()
let decodedRes = HistoryResponseRPC.decode(pb.buffer)
@ -140,11 +141,11 @@ procSuite "Waku Store - RPC codec":
check:
# the fields of decoded response decodedRes must be the same as the original response res
decodedRes.value == res
test "HistoryResponseRPC protobuf codec - empty history response":
## Given
let emptyRes = HistoryResponseRPC()
## When
let pb = emptyRes.encode()
let decodedEmptyRes = HistoryResponseRPC.decode(pb.buffer)

View File

@ -7,12 +7,12 @@ import
chronicles,
libp2p/crypto/crypto
import
../../waku/v2/node/peer_manager/peer_manager,
../../waku/v2/protocol/waku_message,
../../waku/v2/protocol/waku_store,
../../waku/v2/protocol/waku_store/client,
./testlib/common,
./testlib/switch
../../../waku/v2/node/peer_manager/peer_manager,
../../../waku/v2/protocol/waku_message,
../../../waku/v2/protocol/waku_store,
../../../waku/v2/protocol/waku_store/client,
../testlib/common,
../testlib/switch

View File

@ -13,17 +13,17 @@ import
libp2p/protocols/pubsub/pubsub,
libp2p/protocols/pubsub/gossipsub
import
../../waku/common/sqlite,
../../waku/v2/node/peer_manager/peer_manager,
../../waku/v2/protocol/waku_message,
../../waku/v2/protocol/waku_archive,
../../waku/v2/protocol/waku_archive/driver/sqlite_driver,
../../waku/v2/protocol/waku_store,
../../waku/v2/protocol/waku_filter,
../../waku/v2/utils/peers,
../../waku/v2/utils/time,
../../waku/v2/node/waku_node,
./testlib/common
../../../waku/common/sqlite,
../../../waku/v2/node/peer_manager/peer_manager,
../../../waku/v2/protocol/waku_message,
../../../waku/v2/protocol/waku_archive,
../../../waku/v2/protocol/waku_archive/driver/sqlite_driver,
../../../waku/v2/protocol/waku_store,
../../../waku/v2/protocol/waku_filter,
../../../waku/v2/utils/peers,
../../../waku/v2/utils/time,
../../../waku/v2/node/waku_node,
../testlib/common
from std/times import getTime, toUnixFloat