From 94947a8504fd1c07a1a873321354198325688826 Mon Sep 17 00:00:00 2001 From: Darshan K <35736874+darshankabariya@users.noreply.github.com> Date: Thu, 20 Jun 2024 18:38:55 +0530 Subject: [PATCH] chore: better descriptive log (#2826) * chore: update logs with topic discription & debug msg * chore: update unit according to error msg * chore: update rest unit according to error msg * chore: add content-topic with debug msg --- tests/waku_core/test_namespaced_topics.nim | 2 +- tests/wakunode_rest/test_rest_relay.nim | 6 ++++-- waku/factory/node_factory.nim | 3 +++ waku/waku_core/topics/content_topic.nim | 4 +++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/waku_core/test_namespaced_topics.nim b/tests/waku_core/test_namespaced_topics.nim index 3344b56316..a0cf6ae5bb 100644 --- a/tests/waku_core/test_namespaced_topics.nim +++ b/tests/waku_core/test_namespaced_topics.nim @@ -69,7 +69,7 @@ suite "Waku Message - Content topics namespacing": let err = ns.tryError() check: err.kind == ParsingErrorKind.InvalidFormat - err.cause == "topic must start with slash" + err.cause == "content-topic '" & topic & "' must start with slash" test "Parse content topic string - Invalid string: not namespaced": ## Given diff --git a/tests/wakunode_rest/test_rest_relay.nim b/tests/wakunode_rest/test_rest_relay.nim index c672ee6e4f..d146521f53 100644 --- a/tests/wakunode_rest/test_rest_relay.nim +++ b/tests/wakunode_rest/test_rest_relay.nim @@ -511,11 +511,12 @@ suite "Waku v2 Rest API - Relay": let client = newRestHttpClient(initTAddress(restAddress, restPort)) + let invalidContentTopic = "invalidContentTopic" # When let response = await client.relayPostAutoMessagesV1( RelayWakuMessage( payload: base64.encode("TEST-PAYLOAD"), - contentTopic: some("invalidContentTopic"), + contentTopic: some(invalidContentTopic), timestamp: some(int64(2022)), ) ) @@ -525,7 +526,8 @@ suite "Waku v2 Rest API - Relay": response.status == 400 $response.contentType == $MIMETYPE_TEXT response.data == - "Failed to publish. Autosharding error: invalid format: topic must start with slash" + "Failed to publish. Autosharding error: invalid format: content-topic '" & + invalidContentTopic & "' must start with slash" await restServer.stop() await restServer.closeWait() diff --git a/waku/factory/node_factory.nim b/waku/factory/node_factory.nim index 89e955f9b5..9c442ad36a 100644 --- a/waku/factory/node_factory.nim +++ b/waku/factory/node_factory.nim @@ -149,6 +149,9 @@ proc setupProtocols( conf.contentTopics.mapIt(node.wakuSharding.getShard(it).expect("Valid Shard")) let pubsubTopics = conf.pubsubTopics & shards + debug "Shards created from content topics", + contentTopics = conf.contentTopics, shards = shards + let parsedMaxMsgSize = parseMsgSize(conf.maxMessageSize).valueOr: return err("failed to parse 'max-num-bytes-msg-size' param: " & $error) diff --git a/waku/waku_core/topics/content_topic.nim b/waku/waku_core/topics/content_topic.nim index 092c973b3e..8820da4715 100644 --- a/waku/waku_core/topics/content_topic.nim +++ b/waku/waku_core/topics/content_topic.nim @@ -68,7 +68,9 @@ proc parse*( ## Autosharding adds 1 optional prefix `/ if not topic.startsWith("/"): - return err(ParsingError.invalidFormat("topic must start with slash")) + return err( + ParsingError.invalidFormat("content-topic '" & topic & "' must start with slash") + ) let parts = topic[1 ..< topic.len].split("/")