4
4
use bitcoin:: hash_types:: BlockHash ;
5
5
6
6
use lightning:: chain:: channelmonitor;
7
+ use lightning:: util:: ser:: { ReadableArgs , Writeable , Writer } ;
7
8
use lightning:: util:: test_channel_signer:: TestChannelSigner ;
8
- use lightning:: util:: ser:: { ReadableArgs , Writer , Writeable } ;
9
9
use lightning:: util:: test_utils:: OnlyReadsKeysInterface ;
10
10
11
11
use crate :: utils:: test_logger;
@@ -22,10 +22,19 @@ impl Writer for VecWriter {
22
22
23
23
#[ inline]
24
24
pub fn do_test < Out : test_logger:: Output > ( data : & [ u8 ] , _out : Out ) {
25
- if let Ok ( ( latest_block_hash, monitor) ) = <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read ( & mut Cursor :: new ( data) , ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ) {
25
+ if let Ok ( ( latest_block_hash, monitor) ) =
26
+ <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read (
27
+ & mut Cursor :: new ( data) ,
28
+ ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ,
29
+ ) {
26
30
let mut w = VecWriter ( Vec :: new ( ) ) ;
27
31
monitor. write ( & mut w) . unwrap ( ) ;
28
- let deserialized_copy = <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read ( & mut Cursor :: new ( & w. 0 ) , ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ) . unwrap ( ) ;
32
+ let deserialized_copy =
33
+ <( BlockHash , channelmonitor:: ChannelMonitor < TestChannelSigner > ) >:: read (
34
+ & mut Cursor :: new ( & w. 0 ) ,
35
+ ( & OnlyReadsKeysInterface { } , & OnlyReadsKeysInterface { } ) ,
36
+ )
37
+ . unwrap ( ) ;
29
38
assert ! ( latest_block_hash == deserialized_copy. 0 ) ;
30
39
assert ! ( monitor == deserialized_copy. 1 ) ;
31
40
}
@@ -37,5 +46,5 @@ pub fn chanmon_deser_test<Out: test_logger::Output>(data: &[u8], out: Out) {
37
46
38
47
#[ no_mangle]
39
48
pub extern "C" fn chanmon_deser_run ( data : * const u8 , datalen : usize ) {
40
- do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } ) ;
49
+ do_test ( unsafe { std:: slice:: from_raw_parts ( data, datalen) } , test_logger:: DevNull { } ) ;
41
50
}
0 commit comments