From: Arik Sosman Date: Thu, 28 Mar 2024 06:57:19 +0000 (-0700) Subject: Test storing node addresses. X-Git-Url: http://git.bitcoin.ninja/index.cgi?a=commitdiff_plain;h=f46a13944933c9c6c42fbeba66473d6e548d7cda;p=rapid-gossip-sync-server Test storing node addresses. --- diff --git a/src/tests/mod.rs b/src/tests/mod.rs index 13d34e9..578fa9f 100644 --- a/src/tests/mod.rs +++ b/src/tests/mod.rs @@ -12,7 +12,7 @@ use bitcoin::hashes::Hash; use bitcoin::hashes::sha256d::Hash as Sha256dHash; use hex_conservative::DisplayHex; use lightning::ln::features::{ChannelFeatures, NodeFeatures}; -use lightning::ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, UnsignedChannelAnnouncement, UnsignedChannelUpdate, UnsignedNodeAnnouncement}; +use lightning::ln::msgs::{ChannelAnnouncement, ChannelUpdate, NodeAnnouncement, SocketAddress, UnsignedChannelAnnouncement, UnsignedChannelUpdate, UnsignedNodeAnnouncement}; use lightning::routing::gossip::{NetworkGraph, NodeAlias, NodeId}; use lightning::util::ser::Writeable; use lightning_rapid_gossip_sync::RapidGossipSync; @@ -302,9 +302,28 @@ async fn test_node_announcement_persistence() { let (mut persister, receiver) = GossipPersister::new(network_graph_arc.clone(), logger.clone()); { // seed the db - let announcement = generate_node_announcement(); + let mut announcement = generate_node_announcement(); receiver.send(GossipMessage::NodeAnnouncement(announcement.clone(), None)).await.unwrap(); + receiver.send(GossipMessage::NodeAnnouncement(announcement.clone(), Some(12345))).await.unwrap(); + + { + // modify announcement to contain a bunch of addresses + announcement.contents.addresses.push(SocketAddress::Hostname { + hostname: "google.com".to_string().try_into().unwrap(), + port: 443, + }); + announcement.contents.addresses.push(SocketAddress::TcpIpV4 { addr: [127, 0, 0, 1], port: 9635 }); + announcement.contents.addresses.push(SocketAddress::TcpIpV6 { addr: [1; 16], port: 1337 }); + announcement.contents.addresses.push(SocketAddress::OnionV2([1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12])); + announcement.contents.addresses.push(SocketAddress::OnionV3 { + ed25519_pubkey: [1; 32], + checksum: 2, + version: 3, + port: 4, + }); + } receiver.send(GossipMessage::NodeAnnouncement(announcement, Some(12345))).await.unwrap(); + drop(receiver); persister.persist_gossip().await;