mirror of
https://github.com/logos-messaging/logos-delivery-rust-bindings.git
synced 2026-07-29 22:43:34 +00:00
feat: typed CBOR requests for send and channel_send
Bumps vendor to the typed SendRequest / ChannelSendRequest procs and updates the channels test to fill the typed struct instead of building a JSON string. send_async now takes SendRequest, channel_send_async takes (channel_id, ChannelSendRequest); both structs are re-exported from the generated crate. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
parent
9ba6c4d4f1
commit
4ac3452ffd
@ -1,11 +1,11 @@
|
||||
use base64::Engine;
|
||||
use regex::Regex;
|
||||
use serde::Serialize;
|
||||
use serial_test::serial;
|
||||
use std::sync::{Arc, Mutex};
|
||||
use std::time::Duration;
|
||||
use waku_bindings::{
|
||||
ChannelMessageReceivedPayload, ChannelMessageSentPayload, LogosDeliveryCtx, WakuNodeConfig,
|
||||
ChannelMessageReceivedPayload, ChannelMessageSentPayload, ChannelSendRequest,
|
||||
LogosDeliveryCtx, WakuNodeConfig,
|
||||
};
|
||||
|
||||
const TEST_CHANNEL_ID: &str = "test-channel";
|
||||
@ -21,13 +21,6 @@ const SHARDS_IN_NETWORK: usize = 8;
|
||||
/// must share it: the singleton refuses to be re-targeted.
|
||||
const STORAGE_PATH: &str = "./data-channels-test";
|
||||
|
||||
/// Body of `channel_send`, whose payload travels base64-encoded.
|
||||
#[derive(Serialize)]
|
||||
struct ChannelMessage {
|
||||
payload: String,
|
||||
ephemeral: bool,
|
||||
}
|
||||
|
||||
fn new_node(tcp_port: usize) -> LogosDeliveryCtx {
|
||||
// A channel's shard is derived from its content topic, so the node needs
|
||||
// autosharding on, and has to sit on every shard a topic might hash to.
|
||||
@ -43,12 +36,11 @@ fn new_node(tcp_port: usize) -> LogosDeliveryCtx {
|
||||
LogosDeliveryCtx::create(config, TIMEOUT).expect("node should instantiate")
|
||||
}
|
||||
|
||||
fn channel_message(payload: &[u8]) -> String {
|
||||
serde_json::to_string(&ChannelMessage {
|
||||
fn channel_message(payload: &[u8]) -> ChannelSendRequest {
|
||||
ChannelSendRequest {
|
||||
payload: base64::engine::general_purpose::STANDARD.encode(payload),
|
||||
ephemeral: false,
|
||||
})
|
||||
.expect("message should serialise")
|
||||
}
|
||||
}
|
||||
|
||||
/// Dials `to` from `from`, rewriting the advertised address to loopback so NAT
|
||||
|
||||
@ -1 +1 @@
|
||||
Subproject commit f2801b86a2ba27d8ee9e1e3d354fc68ac6016fc7
|
||||
Subproject commit 0291318c95cfe6640ff2928f7cf5f2ff360d3673
|
||||
Loading…
x
Reference in New Issue
Block a user