@@ -7531,6 +7531,7 @@ mod tests {
7531
7531
use crate::util::config::UserConfig;
7532
7532
use crate::util::enforcing_trait_impls::EnforcingSigner;
7533
7533
use crate::util::errors::APIError;
7534
+ use crate::util::ser::{Readable, Writeable};
7534
7535
use crate::util::test_utils;
7535
7536
use crate::util::test_utils::OnGetShutdownScriptpubkey;
7536
7537
use bitcoin::secp256k1::{Secp256k1, ecdsa::Signature};
@@ -7542,6 +7543,7 @@ mod tests {
7542
7543
use bitcoin::PackedLockTime;
7543
7544
use bitcoin::util::address::WitnessVersion;
7544
7545
use crate::prelude::*;
7546
+ use crate::io;
7545
7547
7546
7548
struct TestFeeEstimator {
7547
7549
fee_est: u32
@@ -7555,7 +7557,7 @@ mod tests {
7555
7557
#[test]
7556
7558
fn test_channel_id_new_from_data() {
7557
7559
let data: [u8; 32] = [2; 32];
7558
- let channel_id = ChannelId::from_bytes([2; 32] );
7560
+ let channel_id = ChannelId::from_bytes(data.clone() );
7559
7561
assert_eq!(*channel_id.bytes(), data);
7560
7562
}
7561
7563
@@ -7574,6 +7576,19 @@ mod tests {
7574
7576
assert_ne!(channel_id11, channel_id21);
7575
7577
}
7576
7578
7579
+ #[test]
7580
+ fn test_channel_id_write_read() {
7581
+ let data: [u8; 32] = [2; 32];
7582
+ let channel_id = ChannelId::from_bytes(data.clone());
7583
+
7584
+ let mut w = test_utils::TestVecWriter(Vec::new());
7585
+ channel_id.write(&mut w).unwrap();
7586
+
7587
+ let channel_id_2 = ChannelId::read(&mut io::Cursor::new(&w.0)).unwrap();
7588
+ assert_eq!(channel_id_2, channel_id);
7589
+ assert_eq!(channel_id_2.bytes(), &data);
7590
+ }
7591
+
7577
7592
#[test]
7578
7593
fn test_max_funding_satoshis_no_wumbo() {
7579
7594
assert_eq!(TOTAL_BITCOIN_SUPPLY_SATOSHIS, 21_000_000 * 100_000_000);
0 commit comments