Skip to content

Commit

Permalink
chore(core): move utils time module to waku_core
Browse files Browse the repository at this point in the history
  • Loading branch information
Lorenzo Delgado authored Apr 19, 2023
1 parent 14305c6 commit 93b0c07
Show file tree
Hide file tree
Showing 44 changed files with 42 additions and 70 deletions.
1 change: 0 additions & 1 deletion apps/chat2/chat2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import
../../waku/v2/node/peer_manager,
../../waku/v2/utils/compat,
../../waku/v2/utils/peers,
../../waku/v2/utils/time,
../../waku/common/utils/nat,
./config_chat2

Expand Down
1 change: 0 additions & 1 deletion apps/wakubridge/wakubridge.nim
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ import
# Waku v2 imports
libp2p/crypto/crypto,
libp2p/nameresolving/nameresolver,
../../waku/v2/utils/time,
../../waku/v2/waku_core,
../../waku/v2/waku_store,
../../waku/v2/waku_filter,
Expand Down
5 changes: 2 additions & 3 deletions examples/v2/publisher.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ import
import
../../../waku/common/logging,
../../../waku/v2/node/peer_manager,
../../../waku/v2/waku_node,
../../../waku/v2/waku_core,
../../../waku/v2/waku_node,
../../../waku/v2/waku_enr,
../../../waku/v2/waku_discv5,
../../../waku/v2/utils/time
../../../waku/v2/waku_discv5

proc now*(): Timestamp =
getNanosecondTime(getTime().toUnixFloat())
Expand Down
2 changes: 1 addition & 1 deletion examples/v2/subscriber.nim
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import
import
../../../waku/common/logging,
../../../waku/v2/node/peer_manager,
../../../waku/v2/waku_node,
../../../waku/v2/waku_core,
../../../waku/v2/waku_node,
../../../waku/v2/waku_enr,
../../../waku/v2/waku_discv5

Expand Down
2 changes: 2 additions & 0 deletions tests/all_tests_v2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@
# Waku core test suite
import
./v2/waku_core/test_namespaced_topics,
./v2/waku_core/test_time,
./v2/waku_core/test_message_digest


# Waku archive test suite
import
./v2/waku_archive/test_driver_queue_index,
Expand Down
1 change: 0 additions & 1 deletion tests/v2/test_utils_compat.nim
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import
import
../../waku/v2/waku_core,
../../waku/v2/utils/compat,
../../waku/v2/utils/time,
./testlib/common

suite "Waku Payload":
Expand Down
11 changes: 0 additions & 11 deletions tests/v2/testlib/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,6 @@ import
std/[times, random],
bearssl/rand,
libp2p/crypto/crypto
import
../../../waku/v2/utils/time


# Time

proc now*(): Timestamp =
getNanosecondTime(getTime().toUnixFloat())

proc ts*(offset=0, origin=now()): Timestamp =
origin + getNanosecondTime(offset)


## Randomization
Expand Down
11 changes: 10 additions & 1 deletion tests/v2/testlib/wakucore.nim
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import
std/options,
std/[options, times],
stew/[results, byteutils],
stew/shims/net,
chronos,
Expand All @@ -14,6 +14,15 @@ import
export switch


# Time

proc now*(): Timestamp =
getNanosecondTime(getTime().toUnixFloat())

proc ts*(offset=0, origin=now()): Timestamp =
origin + getNanosecondTime(offset)


# Switch

proc generateEcdsaKey*(): libp2p_keys.PrivateKey =
Expand Down
3 changes: 1 addition & 2 deletions tests/v2/waku_archive/test_driver_queue.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,7 @@ import
../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/queue_driver/queue_driver {.all.},
../../../waku/v2/waku_archive/driver/queue_driver/index,
../../../waku/v2/waku_core,
../../../waku/v2/utils/time
../../../waku/v2/waku_core


# Helper functions
Expand Down
3 changes: 1 addition & 2 deletions tests/v2/waku_archive/test_driver_queue_index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ import
nimcrypto
import
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive/driver/queue_driver/index,
../../../waku/v2/utils/time
../../../waku/v2/waku_archive/driver/queue_driver/index


## Helpers
Expand Down
1 change: 0 additions & 1 deletion tests/v2/waku_archive/test_driver_queue_pagination.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import
../../../waku/v2/waku_archive/driver/queue_driver/queue_driver {.all.},
../../../waku/v2/waku_archive/driver/queue_driver/index,
../../../waku/v2/waku_core,
../../../waku/v2/utils/time,
../testlib/common,
../testlib/wakucore

