|
1 | 1 | {.used.} |
2 | 2 |
|
3 | | -import std/[options, strscans], testutils/unittests, chronos, libp2p/crypto/crypto |
| 3 | +import |
| 4 | + std/[options, strscans], |
| 5 | + testutils/unittests, |
| 6 | + chronos, |
| 7 | + chronicles, |
| 8 | + libp2p/crypto/crypto |
4 | 9 |
|
5 | 10 | import |
6 | 11 | waku/[ |
@@ -307,6 +312,39 @@ suite "Waku Lightpush Client": |
307 | 312 | # Cleanup |
308 | 313 | await serverSwitch2.stop() |
309 | 314 |
|
| 315 | + asyncTest "Check timestamp is not zero": |
| 316 | + ## This test validates that, even the generated message has a timestamp of 0, |
| 317 | + ## the node will eventually set a timestamp when publishing the message. |
| 318 | + let |
| 319 | + zeroTimestamp = 0 |
| 320 | + meta = "TEST-META" |
| 321 | + message = fakeWakuMessage( |
| 322 | + payloads.ALPHABETIC, content_topics.CURRENT, meta, zeroTimestamp |
| 323 | + ) |
| 324 | + |
| 325 | + # When publishing a valid payload |
| 326 | + let publishResponse = |
| 327 | + await client.publish(some(pubsubTopic), message, serverRemotePeerInfo) |
| 328 | + |
| 329 | + # Then the message is received by the server |
| 330 | + discard await handlerFuture.withTimeout(FUTURE_TIMEOUT) |
| 331 | + assertResultOk publishResponse |
| 332 | + check handlerFuture.finished() |
| 333 | + |
| 334 | + # And the message is received with the correct topic and payload |
| 335 | + let (readPubsubTopic, readMessage) = handlerFuture.read() |
| 336 | + |
| 337 | + check: |
| 338 | + pubsubTopic == readPubsubTopic |
| 339 | + message.payload == readMessage.payload |
| 340 | + message.contentTopic == readMessage.contentTopic |
| 341 | + message.meta == readMessage.meta |
| 342 | + message.timestamp != readMessage.timestamp |
| 343 | + message.ephemeral == readMessage.ephemeral |
| 344 | + message.proof == readMessage.proof |
| 345 | + message.version == readMessage.version |
| 346 | + readMessage.timestamp > 0 |
| 347 | + |
310 | 348 | suite "Verification of PushResponse Payload": |
311 | 349 | asyncTest "Positive Responses": |
312 | 350 | # When sending a valid PushRequest |
|
0 commit comments