@@ -7544,6 +7544,7 @@ mod tests {
7544
7544
use crate::util::config::UserConfig;
7545
7545
use crate::util::enforcing_trait_impls::EnforcingSigner;
7546
7546
use crate::util::errors::APIError;
7547
+ use crate::util::ser::{Readable, Writeable};
7547
7548
use crate::util::test_utils;
7548
7549
use crate::util::test_utils::OnGetShutdownScriptpubkey;
7549
7550
use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
@@ -7555,6 +7556,7 @@ mod tests {
7555
7556
use bitcoin::PackedLockTime;
7556
7557
use bitcoin::util::address::WitnessVersion;
7557
7558
use crate::prelude::*;
7559
+ use crate::io;
7558
7560
7559
7561
struct TestFeeEstimator {
7560
7562
fee_est: u32
@@ -7568,7 +7570,7 @@ mod tests {
7568
7570
#[test]
7569
7571
fn test_channel_id_new_from_data() {
7570
7572
let data: [u8; 32] = [2; 32];
7571
- let channel_id = ChannelId::from_bytes([2; 32] );
7573
+ let channel_id = ChannelId::from_bytes(data.clone() );
7572
7574
assert_eq!(*channel_id.bytes(), data);
7573
7575
}
7574
7576
@@ -7587,6 +7589,19 @@ mod tests {
7587
7589
assert_ne!(channel_id11, channel_id21);
7588
7590
}
7589
7591
7592
+ #[test]
7593
+ fn test_channel_id_write_read() {
7594
+ let data: [u8; 32] = [2; 32];
7595
+ let channel_id = ChannelId::from_bytes(data.clone());
7596
+
7597
+ let mut w = test_utils::TestVecWriter(Vec::new());
7598
+ channel_id.write(&mut w).unwrap();
7599
+
7600
+ let channel_id_2 = ChannelId::read(&mut io::Cursor::new(&w.0)).unwrap();
7601
+ assert_eq!(channel_id_2, channel_id);
7602
+ assert_eq!(channel_id_2.bytes(), &data);
7603
+ }
7604
+
7590
7605
#[test]
7591
7606
fn test_max_funding_satoshis_no_wumbo() {
7592
7607
assert_eq!(TOTAL_BITCOIN_SUPPLY_SATOSHIS, 21_000_000 * 100_000_000);
0 commit comments