NagyZoltanPeter 1fd25355e0
feat: waku api send (#3669)
* Introduce api/send
Added events and requests for support.
Reworked delivery_monitor into a featured devlivery_service, that
- supports relay publish and lightpush depending on configuration but with fallback options
- if available and configured it utilizes store api to confirm message delivery
- emits message delivery events accordingly

prepare for use in api_example

* Fix edge mode config and test added
* Fix some import issues, start and stop waku shall not throw exception but return with result properly
* Utlize sync RequestBroker, adapt to non-async broker usage and gcsafe where appropriate, removed leftover
* add api_example app to examples2
* Adapt after merge from master
* Adapt code for using broker context
* Fix brokerCtx settings for all usedbrokers, cover locked node init
* Various fixes upon test failures. Added initial of subscribe API and auto-subscribe for send api
* More test added
* Fix multi propagate event emit, fix fail send test case
* Fix rebase
* Fix PushMessageHandlers in tests
* adapt libwaku to api changes
* Fix relay test by adapting publish return error in case NoPeersToPublish
* Addressing all remaining review findings. Removed leftovers. Fixed loggings and typos
* Fix rln relay broker, missed brokerCtx
* Fix rest relay test failed, due to publish will fail if no peer avail
* ignore anvil test state file
* Make terst_wakunode_rln_relay broker context aware to fix
* Fix waku rln tests by having them broker context aware
* fix typo in test_app.nim
2026-01-30 01:06:00 +01:00

102 lines
2.3 KiB
Nim

{.used.}
import
testutils/unittests,
chronicles,
chronos,
libp2p/crypto/crypto,
libp2p/crypto/secp,
libp2p/multiaddress,
libp2p/switch
import ../testlib/wakucore, ../testlib/wakunode
include waku/factory/waku, waku/common/enr/typed_record
suite "Wakunode2 - Waku":
test "compilation version should be reported":
## Given
let conf = defaultTestWakuConf()
let waku = (waitFor Waku.new(conf)).valueOr:
raiseAssert error
## When
let version = waku.version
## Then
check:
version == git_version
suite "Wakunode2 - Waku initialization":
test "peer persistence setup should be successfully mounted":
## Given
var conf = defaultTestWakuConf()
conf.peerPersistence = true
let waku = (waitFor Waku.new(conf)).valueOr:
raiseAssert error
check:
not waku.node.peerManager.storage.isNil()
test "node setup is successful with default configuration":
## Given
var conf = defaultTestWakuConf()
## When
var waku = (waitFor Waku.new(conf)).valueOr:
raiseAssert error
(waitFor startWaku(addr waku)).isOkOr:
raiseAssert error
## Then
let node = waku.node
check:
not node.isNil()
node.wakuArchive.isNil()
node.wakuStore.isNil()
not node.wakuStoreClient.isNil()
not node.wakuRendezvous.isNil()
## Cleanup
(waitFor waku.stop()).isOkOr:
raiseAssert error
test "app properly handles dynamic port configuration":
## Given
var conf = defaultTestWakuConf()
conf.endpointConf.p2pTcpPort = Port(0)
## When
var waku = (waitFor Waku.new(conf)).valueOr:
raiseAssert error
(waitFor startWaku(addr waku)).isOkOr:
raiseAssert error
## Then
let
node = waku.node
typedNodeEnr = node.enr.toTyped()
assert typedNodeEnr.isOk(), $typedNodeEnr.error
let tcpPort = typedNodeEnr.value.tcp()
assert tcpPort.isSome()
check tcpPort.get() != 0
check:
# Waku started properly
not node.isNil()
node.wakuArchive.isNil()
node.wakuStore.isNil()
not node.wakuStoreClient.isNil()
not node.wakuRendezvous.isNil()
# DS structures are updated with dynamic ports
typedNodeEnr.get().tcp.get() != 0
## Cleanup
(waitFor waku.stop()).isOkOr:
raiseAssert error