Expand Down
3 changes: 1 addition & 2 deletions tests/v2/waku_archive/test_retention_policy.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ import
chronos
import
../../../waku/common/sqlite,
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/sqlite_driver,
../../../waku/v2/waku_archive/retention_policy,
../../../waku/v2/waku_archive/retention_policy/retention_policy_capacity,
../../../waku/v2/waku_core,
../../../waku/v2/utils/time,
../testlib/common,
../testlib/wakucore

Expand Down
1 change: 0 additions & 1 deletion tests/v2/waku_archive/test_waku_archive.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive/driver/sqlite_driver,
../../../waku/v2/waku_archive,
../../../waku/v2/utils/time,
../testlib/common,
../testlib/wakucore

Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
{.used.}

import
stew/results,
testutils/unittests
import
../../waku/v2/utils/time
../../waku/v2/waku_core/time

suite "Utils - Time":
suite "Waku Core - Time":

test "Test timestamp conversion":
## Given
Expand Down
2 changes: 1 addition & 1 deletion tests/v2/waku_store/test_rpc_codec.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import
chronos
import
../../../waku/common/protobuf,
../../../waku/v2/waku_core,
../../../waku/v2/waku_store/rpc,
../../../waku/v2/waku_store/rpc_codec,
../../../waku/v2/utils/time,
../testlib/common,
../testlib/wakucore

Expand Down
3 changes: 1 addition & 2 deletions tests/v2/wakunode_jsonrpc/test_jsonrpc_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,15 @@ import
json_rpc/[rpcserver, rpcclient]
import
../../../waku/v2/node/peer_manager,
../../../waku/v2/waku_core,
../../../waku/v2/waku_node,
../../../waku/v2/node/jsonrpc/store/handlers as store_api,
../../../waku/v2/node/jsonrpc/store/client as store_api_client,
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/queue_driver,
../../../waku/v2/waku_store,
../../../waku/v2/waku_store/rpc,
../../../waku/v2/utils/peers,
../../../waku/v2/utils/time,
../../v2/testlib/common,
../../v2/testlib/wakucore,
../../v2/testlib/wakunode
Expand Down
3 changes: 1 addition & 2 deletions tests/v2/wakunode_rest/test_rest_relay.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import
libp2p/crypto/crypto
import
../../waku/common/base64,
../../waku/v2/waku_core,
../../waku/v2/waku_node,
../../waku/v2/node/rest/server,
../../waku/v2/node/rest/client,
Expand All @@ -17,9 +18,7 @@ import
../../waku/v2/node/rest/relay/handlers as relay_api,
../../waku/v2/node/rest/relay/client as relay_api_client,
../../waku/v2/node/rest/relay/topic_cache,
../../waku/v2/waku_core,
../../waku/v2/waku_relay,
../../waku/v2/utils/time,
../testlib/wakucore,
../testlib/wakunode

Expand Down
13 changes: 6 additions & 7 deletions tests/v2/wakunode_rest/test_rest_store.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,19 @@ import
presto, presto/client as presto_client,
libp2p/crypto/crypto
import
../../../waku/v2/waku_core,
../../../waku/v2/waku_node,
../../../waku/v2/node/peer_manager,
../../../waku/v2/node/waku_node,
../../waku/v2/node/rest/server,
../../waku/v2/node/rest/client,
../../waku/v2/node/rest/responses,
../../../waku/v2/node/rest/server,
../../../waku/v2/node/rest/client,
../../../waku/v2/node/rest/responses,
../../../waku/v2/node/rest/store/handlers as store_api,
../../../waku/v2/node/rest/store/client as store_api_client,
../../../waku/v2/node/rest/store/types,
../../../waku/v2/waku_core,
../../../waku/v2/waku_archive,
../../../waku/v2/waku_archive/driver/queue_driver,
../../../waku/v2/waku_store as waku_store,
../../../waku/v2/utils/peers,
../../../waku/v2/utils/time,
../../v2/testlib/common,
../../v2/testlib/wakucore,
../../v2/testlib/wakunode
Expand Down Expand Up @@ -166,7 +165,7 @@ procSuite "Waku v2 Rest API - Store":
peerSwitch.mount(node.wakuStore)

