From 11c5d4ed4c28a678a6913dd118ceeb648b47d9aa Mon Sep 17 00:00:00 2001 From: Petri Savolainen Date: Sun, 5 Jul 2026 10:28:03 +0300 Subject: [PATCH] =?UTF-8?q?Consolidation=20step=205=20of=208:=20utils=20?= =?UTF-8?q?=E2=80=94=2021=20headers=20become=20named=20sub-modules=20[andr?= =?UTF-8?q?oidbuild]=20[iosbuild]?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Plain application of the settled architecture: one streamr.utils.X sub-module per former header, no umbrella, include/ tree deleted, all 45 repo-wide importers flipped to narrow imports. Documents a clang 22.1.8 modules miscompile found during the flip: an UNUSED import of a folly-coro-heavy BMI into a module unit with its own textual folly coroutine declarations broke coroutine resumption at runtime — minimal imports is now recorded as a correctness rule, not just hygiene. Also removes a 2024 typo-named duplicate test file that no target ever built (SigninUtilsTest.cpp). Co-Authored-By: Claude Fable 5 --- MODERNIZATION.md | 39 +++- packages/streamr-dht/modules/Identifiers.cppm | 3 +- .../modules/connection/Connection.cppm | 3 +- .../connection/ConnectionLockStates.cppm | 2 +- .../modules/connection/ConnectionManager.cppm | 2 +- .../modules/connection/Handshaker.cppm | 3 +- .../modules/connection/PendingConnection.cppm | 3 +- .../modules/connection/endpoint/Endpoint.cppm | 2 +- .../connection/endpoint/EndpointState.cppm | 2 +- .../websocket/WebsocketClientConnection.cppm | 2 +- .../websocket/WebsocketClientConnector.cppm | 2 +- .../WebsocketClientConnectorRpcLocal.cppm | 2 +- .../websocket/WebsocketConnection.cppm | 2 +- .../connection/websocket/WebsocketServer.cppm | 2 +- .../websocket/WebsocketServerConnector.cppm | 4 +- .../transport/RoutingRpcCommunicator.cppm | 2 +- .../integration/ConnectionLockingTest.cpp | 3 +- .../test/unit/PendingConnectionTest.cpp | 2 +- .../WebsocketClientConnectorRpcLocalTest.cpp | 2 +- .../src/streamrproxyclient.cpp | 5 +- .../modules/RpcCommunicatorClientApi.cppm | 3 +- .../logic/ContentDeliveryRpcLocal.cppm | 2 +- .../logic/ContentDeliveryRpcRemote.cppm | 2 +- .../formStreamPartDeliveryServiceId.cppm | 2 +- .../modules/logic/proxy/ProxyClient.cppm | 5 +- .../logic/proxy/ProxyConnectionRpcLocal.cppm | 4 +- .../logic/proxy/ProxyConnectionRpcRemote.cppm | 3 +- .../ProxyClientTsIntegrationTest.cpp | 4 +- packages/streamr-utils/CMakeLists.txt | 18 +- .../include/streamr-utils/Uuid.hpp | 19 -- .../include/streamr-utils/toCoroTask.hpp | 17 -- .../toEthereumAddressOrENSName.hpp | 21 -- packages/streamr-utils/lint.sh | 9 +- .../AbortController.cppm} | 22 +- .../AbortableTimers.cppm} | 22 +- .../BinaryUtils.cppm} | 16 +- .../Branded.hpp => modules/Branded.cppm} | 16 +- .../ENSName.hpp => modules/ENSName.cppm} | 19 +- .../EnableSharedFromThis.cppm} | 13 +- .../EthereumAddress.cppm} | 15 +- .../Ipv4Helper.cppm} | 13 +- .../ReplayEventEmitterWrapper.cppm} | 15 +- .../RetryUtils.cppm} | 25 ++- .../SigningUtils.cppm} | 19 +- .../StreamID.hpp => modules/StreamID.cppm} | 26 ++- .../StreamPartID.cppm} | 25 ++- packages/streamr-utils/modules/Uuid.cppm | 24 +++ .../collect.hpp => modules/collect.cppm} | 20 +- .../partition.hpp => modules/partition.cppm} | 13 +- .../runAndWaitForEvents.cppm} | 26 ++- .../modules/streamr.utils-all.cppm | 192 ------------------ .../streamr-utils/modules/streamr.utils.cppm | 4 - .../streamr-utils/modules/toCoroTask.cppm | 22 ++ .../modules/toEthereumAddressOrENSName.cppm | 26 +++ .../waitForCondition.cppm} | 27 ++- .../waitForEvent.cppm} | 19 +- .../test/unit/AbortControllerTest.cpp | 2 +- .../test/unit/AbortableTimersTest.cpp | 3 +- .../test/unit/BinaryUtilsTest.cpp | 2 +- .../streamr-utils/test/unit/BrandedTest.cpp | 2 +- .../streamr-utils/test/unit/ENSNameTest.cpp | 2 +- .../test/unit/EthereumAddressTest.cpp | 2 +- .../unit/ReplayEventEmitterWrapperTest.cpp | 2 +- .../test/unit/RetryUtilsTest.cpp | 2 +- .../test/unit/SigninUtilsTest.cpp | 33 --- .../test/unit/SigningUtilsTest.cpp | 3 +- .../streamr-utils/test/unit/StreamIDTest.cpp | 2 +- .../test/unit/StreamPartIDTest.cpp | 3 +- .../streamr-utils/test/unit/collectTest.cpp | 2 +- .../test/unit/runAndWaitForEventsTest.cpp | 2 +- .../test/unit/toCoroTaskTest.cpp | 2 +- .../unit/toEthereumAddressOrENSNameTest.cpp | 4 +- .../test/unit/waitForConditionTest.cpp | 3 +- .../test/unit/waitForEventTest.cpp | 3 +- 74 files changed, 422 insertions(+), 467 deletions(-) delete mode 100644 packages/streamr-utils/include/streamr-utils/Uuid.hpp delete mode 100644 packages/streamr-utils/include/streamr-utils/toCoroTask.hpp delete mode 100644 packages/streamr-utils/include/streamr-utils/toEthereumAddressOrENSName.hpp rename packages/streamr-utils/{include/streamr-utils/AbortController.hpp => modules/AbortController.cppm} (73%) rename packages/streamr-utils/{include/streamr-utils/AbortableTimers.hpp => modules/AbortableTimers.cppm} (82%) rename packages/streamr-utils/{include/streamr-utils/BinaryUtils.hpp => modules/BinaryUtils.cppm} (79%) rename packages/streamr-utils/{include/streamr-utils/Branded.hpp => modules/Branded.cppm} (94%) rename packages/streamr-utils/{include/streamr-utils/ENSName.hpp => modules/ENSName.cppm} (64%) rename packages/streamr-utils/{include/streamr-utils/EnableSharedFromThis.hpp => modules/EnableSharedFromThis.cppm} (77%) rename packages/streamr-utils/{include/streamr-utils/EthereumAddress.hpp => modules/EthereumAddress.cppm} (70%) rename packages/streamr-utils/{include/streamr-utils/Ipv4Helper.hpp => modules/Ipv4Helper.cppm} (66%) rename packages/streamr-utils/{include/streamr-utils/ReplayEventEmitterWrapper.hpp => modules/ReplayEventEmitterWrapper.cppm} (92%) rename packages/streamr-utils/{include/streamr-utils/RetryUtils.hpp => modules/RetryUtils.cppm} (76%) rename packages/streamr-utils/{include/streamr-utils/SigningUtils.hpp => modules/SigningUtils.cppm} (85%) rename packages/streamr-utils/{include/streamr-utils/StreamID.hpp => modules/StreamID.cppm} (86%) rename packages/streamr-utils/{include/streamr-utils/StreamPartID.hpp => modules/StreamPartID.cppm} (81%) create mode 100644 packages/streamr-utils/modules/Uuid.cppm rename packages/streamr-utils/{include/streamr-utils/collect.hpp => modules/collect.cppm} (76%) rename packages/streamr-utils/{include/streamr-utils/partition.hpp => modules/partition.cppm} (76%) rename packages/streamr-utils/{include/streamr-utils/runAndWaitForEvents.hpp => modules/runAndWaitForEvents.cppm} (76%) delete mode 100644 packages/streamr-utils/modules/streamr.utils-all.cppm delete mode 100644 packages/streamr-utils/modules/streamr.utils.cppm create mode 100644 packages/streamr-utils/modules/toCoroTask.cppm create mode 100644 packages/streamr-utils/modules/toEthereumAddressOrENSName.cppm rename packages/streamr-utils/{include/streamr-utils/waitForCondition.hpp => modules/waitForCondition.cppm} (73%) rename packages/streamr-utils/{include/streamr-utils/waitForEvent.hpp => modules/waitForEvent.cppm} (84%) delete mode 100644 packages/streamr-utils/test/unit/SigninUtilsTest.cpp diff --git a/MODERNIZATION.md b/MODERNIZATION.md index 296a642f..6130d11e 100644 --- a/MODERNIZATION.md +++ b/MODERNIZATION.md @@ -944,7 +944,44 @@ exactly that. So consolidation walks the dependency chain from the top: Verified: whole-tree build, 309/309 tests, standalone chain (proto-rpc → dht → trackerless-network → proxyclient), lint green over the module units. -5. C-5 streamr-utils +5. **C-5 streamr-utils** ✅ — plain application of the settled + architecture: the 21 public headers became named sub-modules + (`streamr.utils.X`) under `modules/`, one per former header (git mv, + history preserved); the coarse façade (`streamr.utils` + + `streamr.utils-all`) and the include/ tree deleted; all 45 repo-wide + `import streamr.utils;` consumers flipped to narrow imports; the + package no longer exports an include directory. One 2024 leftover + removed in passing: test/unit/SigninUtilsTest.cpp (typo-named, + byte-identical duplicate of SigningUtilsTest.cpp, never in any CMake + target — surfaced because clangd had been linting it with flags + borrowed from a neighboring file). + **IMPORTANT FINDING — a clang 22.1.8 modules miscompile, and the + rule that avoids it.** The first (script-driven) consumer flip + over-matched names and added spurious imports; among them, + `import streamr.utils.waitForCondition;` in + streamr.protorpc.RpcCommunicatorClientApi — a module unit that + textually includes folly's coroutine Promise/Timeout headers in its + own global module fragment and defines coroutine code. With that one + spurious import added, ALL 17 RpcCommunicator tests hang + deterministically: the response arrives, the promise is resolved, + and the awaiting coroutine never resumes (every thread idle-parked; + confirmed by stack traces). The imported BMI's global module + fragment carries overlapping folly-coroutine declarations + (waitForCondition's GMF also includes folly coro headers), and + merging them with the importer's own textual copies miscompiles the + promise-resumption path. Removing the unused import fixes it; + bisection pinned exactly this import (collect alone is fine, the + waitForCondition import alone hangs). CONSEQUENCE, now a hard rule + (it was already the architecture's intent): **a module unit imports + ONLY the modules whose names its code actually uses — never + speculative or convenience imports.** The flip tooling now prunes + against a curated per-module export-name list, and the compiler's + "declaration of 'X' must be imported from module 'M'" errors are the + ground truth for adding imports back. + Verified: whole-tree build, 309/309 tests (with per-test timeouts), + standalone chain (utils 49/49 → proto-rpc 26/26 → dht 83/83 → + trackerless-network → proxyclient 15/15), lint green in all five + touched packages (utils module units now clangd-tidy-linted). 6. C-6 streamr-logger 7. C-7 streamr-json 8. C-8 streamr-eventemitter (+ final bench.sh metrics and memo closure) diff --git a/packages/streamr-dht/modules/Identifiers.cppm b/packages/streamr-dht/modules/Identifiers.cppm index f086d0bc..ca692689 100644 --- a/packages/streamr-dht/modules/Identifiers.cppm +++ b/packages/streamr-dht/modules/Identifiers.cppm @@ -10,7 +10,8 @@ module; export module streamr.dht.Identifiers; -import streamr.utils; +import streamr.utils.BinaryUtils; +import streamr.utils.Branded; // Hoisted from the former header (file scope, NOT exported); // fully qualified: relative namespace names resolve differently diff --git a/packages/streamr-dht/modules/connection/Connection.cppm b/packages/streamr-dht/modules/connection/Connection.cppm index 5ac16095..6766eb1d 100644 --- a/packages/streamr-dht/modules/connection/Connection.cppm +++ b/packages/streamr-dht/modules/connection/Connection.cppm @@ -15,7 +15,8 @@ export module streamr.dht.Connection; import streamr.eventemitter; import streamr.logger; -import streamr.utils; +import streamr.utils.Branded; +import streamr.utils.Uuid; // Hoisted from the former header (file scope, NOT exported); // fully qualified: relative namespace names resolve differently diff --git a/packages/streamr-dht/modules/connection/ConnectionLockStates.cppm b/packages/streamr-dht/modules/connection/ConnectionLockStates.cppm index c10f0172..8170d1d2 100644 --- a/packages/streamr-dht/modules/connection/ConnectionLockStates.cppm +++ b/packages/streamr-dht/modules/connection/ConnectionLockStates.cppm @@ -12,7 +12,7 @@ module; export module streamr.dht.ConnectionLockStates; -import streamr.utils; +import streamr.utils.Branded; import streamr.dht.Identifiers; export namespace streamr::dht::connection { diff --git a/packages/streamr-dht/modules/connection/ConnectionManager.cppm b/packages/streamr-dht/modules/connection/ConnectionManager.cppm index bbc5e0ae..abd71fb6 100644 --- a/packages/streamr-dht/modules/connection/ConnectionManager.cppm +++ b/packages/streamr-dht/modules/connection/ConnectionManager.cppm @@ -22,7 +22,7 @@ export module streamr.dht.ConnectionManager; import streamr.protorpc.RpcCommunicator; import streamr.dht.ConnectionLockStates; import streamr.logger; -import streamr.utils; +import streamr.utils.waitForEvent; import streamr.dht.ConnectionLockRpcLocal; import streamr.dht.ConnectionLockRpcRemote; import streamr.dht.ConnectionLocker; diff --git a/packages/streamr-dht/modules/connection/Handshaker.cppm b/packages/streamr-dht/modules/connection/Handshaker.cppm index 95a8e803..ee5ac19e 100644 --- a/packages/streamr-dht/modules/connection/Handshaker.cppm +++ b/packages/streamr-dht/modules/connection/Handshaker.cppm @@ -12,7 +12,8 @@ export module streamr.dht.Handshaker; import streamr.eventemitter; import streamr.logger; -import streamr.utils; +import streamr.utils.EnableSharedFromThis; +import streamr.utils.Uuid; import streamr.dht.Connection; import streamr.dht.Version; diff --git a/packages/streamr-dht/modules/connection/PendingConnection.cppm b/packages/streamr-dht/modules/connection/PendingConnection.cppm index f76aa1c5..5afdbc51 100644 --- a/packages/streamr-dht/modules/connection/PendingConnection.cppm +++ b/packages/streamr-dht/modules/connection/PendingConnection.cppm @@ -14,7 +14,8 @@ module; export module streamr.dht.PendingConnection; -import streamr.utils; +import streamr.utils.AbortController; +import streamr.utils.AbortableTimers; import streamr.logger; import streamr.dht.Connection; import streamr.dht.IPendingConnection; diff --git a/packages/streamr-dht/modules/connection/endpoint/Endpoint.cppm b/packages/streamr-dht/modules/connection/endpoint/Endpoint.cppm index c6d11673..08eb4613 100644 --- a/packages/streamr-dht/modules/connection/endpoint/Endpoint.cppm +++ b/packages/streamr-dht/modules/connection/endpoint/Endpoint.cppm @@ -16,7 +16,7 @@ export module streamr.dht.Endpoint; import streamr.eventemitter; import streamr.logger; -import streamr.utils; +import streamr.utils.EnableSharedFromThis; import streamr.dht.ConnectedEndpointState; import streamr.dht.ConnectingEndpointState; import streamr.dht.DisconnectedEndpointState; diff --git a/packages/streamr-dht/modules/connection/endpoint/EndpointState.cppm b/packages/streamr-dht/modules/connection/endpoint/EndpointState.cppm index 95b4a0fb..daf7f7dd 100644 --- a/packages/streamr-dht/modules/connection/endpoint/EndpointState.cppm +++ b/packages/streamr-dht/modules/connection/endpoint/EndpointState.cppm @@ -11,7 +11,7 @@ module; export module streamr.dht.EndpointState; import streamr.logger; -import streamr.utils; +import streamr.utils.EnableSharedFromThis; import streamr.dht.Connection; import streamr.dht.IPendingConnection; diff --git a/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnection.cppm b/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnection.cppm index 119e49f0..899605dd 100644 --- a/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnection.cppm +++ b/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnection.cppm @@ -13,7 +13,7 @@ export module streamr.dht.WebsocketClientConnection; import streamr.dht.Connection; import streamr.logger; -import streamr.utils; +import streamr.utils.waitForEvent; import streamr.dht.WebsocketConnection; // Hoisted from the former header (file scope, NOT exported); diff --git a/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnector.cppm b/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnector.cppm index b3948e08..58898fe9 100644 --- a/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnector.cppm +++ b/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnector.cppm @@ -16,7 +16,7 @@ export module streamr.dht.WebsocketClientConnector; import streamr.dht.Handshaker; import streamr.dht.Connection; import streamr.logger; -import streamr.utils; +import streamr.utils.AbortController; import streamr.dht.Connectivity; import streamr.dht.IPendingConnection; import streamr.dht.Identifiers; diff --git a/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnectorRpcLocal.cppm b/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnectorRpcLocal.cppm index 993f92c9..6ba7ae34 100644 --- a/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnectorRpcLocal.cppm +++ b/packages/streamr-dht/modules/connection/websocket/WebsocketClientConnectorRpcLocal.cppm @@ -12,7 +12,7 @@ module; export module streamr.dht.WebsocketClientConnectorRpcLocal; import streamr.dht.DhtRpcServer; -import streamr.utils; +import streamr.utils.AbortController; import streamr.dht.DhtCallContext; import streamr.dht.IPendingConnection; import streamr.dht.Identifiers; diff --git a/packages/streamr-dht/modules/connection/websocket/WebsocketConnection.cppm b/packages/streamr-dht/modules/connection/websocket/WebsocketConnection.cppm index 2902d9e1..1fad69bd 100644 --- a/packages/streamr-dht/modules/connection/websocket/WebsocketConnection.cppm +++ b/packages/streamr-dht/modules/connection/websocket/WebsocketConnection.cppm @@ -12,7 +12,7 @@ module; export module streamr.dht.WebsocketConnection; import streamr.logger; -import streamr.utils; +import streamr.utils.EnableSharedFromThis; import streamr.dht.Connection; // Hoisted from the former header (file scope, NOT exported); diff --git a/packages/streamr-dht/modules/connection/websocket/WebsocketServer.cppm b/packages/streamr-dht/modules/connection/websocket/WebsocketServer.cppm index 495314a3..ec3f1fa5 100644 --- a/packages/streamr-dht/modules/connection/websocket/WebsocketServer.cppm +++ b/packages/streamr-dht/modules/connection/websocket/WebsocketServer.cppm @@ -18,7 +18,7 @@ import streamr.eventemitter; import streamr.dht.Connection; import streamr.dht.WebsocketConnection; import streamr.logger; -import streamr.utils; +import streamr.utils.Uuid; import streamr.dht.CertificateHelper; import streamr.dht.Errors; import streamr.dht.PortRange; diff --git a/packages/streamr-dht/modules/connection/websocket/WebsocketServerConnector.cppm b/packages/streamr-dht/modules/connection/websocket/WebsocketServerConnector.cppm index 9023934b..01687c54 100644 --- a/packages/streamr-dht/modules/connection/websocket/WebsocketServerConnector.cppm +++ b/packages/streamr-dht/modules/connection/websocket/WebsocketServerConnector.cppm @@ -16,7 +16,9 @@ export module streamr.dht.WebsocketServerConnector; import streamr.dht.WebsocketServerConnection; import streamr.logger; -import streamr.utils; +import streamr.utils.AbortController; +import streamr.utils.Ipv4Helper; +import streamr.utils.Uuid; import streamr.dht.Handshaker; import streamr.dht.IPendingConnection; import streamr.dht.Identifiers; diff --git a/packages/streamr-dht/modules/transport/RoutingRpcCommunicator.cppm b/packages/streamr-dht/modules/transport/RoutingRpcCommunicator.cppm index 9a92102a..c39ab416 100644 --- a/packages/streamr-dht/modules/transport/RoutingRpcCommunicator.cppm +++ b/packages/streamr-dht/modules/transport/RoutingRpcCommunicator.cppm @@ -14,7 +14,7 @@ export module streamr.dht.RoutingRpcCommunicator; import streamr.logger; import streamr.protorpc.RpcCommunicator; import streamr.protorpc.protos; -import streamr.utils; +import streamr.utils.Uuid; import streamr.dht.DhtCallContext; import streamr.dht.Identifiers; import streamr.dht.Transport; diff --git a/packages/streamr-dht/test/integration/ConnectionLockingTest.cpp b/packages/streamr-dht/test/integration/ConnectionLockingTest.cpp index 758a1a3b..1f3b28e6 100644 --- a/packages/streamr-dht/test/integration/ConnectionLockingTest.cpp +++ b/packages/streamr-dht/test/integration/ConnectionLockingTest.cpp @@ -19,7 +19,8 @@ import streamr.dht.PortRange; import streamr.dht.Transport; import streamr.dht.protos; import streamr.logger; -import streamr.utils; +import streamr.utils.collect; +import streamr.utils.waitForCondition; using ::dht::ConnectivityResponse; // using ::dht::Message; diff --git a/packages/streamr-dht/test/unit/PendingConnectionTest.cpp b/packages/streamr-dht/test/unit/PendingConnectionTest.cpp index 73065137..637ad0d7 100644 --- a/packages/streamr-dht/test/unit/PendingConnectionTest.cpp +++ b/packages/streamr-dht/test/unit/PendingConnectionTest.cpp @@ -11,7 +11,7 @@ import streamr.dht.Connection; import streamr.dht.PendingConnection; import streamr.dht.Transport; import streamr.dht.protos; -import streamr.utils; +import streamr.utils.waitForCondition; using ::dht::PeerDescriptor; using streamr::dht::connection::Connection; diff --git a/packages/streamr-dht/test/unit/WebsocketClientConnectorRpcLocalTest.cpp b/packages/streamr-dht/test/unit/WebsocketClientConnectorRpcLocalTest.cpp index fa9b8b92..d632d20f 100644 --- a/packages/streamr-dht/test/unit/WebsocketClientConnectorRpcLocalTest.cpp +++ b/packages/streamr-dht/test/unit/WebsocketClientConnectorRpcLocalTest.cpp @@ -5,7 +5,7 @@ import streamr.dht.Identifiers; import streamr.dht.PendingConnection; import streamr.dht.WebsocketClientConnectorRpcLocal; import streamr.dht.protos; -import streamr.utils; +import streamr.utils.AbortController; using ::dht::PeerDescriptor; using streamr::dht::DhtAddress; diff --git a/packages/streamr-libstreamrproxyclient/src/streamrproxyclient.cpp b/packages/streamr-libstreamrproxyclient/src/streamrproxyclient.cpp index 97f25b4e..945e6eff 100644 --- a/packages/streamr-libstreamrproxyclient/src/streamrproxyclient.cpp +++ b/packages/streamr-libstreamrproxyclient/src/streamrproxyclient.cpp @@ -30,7 +30,10 @@ import streamr.dht.Identifiers; import streamr.dht.protos; import streamr.logger; import streamr.trackerlessnetwork.ProxyClient; -import streamr.utils; +import streamr.utils.BinaryUtils; +import streamr.utils.EthereumAddress; +import streamr.utils.SigningUtils; +import streamr.utils.StreamPartID; namespace streamr::libstreamrproxyclient { diff --git a/packages/streamr-proto-rpc/modules/RpcCommunicatorClientApi.cppm b/packages/streamr-proto-rpc/modules/RpcCommunicatorClientApi.cppm index 788bd419..9684b8c5 100644 --- a/packages/streamr-proto-rpc/modules/RpcCommunicatorClientApi.cppm +++ b/packages/streamr-proto-rpc/modules/RpcCommunicatorClientApi.cppm @@ -16,7 +16,8 @@ module; export module streamr.protorpc.RpcCommunicatorClientApi; import streamr.logger; -import streamr.utils; +import streamr.utils.Branded; +import streamr.utils.Uuid; import streamr.protorpc.Errors; // Hoisted from the former header (file scope, NOT exported); diff --git a/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcLocal.cppm b/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcLocal.cppm index d1d6da1d..0034a171 100644 --- a/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcLocal.cppm +++ b/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcLocal.cppm @@ -13,7 +13,7 @@ import streamr.dht.DhtCallContext; import streamr.dht.Identifiers; import streamr.dht.ListeningRpcCommunicator; import streamr.dht.protos; -import streamr.utils; +import streamr.utils.StreamPartID; // Hoisted from the former header (file scope, NOT exported); // fully qualified because relative namespace names resolve diff --git a/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcRemote.cppm b/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcRemote.cppm index e50f933c..ad390ba7 100644 --- a/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcRemote.cppm +++ b/packages/streamr-trackerless-network/modules/logic/ContentDeliveryRpcRemote.cppm @@ -15,7 +15,7 @@ import streamr.dht.DhtCallContext; import streamr.dht.RpcRemote; import streamr.dht.protos; import streamr.logger; -import streamr.utils; +import streamr.utils.StreamPartID; // Hoisted from the former header (file scope, NOT exported); // fully qualified because relative namespace names resolve diff --git a/packages/streamr-trackerless-network/modules/logic/formStreamPartDeliveryServiceId.cppm b/packages/streamr-trackerless-network/modules/logic/formStreamPartDeliveryServiceId.cppm index 4a5c2a4c..a76aba98 100644 --- a/packages/streamr-trackerless-network/modules/logic/formStreamPartDeliveryServiceId.cppm +++ b/packages/streamr-trackerless-network/modules/logic/formStreamPartDeliveryServiceId.cppm @@ -12,7 +12,7 @@ module; export module streamr.trackerlessnetwork.formStreamPartDeliveryServiceId; import streamr.dht.Identifiers; -import streamr.utils; +import streamr.utils.StreamPartID; // Hoisted from the former header (file scope, NOT exported); // fully qualified because relative namespace names resolve diff --git a/packages/streamr-trackerless-network/modules/logic/proxy/ProxyClient.cppm b/packages/streamr-trackerless-network/modules/logic/proxy/ProxyClient.cppm index d21a0514..dd7bc60d 100644 --- a/packages/streamr-trackerless-network/modules/logic/proxy/ProxyClient.cppm +++ b/packages/streamr-trackerless-network/modules/logic/proxy/ProxyClient.cppm @@ -27,7 +27,10 @@ import streamr.dht.Transport; import streamr.dht.protos; import streamr.eventemitter; import streamr.logger; -import streamr.utils; +import streamr.utils.AbortController; +import streamr.utils.EthereumAddress; +import streamr.utils.RetryUtils; +import streamr.utils.StreamPartID; import streamr.trackerlessnetwork.ContentDeliveryRpcLocal; import streamr.trackerlessnetwork.ContentDeliveryRpcRemote; import streamr.trackerlessnetwork.DuplicateMessageDetector; diff --git a/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcLocal.cppm b/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcLocal.cppm index 5a085d6c..b4cc8c77 100644 --- a/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcLocal.cppm +++ b/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcLocal.cppm @@ -16,7 +16,9 @@ import streamr.dht.Identifiers; import streamr.dht.ListeningRpcCommunicator; import streamr.dht.protos; import streamr.eventemitter; -import streamr.utils; +import streamr.utils.BinaryUtils; +import streamr.utils.EthereumAddress; +import streamr.utils.StreamPartID; import streamr.trackerlessnetwork.ContentDeliveryRpcRemote; // Hoisted from the former header (file scope, NOT exported); diff --git a/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcRemote.cppm b/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcRemote.cppm index 25f1ec9f..7c07f193 100644 --- a/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcRemote.cppm +++ b/packages/streamr-trackerless-network/modules/logic/proxy/ProxyConnectionRpcRemote.cppm @@ -14,7 +14,8 @@ import streamr.dht.DhtCallContext; import streamr.dht.RpcRemote; import streamr.dht.protos; import streamr.logger; -import streamr.utils; +import streamr.utils.BinaryUtils; +import streamr.utils.EthereumAddress; // Hoisted from the former header (file scope, NOT exported); // fully qualified because relative namespace names resolve diff --git a/packages/streamr-trackerless-network/test/integration/ProxyClientTsIntegrationTest.cpp b/packages/streamr-trackerless-network/test/integration/ProxyClientTsIntegrationTest.cpp index 12eac51d..8047fc4f 100644 --- a/packages/streamr-trackerless-network/test/integration/ProxyClientTsIntegrationTest.cpp +++ b/packages/streamr-trackerless-network/test/integration/ProxyClientTsIntegrationTest.cpp @@ -9,7 +9,9 @@ import streamr.dht.protos; import streamr.logger; import streamr.trackerlessnetwork.ProxyClient; import streamr.trackerlessnetwork.protos; -import streamr.utils; +import streamr.utils.BinaryUtils; +import streamr.utils.EthereumAddress; +import streamr.utils.StreamPartID; using ::dht::ConnectivityMethod; using ::dht::ConnectivityResponse; diff --git a/packages/streamr-utils/CMakeLists.txt b/packages/streamr-utils/CMakeLists.txt index 6e2499a8..8372e3be 100644 --- a/packages/streamr-utils/CMakeLists.txt +++ b/packages/streamr-utils/CMakeLists.txt @@ -41,19 +41,17 @@ endif() # project() because it inspects the compiler id. include(${CMAKE_CURRENT_SOURCE_DIR}/StreamrModules.cmake) -# Module façade (MODERNIZATION.md Part 2): the package is now a STATIC -# library whose module interface units re-export the public headers. -# #include consumers are unaffected; import consumers get the BMIs. +# CONSOLIDATED (MODERNIZATION.md Phase 2.6): one named sub-module per +# former public header (settled architecture: no umbrella; consumers and +# tests import the individual sub-modules). The include/ tree is gone — +# the module interface units are the source of truth, so the package no +# longer exports any include directory. +file(GLOB_RECURSE STREAMR_UTILS_MODULE_UNITS CONFIGURE_DEPENDS + ${CMAKE_CURRENT_SOURCE_DIR}/modules/*.cppm) streamr_add_module_library(streamr-utils - FILES - modules/streamr.utils.cppm - modules/streamr.utils-all.cppm) + FILES ${STREAMR_UTILS_MODULE_UNITS}) add_library(streamr::streamr-utils ALIAS streamr-utils) -target_include_directories( - streamr-utils PUBLIC $ - $) - find_library(SECP256K1_LIBRARY secp256k1) # secp256k1 >= 0.7 links the precomputed tables into the main library; the # separate secp256k1_precomputed archive no longer exists. diff --git a/packages/streamr-utils/include/streamr-utils/Uuid.hpp b/packages/streamr-utils/include/streamr-utils/Uuid.hpp deleted file mode 100644 index de521d94..00000000 --- a/packages/streamr-utils/include/streamr-utils/Uuid.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef STREAMR_UTILS_UUID_HPP -#define STREAMR_UTILS_UUID_HPP - -#include -#include -#include -namespace streamr::utils { - -class Uuid { -public: - static std::string v4() { - boost::uuids::uuid uuid = boost::uuids::random_generator()(); - return boost::uuids::to_string(uuid); - } -}; - -} // namespace streamr::utils - -#endif // STREAMR_UTILS_UUID_HPP \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/toCoroTask.hpp b/packages/streamr-utils/include/streamr-utils/toCoroTask.hpp deleted file mode 100644 index 73239e94..00000000 --- a/packages/streamr-utils/include/streamr-utils/toCoroTask.hpp +++ /dev/null @@ -1,17 +0,0 @@ -#ifndef STREAMR_UTILS_TOCOROTASK_HPP -#define STREAMR_UTILS_TOCOROTASK_HPP - -#include - -namespace streamr::utils { - -template -inline auto toCoroTask(F&& fn) -> folly::coro::Task> { - return folly::coro::co_invoke( - [fn]() -> folly::coro::Task> { - co_return fn(); - }); -} - -} // namespace streamr::utils -#endif // STREAMR_UTILS_TOCOROTASK_HPP \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/toEthereumAddressOrENSName.hpp b/packages/streamr-utils/include/streamr-utils/toEthereumAddressOrENSName.hpp deleted file mode 100644 index 4a68fbac..00000000 --- a/packages/streamr-utils/include/streamr-utils/toEthereumAddressOrENSName.hpp +++ /dev/null @@ -1,21 +0,0 @@ -#ifndef STREAMR_UTILS_TO_ETHEREUM_ADDRESS_OR_ENS_NAME_HPP -#define STREAMR_UTILS_TO_ETHEREUM_ADDRESS_OR_ENS_NAME_HPP - -#include -#include -#include "streamr-utils/ENSName.hpp" -#include "streamr-utils/EthereumAddress.hpp" - -namespace streamr::utils { - -inline std::variant toEthereumAddressOrENSName( - std::string_view str) { - if (isENSNameFormatIgnoreCase(str)) { - return toENSName(str); - } - return toEthereumAddress(str); -} - -} // namespace streamr::utils - -#endif // STREAMR_UTILS_TO_ETHEREUM_ADDRESS_OR_ENS_NAME_HPP diff --git a/packages/streamr-utils/lint.sh b/packages/streamr-utils/lint.sh index 2355dde0..ca3e1dd0 100755 --- a/packages/streamr-utils/lint.sh +++ b/packages/streamr-utils/lint.sh @@ -17,11 +17,14 @@ clangd-tidy -p ./build $TIDY_FILES echo "Running clang-format --dry-run on $FILES" ../../run-clang-format.py $FILES -# Module interface units: format check only. clangd-tidy is not run on -# .cppm files (headers remain the fully linted source of truth during the -# façade migration; clangd modules support is still experimental). +# CONSOLIDATED (MODERNIZATION.md Phase 2.6): the include/ tree is gone — +# the code lives in the module interface units, which are linted with +# clangd-tidy as the source of truth. MODULE_FILES=$(find ./modules -type f -name "*.cppm" 2>/dev/null | xargs echo) if [ -n "$MODULE_FILES" ]; then + echo "Running clangd-tidy on $MODULE_FILES" + clangd-tidy -p ./build $MODULE_FILES + echo "Running clang-format --dry-run on $MODULE_FILES" ../../run-clang-format.py $MODULE_FILES fi diff --git a/packages/streamr-utils/include/streamr-utils/AbortController.hpp b/packages/streamr-utils/modules/AbortController.cppm similarity index 73% rename from packages/streamr-utils/include/streamr-utils/AbortController.hpp rename to packages/streamr-utils/modules/AbortController.cppm index e8fb4c8b..488b195f 100644 --- a/packages/streamr-utils/include/streamr-utils/AbortController.hpp +++ b/packages/streamr-utils/modules/AbortController.cppm @@ -1,10 +1,19 @@ -#ifndef STREAMR_UTILS_ABORT_CONTROLLER_HPP -#define STREAMR_UTILS_ABORT_CONTROLLER_HPP - +// Module streamr.utils.AbortController +// CONSOLIDATED from the former header +// streamr-utils/AbortController.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; + +#include +#include +#include #include -#include "streamr-eventemitter/EventEmitter.hpp" -namespace streamr::utils { +export module streamr.utils.AbortController; + +import streamr.eventemitter; + +export namespace streamr::utils { using streamr::eventemitter::Event; using streamr::eventemitter::EventEmitter; @@ -51,5 +60,4 @@ class AbortController { AbortSignal& getSignal() { return signal; } }; -} // namespace streamr::utils -#endif // STREAMR_UTILS_ABORT_CONTROLLER_HPP \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/AbortableTimers.hpp b/packages/streamr-utils/modules/AbortableTimers.cppm similarity index 82% rename from packages/streamr-utils/include/streamr-utils/AbortableTimers.hpp rename to packages/streamr-utils/modules/AbortableTimers.cppm index 95339cbe..679526b4 100644 --- a/packages/streamr-utils/include/streamr-utils/AbortableTimers.hpp +++ b/packages/streamr-utils/modules/AbortableTimers.cppm @@ -1,10 +1,21 @@ -#ifndef STREAMR_UTILS_ABORTABLE_TIMERS_HPP -#define STREAMR_UTILS_ABORTABLE_TIMERS_HPP +// Module streamr.utils.AbortableTimers +// CONSOLIDATED from the former header +// streamr-utils/AbortableTimers.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; +#include +#include +#include +#include +#include #include -#include "AbortController.hpp" -namespace streamr::utils { +export module streamr.utils.AbortableTimers; + +import streamr.utils.AbortController; + +export namespace streamr::utils { using streamr::utils::AbortSignal; using streamr::utils::abortsignalevents::Aborted; @@ -73,5 +84,4 @@ class AbortableTimers { } }; -} // namespace streamr::utils -#endif // STREAMR_UTILS_ABORTABLE_TIMERS_HPP \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/BinaryUtils.hpp b/packages/streamr-utils/modules/BinaryUtils.cppm similarity index 79% rename from packages/streamr-utils/include/streamr-utils/BinaryUtils.hpp rename to packages/streamr-utils/modules/BinaryUtils.cppm index 2afc9cfb..1c1313b9 100644 --- a/packages/streamr-utils/include/streamr-utils/BinaryUtils.hpp +++ b/packages/streamr-utils/modules/BinaryUtils.cppm @@ -1,10 +1,16 @@ -#ifndef STREAMR_UTILS_BINARYUTILS_HPP -#define STREAMR_UTILS_BINARYUTILS_HPP +// Module streamr.utils.BinaryUtils +// CONSOLIDATED from the former header +// streamr-utils/BinaryUtils.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; +#include #include #include -namespace streamr::utils { +export module streamr.utils.BinaryUtils; + +export namespace streamr::utils { class BinaryUtils { public: @@ -43,6 +49,4 @@ class BinaryUtils { } }; -} // namespace streamr::utils - -#endif // STREAMR_UTILS_BINARYUTILS_HPP \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/Branded.hpp b/packages/streamr-utils/modules/Branded.cppm similarity index 94% rename from packages/streamr-utils/include/streamr-utils/Branded.hpp rename to packages/streamr-utils/modules/Branded.cppm index 6895bac8..5414a293 100644 --- a/packages/streamr-utils/include/streamr-utils/Branded.hpp +++ b/packages/streamr-utils/modules/Branded.cppm @@ -1,10 +1,16 @@ -#ifndef STREAMR_UTILS_BRANDED_HPP -#define STREAMR_UTILS_BRANDED_HPP +// Module streamr.utils.Branded +// CONSOLIDATED from the former header +// streamr-utils/Branded.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; +#include #include #include -namespace streamr::utils { +export module streamr.utils.Branded; + +export namespace streamr::utils { template using BrandString = std::integer_sequence; @@ -205,6 +211,4 @@ class Branded { bool operator>=(const T& other) const { return value >= other; } }; -} // namespace streamr::utils - -#endif // STREAMR_UTILS_BRANDED_HPP +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/ENSName.hpp b/packages/streamr-utils/modules/ENSName.cppm similarity index 64% rename from packages/streamr-utils/include/streamr-utils/ENSName.hpp rename to packages/streamr-utils/modules/ENSName.cppm index 82084d92..0643373e 100644 --- a/packages/streamr-utils/include/streamr-utils/ENSName.hpp +++ b/packages/streamr-utils/modules/ENSName.cppm @@ -1,12 +1,20 @@ -#ifndef STREAMR_UTILS_ENS_NAME_HPP -#define STREAMR_UTILS_ENS_NAME_HPP +// Module streamr.utils.ENSName +// CONSOLIDATED from the former header +// streamr-utils/ENSName.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include +#include +#include -#include "streamr-utils/Branded.hpp" -namespace streamr::utils { +export module streamr.utils.ENSName; + +import streamr.utils.Branded; + +export namespace streamr::utils { inline bool isENSNameFormatIgnoreCase(std::string_view str) { return str.contains('.'); @@ -25,5 +33,4 @@ inline ENSName toENSName(std::string_view str) { } throw std::runtime_error("not a valid ENS name: " + std::string(str)); } -} // namespace streamr::utils -#endif // STREAMR_UTILS_ENS_NAME_HPP +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/EnableSharedFromThis.hpp b/packages/streamr-utils/modules/EnableSharedFromThis.cppm similarity index 77% rename from packages/streamr-utils/include/streamr-utils/EnableSharedFromThis.hpp rename to packages/streamr-utils/modules/EnableSharedFromThis.cppm index 13dcc723..6ed05f82 100644 --- a/packages/streamr-utils/include/streamr-utils/EnableSharedFromThis.hpp +++ b/packages/streamr-utils/modules/EnableSharedFromThis.cppm @@ -1,9 +1,14 @@ -#ifndef ENABLE_SHARED_FROM_THIS_HPP -#define ENABLE_SHARED_FROM_THIS_HPP +// Module streamr.utils.EnableSharedFromThis +// CONSOLIDATED from the former header +// streamr-utils/EnableSharedFromThis.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include -namespace streamr::utils { +export module streamr.utils.EnableSharedFromThis; + +export namespace streamr::utils { // The base class is needed to allow multiple inheritance from // EnableSharedFromThis. @@ -30,5 +35,3 @@ struct EnableSharedFromThis : virtual public EnableSharedFromThisBase { }; } // namespace streamr::utils - -#endif diff --git a/packages/streamr-utils/include/streamr-utils/EthereumAddress.hpp b/packages/streamr-utils/modules/EthereumAddress.cppm similarity index 70% rename from packages/streamr-utils/include/streamr-utils/EthereumAddress.hpp rename to packages/streamr-utils/modules/EthereumAddress.cppm index 052cb572..f0795b91 100644 --- a/packages/streamr-utils/include/streamr-utils/EthereumAddress.hpp +++ b/packages/streamr-utils/modules/EthereumAddress.cppm @@ -1,14 +1,19 @@ -#ifndef STREAMR_UTILS_ETHEREUM_ADDRESS_HPP -#define STREAMR_UTILS_ETHEREUM_ADDRESS_HPP +// Module streamr.utils.EthereumAddress +// CONSOLIDATED from the former header +// streamr-utils/EthereumAddress.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include #include -#include "streamr-utils/Branded.hpp" +export module streamr.utils.EthereumAddress; -namespace streamr::utils { +import streamr.utils.Branded; + +export namespace streamr::utils { using EthereumAddress = Branded; @@ -27,5 +32,3 @@ inline EthereumAddress toEthereumAddress(std::string_view str) { } } // namespace streamr::utils - -#endif // STREAMR_UTILS_ETHEREUM_ADDRESS_HPP \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/Ipv4Helper.hpp b/packages/streamr-utils/modules/Ipv4Helper.cppm similarity index 66% rename from packages/streamr-utils/include/streamr-utils/Ipv4Helper.hpp rename to packages/streamr-utils/modules/Ipv4Helper.cppm index ab73b56a..9a8fb69e 100644 --- a/packages/streamr-utils/include/streamr-utils/Ipv4Helper.hpp +++ b/packages/streamr-utils/modules/Ipv4Helper.cppm @@ -1,11 +1,16 @@ -#ifndef STREAMR_UTILS_IPV4_HELPER_HPP -#define STREAMR_UTILS_IPV4_HELPER_HPP +// Module streamr.utils.Ipv4Helper +// CONSOLIDATED from the former header +// streamr-utils/Ipv4Helper.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include -namespace streamr::utils { +export module streamr.utils.Ipv4Helper; + +export namespace streamr::utils { class Ipv4Helper { public: @@ -22,5 +27,3 @@ class Ipv4Helper { }; } // namespace streamr::utils - -#endif // STREAMR_UTILS_IPV4_HELPER_HPP \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/ReplayEventEmitterWrapper.hpp b/packages/streamr-utils/modules/ReplayEventEmitterWrapper.cppm similarity index 92% rename from packages/streamr-utils/include/streamr-utils/ReplayEventEmitterWrapper.hpp rename to packages/streamr-utils/modules/ReplayEventEmitterWrapper.cppm index 0e43b807..3038512d 100644 --- a/packages/streamr-utils/include/streamr-utils/ReplayEventEmitterWrapper.hpp +++ b/packages/streamr-utils/modules/ReplayEventEmitterWrapper.cppm @@ -1,14 +1,19 @@ -#ifndef STREAMR_UTILS_REPLAY_EVENT_EMITTER_WRAPPER_HPP -#define STREAMR_UTILS_REPLAY_EVENT_EMITTER_WRAPPER_HPP +// Module streamr.utils.ReplayEventEmitterWrapper +// CONSOLIDATED from the former header +// streamr-utils/ReplayEventEmitterWrapper.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include #include -#include "streamr-eventemitter/EventEmitter.hpp" +export module streamr.utils.ReplayEventEmitterWrapper; -namespace streamr::utils { +import streamr.eventemitter; + +export namespace streamr::utils { using streamr::eventemitter::BoundEvent; using streamr::eventemitter::EventEmitter; @@ -117,5 +122,3 @@ makeReplayEventEmitterWrapper(EventEmitter& eventEmitter) { } } // namespace streamr::utils - -#endif // STREAMR_UTILS_REPLAY_EVENT_EMITTER_WRAPPER_HPP diff --git a/packages/streamr-utils/include/streamr-utils/RetryUtils.hpp b/packages/streamr-utils/modules/RetryUtils.cppm similarity index 76% rename from packages/streamr-utils/include/streamr-utils/RetryUtils.hpp rename to packages/streamr-utils/modules/RetryUtils.cppm index 70652daa..1f36179c 100644 --- a/packages/streamr-utils/include/streamr-utils/RetryUtils.hpp +++ b/packages/streamr-utils/modules/RetryUtils.cppm @@ -1,15 +1,26 @@ -#ifndef STREAMR_UTILS_RETRY_UTILS_HPP -#define STREAMR_UTILS_RETRY_UTILS_HPP +// Module streamr.utils.RetryUtils +// CONSOLIDATED from the former header +// streamr-utils/RetryUtils.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; +#include +#include +#include #include +#include #include #include #include #include #include -#include "streamr-logger/SLogger.hpp" -#include "streamr-utils/AbortController.hpp" -namespace streamr::utils { + +export module streamr.utils.RetryUtils; + +import streamr.logger; +import streamr.utils.AbortController; + +export namespace streamr::utils { using streamr::logger::SLogger; @@ -45,6 +56,4 @@ class RetryUtils { } } }; -} // namespace streamr::utils - -#endif // STREAMR_UTILS_RETRY_UTILS_HPP \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/SigningUtils.hpp b/packages/streamr-utils/modules/SigningUtils.cppm similarity index 85% rename from packages/streamr-utils/include/streamr-utils/SigningUtils.hpp rename to packages/streamr-utils/modules/SigningUtils.cppm index c5ae7b8b..97a45bd1 100644 --- a/packages/streamr-utils/include/streamr-utils/SigningUtils.hpp +++ b/packages/streamr-utils/modules/SigningUtils.cppm @@ -1,10 +1,14 @@ -#ifndef STREAMR_UTILS_SIGNINGUTILS_HPP -#define STREAMR_UTILS_SIGNINGUTILS_HPP +// Module streamr.utils.SigningUtils +// CONSOLIDATED from the former header +// streamr-utils/SigningUtils.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include #include +#include #include #include #include @@ -13,9 +17,12 @@ #include #include #include -#include "streamr-utils/BinaryUtils.hpp" -namespace streamr::utils { +export module streamr.utils.SigningUtils; + +import streamr.utils.BinaryUtils; + +export namespace streamr::utils { using streamr::utils::BinaryUtils; @@ -68,6 +75,4 @@ class SigningUtils { } }; -} // namespace streamr::utils - -#endif // STREAMR_UTILS_SIGNINGUTILS_HPP +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/StreamID.hpp b/packages/streamr-utils/modules/StreamID.cppm similarity index 86% rename from packages/streamr-utils/include/streamr-utils/StreamID.hpp rename to packages/streamr-utils/modules/StreamID.cppm index c1c6e0ad..309a3b2b 100644 --- a/packages/streamr-utils/include/streamr-utils/StreamID.hpp +++ b/packages/streamr-utils/modules/StreamID.cppm @@ -1,16 +1,24 @@ -#ifndef STREAMR_UTILS_STREAM_ID_HPP -#define STREAMR_UTILS_STREAM_ID_HPP +// Module streamr.utils.StreamID +// CONSOLIDATED from the former header +// streamr-utils/StreamID.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include +#include +#include #include -#include "streamr-utils/Branded.hpp" -#include "streamr-utils/ENSName.hpp" -#include "streamr-utils/EthereumAddress.hpp" -#include "streamr-utils/toEthereumAddressOrENSName.hpp" -namespace streamr::utils { +export module streamr.utils.StreamID; + +import streamr.utils.Branded; +import streamr.utils.ENSName; +import streamr.utils.EthereumAddress; +import streamr.utils.toEthereumAddressOrENSName; + +export namespace streamr::utils { using StreamID = Branded; @@ -93,6 +101,4 @@ class StreamIDUtils { } }; -} // namespace streamr::utils - -#endif // STREAMR_UTILS_STREAM_ID_HPP \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/StreamPartID.hpp b/packages/streamr-utils/modules/StreamPartID.cppm similarity index 81% rename from packages/streamr-utils/include/streamr-utils/StreamPartID.hpp rename to packages/streamr-utils/modules/StreamPartID.cppm index d14aa78a..407c53fe 100644 --- a/packages/streamr-utils/include/streamr-utils/StreamPartID.hpp +++ b/packages/streamr-utils/modules/StreamPartID.cppm @@ -1,13 +1,22 @@ -#ifndef STREAMR_UTILS_STREAM_PART_ID_HPP -#define STREAMR_UTILS_STREAM_PART_ID_HPP +// Module streamr.utils.StreamPartID +// CONSOLIDATED from the former header +// streamr-utils/StreamPartID.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include +#include +#include #include -#include "streamr-utils/Branded.hpp" -#include "streamr-utils/StreamID.hpp" -#include "streamr-utils/partition.hpp" +#include -namespace streamr::utils { +export module streamr.utils.StreamPartID; + +import streamr.utils.Branded; +import streamr.utils.StreamID; +import streamr.utils.partition; + +export namespace streamr::utils { inline constexpr auto DELIMITER = "#"; // NOLINT @@ -58,6 +67,4 @@ class StreamPartIDUtils { } }; -} // namespace streamr::utils - -#endif // STREAMR_UTILS_STREAM_PART_ID_HPP \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/modules/Uuid.cppm b/packages/streamr-utils/modules/Uuid.cppm new file mode 100644 index 00000000..a32672ff --- /dev/null +++ b/packages/streamr-utils/modules/Uuid.cppm @@ -0,0 +1,24 @@ +// Module streamr.utils.Uuid +// CONSOLIDATED from the former header +// streamr-utils/Uuid.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; + +#include +#include +#include +#include + +export module streamr.utils.Uuid; + +export namespace streamr::utils { + +class Uuid { +public: + static std::string v4() { + boost::uuids::uuid uuid = boost::uuids::random_generator()(); + return boost::uuids::to_string(uuid); + } +}; + +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/collect.hpp b/packages/streamr-utils/modules/collect.cppm similarity index 76% rename from packages/streamr-utils/include/streamr-utils/collect.hpp rename to packages/streamr-utils/modules/collect.cppm index f54529b0..88addc9b 100644 --- a/packages/streamr-utils/include/streamr-utils/collect.hpp +++ b/packages/streamr-utils/modules/collect.cppm @@ -1,13 +1,21 @@ -#ifndef STREAMR_UTILS_COLLECT_HPP -#define STREAMR_UTILS_COLLECT_HPP +// Module streamr.utils.collect +// CONSOLIDATED from the former header +// streamr-utils/collect.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; +#include #include +#include #include #include #include -#include "streamr-utils/toCoroTask.hpp" -namespace streamr::utils { +export module streamr.utils.collect; + +import streamr.utils.toCoroTask; + +export namespace streamr::utils { using streamr::utils::toCoroTask; @@ -41,6 +49,4 @@ inline auto collect(Tasks&&... tasks) }(std::forward(tasks)))...); } -} // namespace streamr::utils - -#endif // STREAMR_UTILS_COLLECT_HPP +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/partition.hpp b/packages/streamr-utils/modules/partition.cppm similarity index 76% rename from packages/streamr-utils/include/streamr-utils/partition.hpp rename to packages/streamr-utils/modules/partition.cppm index 22712531..97919dc7 100644 --- a/packages/streamr-utils/include/streamr-utils/partition.hpp +++ b/packages/streamr-utils/modules/partition.cppm @@ -1,12 +1,17 @@ -#ifndef STREAMR_UTILS_PARTITION_HPP -#define STREAMR_UTILS_PARTITION_HPP +// Module streamr.utils.partition +// CONSOLIDATED from the former header +// streamr-utils/partition.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include #include -namespace streamr::utils { +export module streamr.utils.partition; + +export namespace streamr::utils { inline constexpr auto MAX_PARTITION_COUNT = 100; // NOLINT @@ -31,5 +36,3 @@ inline void ensureValidStreamPartitionCount( } } // namespace streamr::utils - -#endif // STREAMR_UTILS_PARTITION_HPP \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/runAndWaitForEvents.hpp b/packages/streamr-utils/modules/runAndWaitForEvents.cppm similarity index 76% rename from packages/streamr-utils/include/streamr-utils/runAndWaitForEvents.hpp rename to packages/streamr-utils/modules/runAndWaitForEvents.cppm index 02ddd0c3..d1f072c0 100644 --- a/packages/streamr-utils/include/streamr-utils/runAndWaitForEvents.hpp +++ b/packages/streamr-utils/modules/runAndWaitForEvents.cppm @@ -1,13 +1,25 @@ -#ifndef STREAMR_UTILS_RUN_AND_WAIT_FOR_EVENTS_HPP -#define STREAMR_UTILS_RUN_AND_WAIT_FOR_EVENTS_HPP +// Module streamr.utils.runAndWaitForEvents +// CONSOLIDATED from the former header +// streamr-utils/runAndWaitForEvents.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; +#include +#include +#include +#include +#include #include #include #include -#include "streamr-utils/ReplayEventEmitterWrapper.hpp" -#include "streamr-utils/waitForEvent.hpp" -namespace streamr::utils { +export module streamr.utils.runAndWaitForEvents; + +import streamr.eventemitter; +import streamr.utils.ReplayEventEmitterWrapper; +import streamr.utils.waitForEvent; + +export namespace streamr::utils { using streamr::eventemitter::EventEmitter; using streamr::eventemitter::HandlerToken; @@ -50,6 +62,4 @@ inline void runAndWaitForEvents( replayEventEmitterWrappers); } -} // namespace streamr::utils - -#endif // STREAMR_UTILS_RUN_AND_WAIT_FOR_EVENTS_HPP +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/modules/streamr.utils-all.cppm b/packages/streamr-utils/modules/streamr.utils-all.cppm deleted file mode 100644 index 8689c142..00000000 --- a/packages/streamr-utils/modules/streamr.utils-all.cppm +++ /dev/null @@ -1,192 +0,0 @@ -// Coarse façade partition over ALL public headers of streamr-utils. -// One partition (instead of one per header) keeps the number of -// module units — and thus repeated global-module-fragment parses -// of the expensive header stacks — minimal during the façade -// stage (measured at the Phase 2.4 bench checkpoint). Per-header -// granularity returns at consolidation if needed. -module; - -#include "streamr-utils/AbortController.hpp" -#include "streamr-utils/AbortableTimers.hpp" -#include "streamr-utils/BinaryUtils.hpp" -#include "streamr-utils/Branded.hpp" -#include "streamr-utils/ENSName.hpp" -#include "streamr-utils/EnableSharedFromThis.hpp" -#include "streamr-utils/EthereumAddress.hpp" -#include "streamr-utils/Ipv4Helper.hpp" -#include "streamr-utils/ReplayEventEmitterWrapper.hpp" -#include "streamr-utils/RetryUtils.hpp" -#include "streamr-utils/SigningUtils.hpp" -#include "streamr-utils/StreamID.hpp" -#include "streamr-utils/StreamPartID.hpp" -#include "streamr-utils/Uuid.hpp" -#include "streamr-utils/collect.hpp" -#include "streamr-utils/partition.hpp" -#include "streamr-utils/runAndWaitForEvents.hpp" -#include "streamr-utils/toCoroTask.hpp" -#include "streamr-utils/toEthereumAddressOrENSName.hpp" -#include "streamr-utils/waitForCondition.hpp" -#include "streamr-utils/waitForEvent.hpp" - -export module streamr.utils:all; - -export namespace streamr::utils::abortsignalevents { - -using streamr::utils::abortsignalevents::Aborted; - -} // namespace streamr::utils::abortsignalevents - -export namespace streamr::utils { - -using streamr::utils::AbortController; -using streamr::utils::AbortSignal; -using streamr::utils::AbortSignalEvents; -using streamr::utils::abortsignalevents::Aborted; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::AbortableTimers; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::BinaryUtils; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::Branded; -using streamr::utils::BrandString; -using streamr::utils::IntegralType; -using streamr::utils::NonIntegralType; -using streamr::utils::operator""_brand; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::ENSName; -using streamr::utils::isENSNameFormatIgnoreCase; -using streamr::utils::toENSName; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::EnableSharedFromThis; -using streamr::utils::EnableSharedFromThisBase; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::EthereumAddress; -using streamr::utils::toEthereumAddress; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::Ipv4Helper; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::createReplayEventEmitterWrapper; -using streamr::utils::makeReplayEventEmitterWrapper; -using streamr::utils::ReplayEventEmitterWrapper; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::RetryUtils; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::SigningUtils; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::StreamID; -using streamr::utils::StreamIDUtils; -using streamr::utils::toStreamID; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::DELIMITER; -using streamr::utils::StreamPartID; -using streamr::utils::StreamPartIDUtils; -using streamr::utils::toStreamPartID; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::Uuid; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::collect; -using streamr::utils::ResultType; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::ensureValidStreamPartitionCount; -using streamr::utils::ensureValidStreamPartitionIndex; -using streamr::utils::MAX_PARTITION_COUNT; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::runAndWaitForEvents; -using streamr::utils::runAndWaitForEventsDefaultTimeout; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::toCoroTask; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::toEthereumAddressOrENSName; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::ConditionMet; -using streamr::utils::defaultRetryInterval; -using streamr::utils::Poller; -using streamr::utils::PollerEvents; -using streamr::utils::waitForCondition; - -} // namespace streamr::utils - -export namespace streamr::utils { - -using streamr::utils::defaultTimeout; -using streamr::utils::remove_pointer; -using streamr::utils::Waiter; -using streamr::utils::waitForEvent; - -} // namespace streamr::utils diff --git a/packages/streamr-utils/modules/streamr.utils.cppm b/packages/streamr-utils/modules/streamr.utils.cppm deleted file mode 100644 index ba04976b..00000000 --- a/packages/streamr-utils/modules/streamr.utils.cppm +++ /dev/null @@ -1,4 +0,0 @@ -// Primary module interface unit of streamr.utils. -export module streamr.utils; - -export import :all; diff --git a/packages/streamr-utils/modules/toCoroTask.cppm b/packages/streamr-utils/modules/toCoroTask.cppm new file mode 100644 index 00000000..ef5caf22 --- /dev/null +++ b/packages/streamr-utils/modules/toCoroTask.cppm @@ -0,0 +1,22 @@ +// Module streamr.utils.toCoroTask +// CONSOLIDATED from the former header +// streamr-utils/toCoroTask.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; + +#include +#include + +export module streamr.utils.toCoroTask; + +export namespace streamr::utils { + +template +inline auto toCoroTask(F&& fn) -> folly::coro::Task> { + return folly::coro::co_invoke( + [fn]() -> folly::coro::Task> { + co_return fn(); + }); +} + +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/modules/toEthereumAddressOrENSName.cppm b/packages/streamr-utils/modules/toEthereumAddressOrENSName.cppm new file mode 100644 index 00000000..a40c0f9d --- /dev/null +++ b/packages/streamr-utils/modules/toEthereumAddressOrENSName.cppm @@ -0,0 +1,26 @@ +// Module streamr.utils.toEthereumAddressOrENSName +// CONSOLIDATED from the former header +// streamr-utils/toEthereumAddressOrENSName.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; + +#include +#include +#include + +export module streamr.utils.toEthereumAddressOrENSName; + +import streamr.utils.ENSName; +import streamr.utils.EthereumAddress; + +export namespace streamr::utils { + +inline std::variant toEthereumAddressOrENSName( + std::string_view str) { + if (isENSNameFormatIgnoreCase(str)) { + return toENSName(str); + } + return toEthereumAddress(str); +} + +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/waitForCondition.hpp b/packages/streamr-utils/modules/waitForCondition.cppm similarity index 73% rename from packages/streamr-utils/include/streamr-utils/waitForCondition.hpp rename to packages/streamr-utils/modules/waitForCondition.cppm index 68ae5dcb..584bf26f 100644 --- a/packages/streamr-utils/include/streamr-utils/waitForCondition.hpp +++ b/packages/streamr-utils/modules/waitForCondition.cppm @@ -1,15 +1,24 @@ -#ifndef STREAMR_UTILS_WAITFORCONDITION_HPP -#define STREAMR_UTILS_WAITFORCONDITION_HPP +// Module streamr.utils.waitForCondition +// CONSOLIDATED from the former header +// streamr-utils/waitForCondition.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include +#include +#include +#include #include #include -#include "streamr-eventemitter/EventEmitter.hpp" -#include "streamr-utils/AbortController.hpp" -#include "streamr-utils/AbortableTimers.hpp" -#include "streamr-utils/waitForEvent.hpp" -namespace streamr::utils { +export module streamr.utils.waitForCondition; + +import streamr.eventemitter; +import streamr.utils.AbortController; +import streamr.utils.AbortableTimers; +import streamr.utils.waitForEvent; + +export namespace streamr::utils { using streamr::eventemitter::Event; using streamr::eventemitter::ReplayEventEmitter; @@ -53,6 +62,4 @@ inline folly::coro::Task waitForCondition( co_await waitForEvent(&poller, timeout, abortSignal); } -} // namespace streamr::utils - -#endif // STREAMR_UTILS_WAITFORCONDITION_HPP \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/include/streamr-utils/waitForEvent.hpp b/packages/streamr-utils/modules/waitForEvent.cppm similarity index 84% rename from packages/streamr-utils/include/streamr-utils/waitForEvent.hpp rename to packages/streamr-utils/modules/waitForEvent.cppm index 2fd29ab2..317d1231 100644 --- a/packages/streamr-utils/include/streamr-utils/waitForEvent.hpp +++ b/packages/streamr-utils/modules/waitForEvent.cppm @@ -1,14 +1,22 @@ -#ifndef STREAMR_UTILS_WAITFOREVENT_HPP -#define STREAMR_UTILS_WAITFOREVENT_HPP +// Module streamr.utils.waitForEvent +// CONSOLIDATED from the former header +// streamr-utils/waitForEvent.hpp (MODERNIZATION.md Phase 2.6): +// this file is now the source of truth. +module; #include #include #include +#include #include #include #include -#include "streamr-utils/AbortController.hpp" -namespace streamr::utils { + +export module streamr.utils.waitForEvent; + +import streamr.utils.AbortController; + +export namespace streamr::utils { template struct remove_pointer { // NOLINT @@ -63,5 +71,4 @@ waitForEvent( std::move(waiter.promiseContract.second), timeout); } -} // namespace streamr::utils -#endif \ No newline at end of file +} // namespace streamr::utils \ No newline at end of file diff --git a/packages/streamr-utils/test/unit/AbortControllerTest.cpp b/packages/streamr-utils/test/unit/AbortControllerTest.cpp index 8b9de33b..1d51eeac 100644 --- a/packages/streamr-utils/test/unit/AbortControllerTest.cpp +++ b/packages/streamr-utils/test/unit/AbortControllerTest.cpp @@ -1,6 +1,6 @@ #include -import streamr.utils; +import streamr.utils.AbortController; using streamr::utils::AbortController; diff --git a/packages/streamr-utils/test/unit/AbortableTimersTest.cpp b/packages/streamr-utils/test/unit/AbortableTimersTest.cpp index 130de0f4..103131d9 100644 --- a/packages/streamr-utils/test/unit/AbortableTimersTest.cpp +++ b/packages/streamr-utils/test/unit/AbortableTimersTest.cpp @@ -3,7 +3,8 @@ #include #include -import streamr.utils; +import streamr.utils.AbortController; +import streamr.utils.AbortableTimers; using streamr::utils::AbortableTimers; using streamr::utils::AbortController; diff --git a/packages/streamr-utils/test/unit/BinaryUtilsTest.cpp b/packages/streamr-utils/test/unit/BinaryUtilsTest.cpp index 315e9d85..ee4771d9 100644 --- a/packages/streamr-utils/test/unit/BinaryUtilsTest.cpp +++ b/packages/streamr-utils/test/unit/BinaryUtilsTest.cpp @@ -2,7 +2,7 @@ #include #include "gtest/gtest.h" -import streamr.utils; +import streamr.utils.BinaryUtils; using streamr::utils::BinaryUtils; diff --git a/packages/streamr-utils/test/unit/BrandedTest.cpp b/packages/streamr-utils/test/unit/BrandedTest.cpp index 918d9da3..86d09a74 100644 --- a/packages/streamr-utils/test/unit/BrandedTest.cpp +++ b/packages/streamr-utils/test/unit/BrandedTest.cpp @@ -1,6 +1,6 @@ #include -import streamr.utils; +import streamr.utils.Branded; using streamr::utils::Branded; using streamr::utils::operator""_brand; // NOLINT(misc-unused-using-decls) diff --git a/packages/streamr-utils/test/unit/ENSNameTest.cpp b/packages/streamr-utils/test/unit/ENSNameTest.cpp index 949e222b..7500da03 100644 --- a/packages/streamr-utils/test/unit/ENSNameTest.cpp +++ b/packages/streamr-utils/test/unit/ENSNameTest.cpp @@ -1,6 +1,6 @@ #include -import streamr.utils; +import streamr.utils.ENSName; using streamr::utils::ENSName; diff --git a/packages/streamr-utils/test/unit/EthereumAddressTest.cpp b/packages/streamr-utils/test/unit/EthereumAddressTest.cpp index 0c8ef5ef..796b3fa4 100644 --- a/packages/streamr-utils/test/unit/EthereumAddressTest.cpp +++ b/packages/streamr-utils/test/unit/EthereumAddressTest.cpp @@ -1,6 +1,6 @@ #include -import streamr.utils; +import streamr.utils.EthereumAddress; using streamr::utils::EthereumAddress; // NOLINT diff --git a/packages/streamr-utils/test/unit/ReplayEventEmitterWrapperTest.cpp b/packages/streamr-utils/test/unit/ReplayEventEmitterWrapperTest.cpp index a3f28ede..88392fd9 100644 --- a/packages/streamr-utils/test/unit/ReplayEventEmitterWrapperTest.cpp +++ b/packages/streamr-utils/test/unit/ReplayEventEmitterWrapperTest.cpp @@ -1,6 +1,6 @@ #include -import streamr.utils; +import streamr.utils.ReplayEventEmitterWrapper; using streamr::utils::ReplayEventEmitterWrapper; // NOLINT diff --git a/packages/streamr-utils/test/unit/RetryUtilsTest.cpp b/packages/streamr-utils/test/unit/RetryUtilsTest.cpp index bd45f5b2..b8bda2a5 100644 --- a/packages/streamr-utils/test/unit/RetryUtilsTest.cpp +++ b/packages/streamr-utils/test/unit/RetryUtilsTest.cpp @@ -1,6 +1,6 @@ #include -import streamr.utils; +import streamr.utils.RetryUtils; using streamr::utils::RetryUtils; // NOLINT diff --git a/packages/streamr-utils/test/unit/SigninUtilsTest.cpp b/packages/streamr-utils/test/unit/SigninUtilsTest.cpp deleted file mode 100644 index 2504c2da..00000000 --- a/packages/streamr-utils/test/unit/SigninUtilsTest.cpp +++ /dev/null @@ -1,33 +0,0 @@ -#include - -import streamr.utils; - -using streamr::utils::BinaryUtils; -using streamr::utils::SigningUtils; - -TEST(SigninUtilsTest, createSignature) { - const std::string privateKeyHex = - "23bead9b499af21c4c16e4511b3b6b08c3e22e76e0591f5ab5ba8d4c3a5b1820"; - const std::string expectedSignatureHex = - "787cd72924153c88350e808de68b68c88030cbc34d053a5c696a5893d5e6fec1687c1b6205ec99aeb3375a81bf5cb8857ae39c1b55a41b32ed6399ae8da456a61b"; - const auto payload = std::string("data-to-sign"); - const auto signature = - SigningUtils::createSignature(payload, privateKeyHex); - EXPECT_EQ( - BinaryUtils::binaryStringToHex(signature).size(), - expectedSignatureHex.size()); - - EXPECT_EQ(BinaryUtils::binaryStringToHex(signature), expectedSignatureHex); -} - -TEST(SigninUtilsTest, hash) { - const std::string payloadHex = - "23bead9b499af21c4c16e4511b3b6b08c3e22e76e0591f5ab5ba8d4c3a5b1820"; - const std::string expectedHash = - "a80293a92b21fa34b4974bb5d48a2600599e5bfc569cc73c3cb5bb21613cd9fa"; - const auto hash = BinaryUtils::binaryStringToHex( - SigningUtils::hash(BinaryUtils::hexToBinaryString(payloadHex))); - std::string lowerCaseHash; - std::ranges::transform(hash, std::back_inserter(lowerCaseHash), ::tolower); - EXPECT_EQ(hash, expectedHash); -} \ No newline at end of file diff --git a/packages/streamr-utils/test/unit/SigningUtilsTest.cpp b/packages/streamr-utils/test/unit/SigningUtilsTest.cpp index 2504c2da..09d1dbc8 100644 --- a/packages/streamr-utils/test/unit/SigningUtilsTest.cpp +++ b/packages/streamr-utils/test/unit/SigningUtilsTest.cpp @@ -1,6 +1,7 @@ #include -import streamr.utils; +import streamr.utils.BinaryUtils; +import streamr.utils.SigningUtils; using streamr::utils::BinaryUtils; using streamr::utils::SigningUtils; diff --git a/packages/streamr-utils/test/unit/StreamIDTest.cpp b/packages/streamr-utils/test/unit/StreamIDTest.cpp index a62e0bb2..2f98bb6c 100644 --- a/packages/streamr-utils/test/unit/StreamIDTest.cpp +++ b/packages/streamr-utils/test/unit/StreamIDTest.cpp @@ -1,6 +1,6 @@ #include -import streamr.utils; +import streamr.utils.StreamID; using streamr::utils::StreamID; // NOLINT diff --git a/packages/streamr-utils/test/unit/StreamPartIDTest.cpp b/packages/streamr-utils/test/unit/StreamPartIDTest.cpp index 07c9cd7b..2bbb1642 100644 --- a/packages/streamr-utils/test/unit/StreamPartIDTest.cpp +++ b/packages/streamr-utils/test/unit/StreamPartIDTest.cpp @@ -1,6 +1,7 @@ #include -import streamr.utils; +import streamr.utils.StreamID; +import streamr.utils.StreamPartID; using streamr::utils::StreamID; using streamr::utils::StreamPartID; diff --git a/packages/streamr-utils/test/unit/collectTest.cpp b/packages/streamr-utils/test/unit/collectTest.cpp index 7ad18f1b..64cd6c5f 100644 --- a/packages/streamr-utils/test/unit/collectTest.cpp +++ b/packages/streamr-utils/test/unit/collectTest.cpp @@ -3,7 +3,7 @@ #include #include -import streamr.utils; +import streamr.utils.collect; using streamr::utils::collect; using streamr::utils::toCoroTask; diff --git a/packages/streamr-utils/test/unit/runAndWaitForEventsTest.cpp b/packages/streamr-utils/test/unit/runAndWaitForEventsTest.cpp index c788b08d..465bf24e 100644 --- a/packages/streamr-utils/test/unit/runAndWaitForEventsTest.cpp +++ b/packages/streamr-utils/test/unit/runAndWaitForEventsTest.cpp @@ -4,7 +4,7 @@ #include #include -import streamr.utils; +import streamr.utils.runAndWaitForEvents; import streamr.eventemitter; using streamr::eventemitter::Event; diff --git a/packages/streamr-utils/test/unit/toCoroTaskTest.cpp b/packages/streamr-utils/test/unit/toCoroTaskTest.cpp index 677096a5..af080a2d 100644 --- a/packages/streamr-utils/test/unit/toCoroTaskTest.cpp +++ b/packages/streamr-utils/test/unit/toCoroTaskTest.cpp @@ -2,7 +2,7 @@ #include #include -import streamr.utils; +import streamr.utils.toCoroTask; using streamr::utils::toCoroTask; diff --git a/packages/streamr-utils/test/unit/toEthereumAddressOrENSNameTest.cpp b/packages/streamr-utils/test/unit/toEthereumAddressOrENSNameTest.cpp index 767de2d1..3a459c24 100644 --- a/packages/streamr-utils/test/unit/toEthereumAddressOrENSNameTest.cpp +++ b/packages/streamr-utils/test/unit/toEthereumAddressOrENSNameTest.cpp @@ -2,7 +2,9 @@ #include #include -import streamr.utils; +import streamr.utils.toEthereumAddressOrENSName; +import streamr.utils.ENSName; +import streamr.utils.EthereumAddress; using streamr::utils::EthereumAddress; using streamr::utils::toEthereumAddressOrENSName; diff --git a/packages/streamr-utils/test/unit/waitForConditionTest.cpp b/packages/streamr-utils/test/unit/waitForConditionTest.cpp index 231020a7..27f6f16f 100644 --- a/packages/streamr-utils/test/unit/waitForConditionTest.cpp +++ b/packages/streamr-utils/test/unit/waitForConditionTest.cpp @@ -1,7 +1,8 @@ #include #include -import streamr.utils; +import streamr.utils.AbortController; +import streamr.utils.waitForCondition; using streamr::utils::AbortController; using streamr::utils::waitForCondition; diff --git a/packages/streamr-utils/test/unit/waitForEventTest.cpp b/packages/streamr-utils/test/unit/waitForEventTest.cpp index 16049b02..3feb5083 100644 --- a/packages/streamr-utils/test/unit/waitForEventTest.cpp +++ b/packages/streamr-utils/test/unit/waitForEventTest.cpp @@ -6,7 +6,8 @@ #include #include -import streamr.utils; +import streamr.utils.AbortController; +import streamr.utils.waitForEvent; import streamr.eventemitter; using streamr::eventemitter::Event;