mirror of https://github.com/waku-org/nwaku.git
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
This commit is contained in:
parent
c483acee35
commit
94947a8504
|
@ -69,7 +69,7 @@ suite "Waku Message - Content topics namespacing":
|
||||||
let err = ns.tryError()
|
let err = ns.tryError()
|
||||||
check:
|
check:
|
||||||
err.kind == ParsingErrorKind.InvalidFormat
|
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":
|
test "Parse content topic string - Invalid string: not namespaced":
|
||||||
## Given
|
## Given
|
||||||
|
|
|
@ -511,11 +511,12 @@ suite "Waku v2 Rest API - Relay":
|
||||||
|
|
||||||
let client = newRestHttpClient(initTAddress(restAddress, restPort))
|
let client = newRestHttpClient(initTAddress(restAddress, restPort))
|
||||||
|
|
||||||
|
let invalidContentTopic = "invalidContentTopic"
|
||||||
# When
|
# When
|
||||||
let response = await client.relayPostAutoMessagesV1(
|
let response = await client.relayPostAutoMessagesV1(
|
||||||
RelayWakuMessage(
|
RelayWakuMessage(
|
||||||
payload: base64.encode("TEST-PAYLOAD"),
|
payload: base64.encode("TEST-PAYLOAD"),
|
||||||
contentTopic: some("invalidContentTopic"),
|
contentTopic: some(invalidContentTopic),
|
||||||
timestamp: some(int64(2022)),
|
timestamp: some(int64(2022)),
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -525,7 +526,8 @@ suite "Waku v2 Rest API - Relay":
|
||||||
response.status == 400
|
response.status == 400
|
||||||
$response.contentType == $MIMETYPE_TEXT
|
$response.contentType == $MIMETYPE_TEXT
|
||||||
response.data ==
|
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.stop()
|
||||||
await restServer.closeWait()
|
await restServer.closeWait()
|
||||||
|
|
|
@ -149,6 +149,9 @@ proc setupProtocols(
|
||||||
conf.contentTopics.mapIt(node.wakuSharding.getShard(it).expect("Valid Shard"))
|
conf.contentTopics.mapIt(node.wakuSharding.getShard(it).expect("Valid Shard"))
|
||||||
let pubsubTopics = conf.pubsubTopics & shards
|
let pubsubTopics = conf.pubsubTopics & shards
|
||||||
|
|
||||||
|
debug "Shards created from content topics",
|
||||||
|
contentTopics = conf.contentTopics, shards = shards
|
||||||
|
|
||||||
let parsedMaxMsgSize = parseMsgSize(conf.maxMessageSize).valueOr:
|
let parsedMaxMsgSize = parseMsgSize(conf.maxMessageSize).valueOr:
|
||||||
return err("failed to parse 'max-num-bytes-msg-size' param: " & $error)
|
return err("failed to parse 'max-num-bytes-msg-size' param: " & $error)
|
||||||
|
|
||||||
|
|
|
@ -68,7 +68,9 @@ proc parse*(
|
||||||
## Autosharding adds 1 optional prefix `/<gen#>
|
## Autosharding adds 1 optional prefix `/<gen#>
|
||||||
|
|
||||||
if not topic.startsWith("/"):
|
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("/")
|
let parts = topic[1 ..< topic.len].split("/")
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue