mirror of
https://github.com/logos-messaging/logos-messaging-go-bindings.git
synced 2026-07-07 03:09:31 +00:00
fix(kernel): drop removed config keys + add a runnable example
Running against the single liblogosdelivery library surfaced a config drift: the consolidated WakuNodeConf strictly rejects unknown keys, and common.WakuConfig still emitted `legacyStore` (removed upstream, and sent unconditionally) and `host` (renamed to `listenAddress`). That failed node creation, so every kernel test that starts a node failed. Reconcile the config: - drop the LegacyStore field (and its two obsolete test references; the already-skipped TestCheckLegacyStore keeps compiling); - map Host to the `listenAddress` JSON key. Add examples/kernel: a small runnable check that drives the unified lifecycle (logosdelivery_create_node/start/stop/destroy) and a few kernel ops (version, listen addresses, is-online, relay subscribe/unsubscribe) over the single library. `go run ./examples/kernel` prints OK. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
d5d5a215ed
commit
3e7d1a41dd
80
examples/kernel/main.go
Normal file
80
examples/kernel/main.go
Normal file
@ -0,0 +1,80 @@
|
||||
// Command kernel is a small runnable check that the bindings work against the
|
||||
// single liblogosdelivery library: it drives the unified node lifecycle
|
||||
// (logosdelivery_create_node/start/stop/destroy) and a few low-level Kernel
|
||||
// (waku_*) operations through pkg/kernel.
|
||||
//
|
||||
// Build/run requires liblogosdelivery at link time, e.g.:
|
||||
//
|
||||
// export LOGOS_DELIVERY_DIR=/abs/path/to/logos-delivery # built with `make liblogosdelivery`
|
||||
// export CGO_CFLAGS="-I$LOGOS_DELIVERY_DIR/library"
|
||||
// export CGO_LDFLAGS="-L$LOGOS_DELIVERY_DIR/build -Wl,-rpath,$LOGOS_DELIVERY_DIR/build"
|
||||
// go run ./examples/kernel
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel"
|
||||
"github.com/logos-messaging/logos-delivery-go-bindings/pkg/kernel/common"
|
||||
)
|
||||
|
||||
func main() {
|
||||
const clusterID = 16
|
||||
|
||||
// A single, isolated relay node — no bootstrap/discovery needed.
|
||||
cfg := &common.WakuConfig{
|
||||
Relay: true,
|
||||
ClusterID: clusterID,
|
||||
Shards: []uint16{0},
|
||||
NumShardsInNetwork: 8,
|
||||
LogLevel: "ERROR",
|
||||
}
|
||||
|
||||
// StartWakuNode creates (logosdelivery_create_node) + starts
|
||||
// (logosdelivery_start_node) the node, allocating a free TCP port.
|
||||
node, err := kernel.StartWakuNode("kernel-example", cfg)
|
||||
if err != nil {
|
||||
log.Fatalf("start node: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
// logosdelivery_stop_node + logosdelivery_destroy
|
||||
if err := node.StopAndDestroy(); err != nil {
|
||||
log.Printf("stop/destroy: %v", err)
|
||||
}
|
||||
}()
|
||||
|
||||
// A few low-level kernel calls to prove the kernel surface links and runs
|
||||
// over the single library.
|
||||
version, err := node.Version() // waku_version
|
||||
if err != nil {
|
||||
log.Fatalf("version: %v", err)
|
||||
}
|
||||
log.Printf("node version: %s", version)
|
||||
|
||||
addrs, err := node.ListenAddresses() // waku_listen_addresses
|
||||
if err != nil {
|
||||
log.Fatalf("listen addresses: %v", err)
|
||||
}
|
||||
log.Printf("listening on: %v", addrs)
|
||||
|
||||
online, err := node.IsOnline() // waku_is_online
|
||||
if err != nil {
|
||||
log.Fatalf("is online: %v", err)
|
||||
}
|
||||
log.Printf("online: %v", online)
|
||||
|
||||
// Subscribe to / unsubscribe from a relay (pubsub) topic
|
||||
// (waku_relay_subscribe / waku_relay_unsubscribe).
|
||||
topic := kernel.FormatWakuRelayTopic(clusterID, 0)
|
||||
if err := node.RelaySubscribe(topic); err != nil {
|
||||
log.Fatalf("relay subscribe: %v", err)
|
||||
}
|
||||
log.Printf("subscribed to %s", topic)
|
||||
|
||||
if err := node.RelayUnsubscribe(topic); err != nil {
|
||||
log.Fatalf("relay unsubscribe: %v", err)
|
||||
}
|
||||
log.Printf("unsubscribed from %s", topic)
|
||||
|
||||
log.Print("OK — single liblogosdelivery library: node lifecycle + kernel ops work")
|
||||
}
|
||||
@ -1,11 +1,12 @@
|
||||
package common
|
||||
|
||||
type WakuConfig struct {
|
||||
Host string `json:"host,omitempty"`
|
||||
// Host is the LibP2P listening address; the consolidated WakuNodeConf calls
|
||||
// it listenAddress (the legacy `host` key was removed).
|
||||
Host string `json:"listenAddress,omitempty"`
|
||||
Nodekey string `json:"nodekey,omitempty"`
|
||||
Relay bool `json:"relay"`
|
||||
Store bool `json:"store,omitempty"`
|
||||
LegacyStore bool `json:"legacyStore"`
|
||||
Storenode string `json:"storenode,omitempty"`
|
||||
StoreMessageRetentionPolicy string `json:"storeMessageRetentionPolicy,omitempty"`
|
||||
StoreMessageDbUrl string `json:"storeMessageDbUrl,omitempty"`
|
||||
|
||||
@ -672,7 +672,6 @@ func TestStore(t *testing.T) {
|
||||
Shards: []uint16{64},
|
||||
Discv5UdpPort: udpPort,
|
||||
TcpPort: tcpPort,
|
||||
LegacyStore: false,
|
||||
}
|
||||
|
||||
senderNode, err := NewWakuNode(&senderNodeWakuConfig, "senderNode")
|
||||
@ -692,7 +691,6 @@ func TestStore(t *testing.T) {
|
||||
Shards: []uint16{64},
|
||||
Discv5UdpPort: udpPort,
|
||||
TcpPort: tcpPort,
|
||||
LegacyStore: false,
|
||||
}
|
||||
receiverNode, err := NewWakuNode(&receiverNodeWakuConfig, "receiverNode")
|
||||
require.NoError(t, err)
|
||||
|
||||
@ -837,7 +837,6 @@ func TestCheckLegacyStore(t *testing.T) {
|
||||
node2Config := DefaultWakuConfig
|
||||
node2Config.Relay = true
|
||||
node2Config.Store = true
|
||||
node2Config.LegacyStore = true
|
||||
|
||||
Debug("Creating Node2")
|
||||
node2, err := StartWakuNode("Node2", &node2Config)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user