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 import
# Waku common test suite
./v2/test_envvar_serialization, ./v2/test_envvar_serialization,
./v2/test_confutils_envvar, ./v2/test_confutils_envvar,
./v2/test_sqlite_migrations ./v2/test_sqlite_migrations
## Waku archive test suite
import import
# Waku archive test suite
./v2/waku_archive/test_driver_queue_index, ./v2/waku_archive/test_driver_queue_index,
./v2/waku_archive/test_driver_queue_pagination, ./v2/waku_archive/test_driver_queue_pagination,
./v2/waku_archive/test_driver_queue_query, ./v2/waku_archive/test_driver_queue_query,
@ -15,14 +15,21 @@ import
./v2/waku_archive/test_retention_policy, ./v2/waku_archive/test_retention_policy,
./v2/waku_archive/test_waku_archive ./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 import
# Waku v2 tests # Waku v2 tests
./v2/test_wakunode, ./v2/test_wakunode,
./v2/test_wakunode_relay, ./v2/test_wakunode_relay,
# Waku Store
./v2/test_waku_store_rpc_codec,
./v2/test_waku_store,
./v2/test_wakunode_store,
# Waku LightPush # Waku LightPush
./v2/test_waku_lightpush, ./v2/test_waku_lightpush,
./v2/test_wakunode_lightpush, ./v2/test_wakunode_lightpush,
@ -66,9 +73,6 @@ when defined(rln):
./v2/test_wakunode_rln_relay, ./v2/test_wakunode_rln_relay,
./v2/test_waku_rln_relay_onchain ./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 # 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, testutils/unittests,
chronos chronos
import import
../../waku/v2/protocol/waku_store/rpc, ../../../waku/common/protobuf,
../../waku/v2/protocol/waku_store/rpc_codec, ../../../waku/v2/protocol/waku_store/rpc,
../../waku/v2/utils/time, ../../../waku/v2/protocol/waku_store/rpc_codec,
./testlib/common ../../../waku/v2/utils/time,
../testlib/common
procSuite "Waku Store - RPC codec": procSuite "Waku Store - RPC codec":
test "PagingIndexRPC protobuf codec": test "PagingIndexRPC protobuf codec":
## Given ## Given
let index = PagingIndexRPC.compute(fakeWakuMessage(), receivedTime=ts(), pubsubTopic=DefaultPubsubTopic) let index = PagingIndexRPC.compute(fakeWakuMessage(), receivedTime=ts(), pubsubTopic=DefaultPubsubTopic)
@ -24,7 +25,7 @@ procSuite "Waku Store - RPC codec":
## Then ## Then
check: check:
decodedIndexRes.isOk() decodedIndexRes.isOk()
let decodedIndex = decodedIndexRes.tryGet() let decodedIndex = decodedIndexRes.tryGet()
check: check:
# The fields of decodedIndex must be the same as the original index # 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": test "PagingIndexRPC protobuf codec - empty index":
## Given ## Given
let emptyIndex = PagingIndexRPC() let emptyIndex = PagingIndexRPC()
let encodedIndex = emptyIndex.encode() let encodedIndex = emptyIndex.encode()
let decodedIndexRes = PagingIndexRPC.decode(encodedIndex.buffer) let decodedIndexRes = PagingIndexRPC.decode(encodedIndex.buffer)
## Then ## Then
check: check:
decodedIndexRes.isOk() decodedIndexRes.isOk()
let decodedIndex = decodedIndexRes.tryGet() let decodedIndex = decodedIndexRes.tryGet()
check: check:
# Check the correctness of init and encode for an empty PagingIndexRPC # Check the correctness of init and encode for an empty PagingIndexRPC
@ -51,7 +52,7 @@ procSuite "Waku Store - RPC codec":
let let
index = PagingIndexRPC.compute(fakeWakuMessage(), receivedTime=ts(), pubsubTopic=DefaultPubsubTopic) index = PagingIndexRPC.compute(fakeWakuMessage(), receivedTime=ts(), pubsubTopic=DefaultPubsubTopic)
pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.FORWARD)) pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.FORWARD))
## When ## When
let pb = pagingInfo.encode() let pb = pagingInfo.encode()
let decodedPagingInfo = PagingInfoRPC.decode(pb.buffer) 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 # The fields of decodedPagingInfo must be the same as the original pagingInfo
decodedPagingInfo.value == pagingInfo decodedPagingInfo.value == pagingInfo
decodedPagingInfo.value.direction == pagingInfo.direction decodedPagingInfo.value.direction == pagingInfo.direction
test "PagingInfoRPC protobuf codec - empty paging info": test "PagingInfoRPC protobuf codec - empty paging info":
## Given ## Given
let emptyPagingInfo = PagingInfoRPC() let emptyPagingInfo = PagingInfoRPC()
## When ## When
let pb = emptyPagingInfo.encode() let pb = emptyPagingInfo.encode()
let decodedEmptyPagingInfo = PagingInfoRPC.decode(pb.buffer) let decodedEmptyPagingInfo = PagingInfoRPC.decode(pb.buffer)
@ -80,7 +81,7 @@ procSuite "Waku Store - RPC codec":
check: check:
# check the correctness of init and encode for an empty PagingInfoRPC # check the correctness of init and encode for an empty PagingInfoRPC
decodedEmptyPagingInfo.value == emptyPagingInfo decodedEmptyPagingInfo.value == emptyPagingInfo
test "HistoryQueryRPC protobuf codec": test "HistoryQueryRPC protobuf codec":
## Given ## Given
let let
@ -88,11 +89,11 @@ procSuite "Waku Store - RPC codec":
pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.BACKWARD)) pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.BACKWARD))
query = HistoryQueryRPC( query = HistoryQueryRPC(
contentFilters: @[HistoryContentFilterRPC(contentTopic: DefaultContentTopic), HistoryContentFilterRPC(contentTopic: DefaultContentTopic)], contentFilters: @[HistoryContentFilterRPC(contentTopic: DefaultContentTopic), HistoryContentFilterRPC(contentTopic: DefaultContentTopic)],
pagingInfo: some(pagingInfo), pagingInfo: some(pagingInfo),
startTime: some(Timestamp(10)), startTime: some(Timestamp(10)),
endTime: some(Timestamp(11)) endTime: some(Timestamp(11))
) )
## When ## When
let pb = query.encode() let pb = query.encode()
let decodedQuery = HistoryQueryRPC.decode(pb.buffer) let decodedQuery = HistoryQueryRPC.decode(pb.buffer)
@ -120,7 +121,7 @@ procSuite "Waku Store - RPC codec":
check: check:
# check the correctness of init and encode for an empty HistoryQueryRPC # check the correctness of init and encode for an empty HistoryQueryRPC
decodedEmptyQuery.value == emptyQuery decodedEmptyQuery.value == emptyQuery
test "HistoryResponseRPC protobuf codec": test "HistoryResponseRPC protobuf codec":
## Given ## Given
let let
@ -128,7 +129,7 @@ procSuite "Waku Store - RPC codec":
index = PagingIndexRPC.compute(message, receivedTime=ts(), pubsubTopic=DefaultPubsubTopic) index = PagingIndexRPC.compute(message, receivedTime=ts(), pubsubTopic=DefaultPubsubTopic)
pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.BACKWARD)) pagingInfo = PagingInfoRPC(pageSize: some(1'u64), cursor: some(index), direction: some(PagingDirectionRPC.BACKWARD))
res = HistoryResponseRPC(messages: @[message], pagingInfo: some(pagingInfo), error: HistoryResponseErrorRPC.INVALID_CURSOR) res = HistoryResponseRPC(messages: @[message], pagingInfo: some(pagingInfo), error: HistoryResponseErrorRPC.INVALID_CURSOR)
## When ## When
let pb = res.encode() let pb = res.encode()
let decodedRes = HistoryResponseRPC.decode(pb.buffer) let decodedRes = HistoryResponseRPC.decode(pb.buffer)
@ -140,11 +141,11 @@ procSuite "Waku Store - RPC codec":
check: check:
# the fields of decoded response decodedRes must be the same as the original response res # the fields of decoded response decodedRes must be the same as the original response res
decodedRes.value == res decodedRes.value == res
test "HistoryResponseRPC protobuf codec - empty history response": test "HistoryResponseRPC protobuf codec - empty history response":
## Given ## Given
let emptyRes = HistoryResponseRPC() let emptyRes = HistoryResponseRPC()
## When ## When
let pb = emptyRes.encode() let pb = emptyRes.encode()
let decodedEmptyRes = HistoryResponseRPC.decode(pb.buffer) let decodedEmptyRes = HistoryResponseRPC.decode(pb.buffer)

View File

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

View File

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