Skip to content

Commit

Permalink
formatting tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jbesraa committed Apr 8, 2023
1 parent 88c4acc commit 362a9b4
Showing 1 changed file with 25 additions and 36 deletions.
61 changes: 25 additions & 36 deletions lightning/src/ln/msgs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2199,8 +2199,8 @@ mod tests {
use crate::io::{self, Cursor};
use crate::prelude::*;
use core::convert::TryFrom;
use core::str::FromStr;
use std::net::{Ipv4Addr, Ipv6Addr};
use core::str::FromStr;
use std::net::{Ipv4Addr, Ipv6Addr};

#[test]
fn encoding_channel_reestablish_no_secret() {
Expand Down Expand Up @@ -3144,38 +3144,27 @@ mod tests {
Ok(encoded_payload)
}

#[test]
fn net_address_from_str() {
let ipv4_net_address = NetAddress::IPv4 {
addr: Ipv4Addr::new(127, 0, 0, 1).octets(),
port: 1234,
};
let ipv6_net_address = NetAddress::IPv6 {
addr : Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).octets(),
port: 1234,
};
let hostname_net_address = NetAddress::Hostname {
hostname : Hostname::try_from("example.com".to_string()).unwrap(),
port: 1234,
};
let onionv3_net_address = NetAddress::OnionV3 {
ed25519_pubkey: [37, 24, 75, 5, 25, 73, 117, 194, 139, 102, 182, 107, 4, 105, 247, 246, 85,
111, 177, 172, 49, 137, 167, 155, 64, 221, 163, 47, 31, 33, 71, 3],
checksum: 48326,
version: 121,
port: 1234
};
let valid_ipv4 = "127.0.0.1:1234";
let valid_ipv6 = "[0:0:0:0:0:0:0:1]:1234";
let valid_hostname = "example.com:1234";
let valid_onionv3 = "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion:1234";
let result_ipv4 = NetAddress::from_str(valid_ipv4).unwrap();
let result_ipv6 = NetAddress::from_str(valid_ipv6).unwrap();
let result_hostname = NetAddress::from_str(valid_hostname).unwrap();
let result_onionv3 = NetAddress::from_str(valid_onionv3).unwrap();
assert_eq!(ipv4_net_address, result_ipv4);
assert_eq!(ipv6_net_address, result_ipv6);
assert_eq!(hostname_net_address, result_hostname);
assert_eq!(onionv3_net_address, result_onionv3);
}
#[test]
fn net_address_from_str() {
assert_eq!(NetAddress::IPv4 {
addr: Ipv4Addr::new(127, 0, 0, 1).octets(),
port: 1234,
}, NetAddress::from_str("127.0.0.1:1234").unwrap());
assert_eq!(NetAddress::IPv6 {
addr : Ipv6Addr::new(0, 0, 0, 0, 0, 0, 0, 1).octets(),
port: 1234,
}, NetAddress::from_str("[0:0:0:0:0:0:0:1]:1234").unwrap());
assert_eq!(
NetAddress::Hostname {
hostname : Hostname::try_from("example.com".to_string()).unwrap(),
port: 1234,
} , NetAddress::from_str("example.com:1234").unwrap());
assert_eq!(NetAddress::OnionV3 {
ed25519_pubkey: [37, 24, 75, 5, 25, 73, 117, 194, 139, 102, 182, 107, 4, 105, 247, 246, 85,
111, 177, 172, 49, 137, 167, 155, 64, 221, 163, 47, 31, 33, 71, 3],
checksum: 48326,
version: 121,
port: 1234
}, NetAddress::from_str( "pg6mmjiyjmcrsslvykfwnntlaru7p5svn6y2ymmju6nubxndf4pscryd.onion:1234").unwrap());
}
}

0 comments on commit 362a9b4

Please sign in to comment.