Skip to content

Commit

Permalink
Add unit tests for Display
Browse files Browse the repository at this point in the history
  • Loading branch information
optout21 committed Aug 13, 2023
1 parent 7561dce commit a1fcce7
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
11 changes: 10 additions & 1 deletion lightning/src/ln/channelmanager.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ use bitcoin::blockdata::constants::{genesis_block, ChainHash};
use bitcoin::network::constants::Network;

use bitcoin::hashes::Hash;
use bitcoin::hashes::hex::ToHex;
use bitcoin::hashes::sha256::Hash as Sha256;
use bitcoin::hash_types::{BlockHash, Txid};

Expand Down Expand Up @@ -10364,6 +10363,16 @@ mod tests {
let events = nodes[0].node.get_and_clear_pending_msg_events();
assert_eq!(events.len(), 0);
}

#[test]
fn test_payment_display() {
let payment_id = PaymentId([42; 32]);
assert_eq!(format!("{}", &payment_id), "2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a");
let payment_hash = PaymentHash([42; 32]);
assert_eq!(format!("{}", &payment_hash), "2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a");
let payment_preimage = PaymentPreimage([42; 32]);
assert_eq!(format!("{}", &payment_preimage), "2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a");
}
}

#[cfg(ldk_bench)]
Expand Down
6 changes: 6 additions & 0 deletions lightning/src/routing/gossip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3418,6 +3418,12 @@ pub(crate) mod tests {
// This serialized info has an address field but no announcement_message, therefore the addresses returned by our function will still be empty
assert!(ann_info_with_addresses.addresses().is_empty());
}

#[test]
fn test_node_id_display() {
let node_id = NodeId([42; 33]);
assert_eq!(format!("{}", &node_id), "2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a2a");
}
}

#[cfg(ldk_bench)]
Expand Down

0 comments on commit a1fcce7

Please sign in to comment.