# Now prime it with some history before tests
let timeOrigin = common.now()
let timeOrigin = wakucore.now()
let msgList = @[
fakeWakuMessage(@[byte 00], ts=ts(00, timeOrigin)),
fakeWakuMessage(@[byte 01], ts=ts(10, timeOrigin)),
Expand Down
1 change: 0 additions & 1 deletion tools/simulation/quicksim2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import
../../waku/v2/waku_filter/rpc,
../../waku/v2/waku_store/rpc,
../../waku/v2/waku_core,
../../waku/v2/utils/time,
../../waku/v2/waku_node,
../../waku/v2/node/waku_payload,
../../waku/v2/node/jsonrpc/[jsonrpc_types,jsonrpc_utils]
Expand Down
3 changes: 1 addition & 2 deletions waku/v2/node/jsonrpc/message.nim
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ import
json_rpc/rpcserver
import
../../../common/base64,
../../waku_core,
../../utils/time
../../waku_core


type
Expand Down
1 change: 0 additions & 1 deletion waku/v2/node/jsonrpc/relay/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import
../../../waku_core,
../../../waku_relay,
../../../utils/compat,
../../../utils/time,
../../waku_node,
../../message_cache,
./types
Expand Down
2 changes: 1 addition & 1 deletion waku/v2/node/jsonrpc/store/client.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import
std/[os, strutils],
json_rpc/rpcclient
import
../../../waku_core,
../../../waku_store/rpc,
../../../utils/time,
./types

export types
Expand Down
2 changes: 1 addition & 1 deletion waku/v2/node/jsonrpc/store/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ import
chronicles,
json_rpc/rpcserver
import
../../../waku_core,
../../../waku_store,
../../../waku_store/rpc,
../../../utils/time,
../../waku_node,
../../peer_manager,
./types
Expand Down
1 change: 0 additions & 1 deletion waku/v2/node/rest/store/handlers.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import
../../../../common/base64,
../../../waku_core,
../../../waku_store/common,
../../../utils/time,
../../waku_node,
../../peer_manager,
../responses,
Expand Down
1 change: 0 additions & 1 deletion waku/v2/node/rest/store/types.nim
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ import
import
../../../waku_store/common as waku_store_common,
../../../../common/base64,
../../../utils/time,
../../../waku_core,
../serdes

Expand Down
1 change: 0 additions & 1 deletion waku/v2/node/waku_node.nim
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import
../waku_discv5,
../waku_peer_exchange,
../utils/peers,
../utils/time,
./config,
./peer_manager,
./waku_switch
Expand Down
1 change: 0 additions & 1 deletion waku/v2/waku_archive/archive.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import
chronos,
metrics
import
../utils/time,
../waku_core,
./common,
./archive_metrics,
Expand Down
1 change: 0 additions & 1 deletion waku/v2/waku_archive/common.nim
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import
stew/byteutils,
nimcrypto/sha2
import
../utils/time,
../waku_core


Expand Down
1 change: 0 additions & 1 deletion waku/v2/waku_archive/driver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import
std/options,
stew/results
import
../utils/time,
../waku_core,
./common

Expand Down
1 change: 0 additions & 1 deletion waku/v2/waku_archive/driver/queue_driver/index.nim
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import
nimcrypto/sha2
import
../../../waku_core,
../../../utils/time,
../../common


Expand Down
1 change: 0 additions & 1 deletion waku/v2/waku_archive/driver/queue_driver/queue_driver.nim
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import
chronicles
import
../../../waku_core,
../../../utils/time,
../../common,
../../driver,
./index
Expand Down
1 change: 0 additions & 1 deletion waku/v2/waku_archive/driver/sqlite_driver/cursor.nim
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ else:

import
../../../waku_core,
../../../utils/time,
../../common

type DbCursor* = (Timestamp, seq[byte], PubsubTopic)
Expand Down
1 change: 0 additions & 1 deletion waku/v2/waku_archive/driver/sqlite_driver/queries.nim
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import
import
../../../../common/sqlite,
../../../waku_core,
../../../utils/time,
./cursor


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ import
import
../../../../common/sqlite,
../../../waku_core,
../../../utils/time,
../../common,
../../driver,
./cursor,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import
chronicles,
chronos
import
../../utils/time,
../../waku_core,
../driver,
../retention_policy

Expand Down
Loading

0 comments on commit 93b0c07

Please sign in to comment.