Skip to content

Commit 566bd25

Browse files
committed
Test router serialization round-trip
1 parent 6b80075 commit 566bd25

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

lightning/src/ln/functional_test_utils.rs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use chain::transaction::OutPoint;
66
use chain::keysinterface::KeysInterface;
77
use ln::channelmanager::{ChannelManager, ChannelManagerReadArgs, RAACommitmentOrder, PaymentPreimage, PaymentHash};
88
use ln::channelmonitor::{ChannelMonitor, ManyChannelMonitor};
9-
use ln::router::{Route, Router};
9+
use ln::router::{Route, Router, RouterReadArgs};
1010
use ln::features::InitFeatures;
1111
use ln::msgs;
1212
use ln::msgs::{ChannelMessageHandler,RoutingMessageHandler};
@@ -97,6 +97,16 @@ impl<'a, 'b, 'c> Drop for Node<'a, 'b, 'c> {
9797
assert!(self.node.get_and_clear_pending_events().is_empty());
9898
assert!(self.chan_monitor.added_monitors.lock().unwrap().is_empty());
9999

100+
// Check that if we serialize the Router, we can deserialize it again.
101+
{
102+
let mut w = test_utils::TestVecWriter(Vec::new());
103+
self.router.write(&mut w).unwrap();
104+
let _ = Router::read(&mut ::std::io::Cursor::new(&w.0), RouterReadArgs {
105+
chain_monitor: Arc::clone(&self.chain_monitor) as Arc<chaininterface::ChainWatchInterface>,
106+
logger: Arc::clone(&self.logger) as Arc<Logger>
107+
}).unwrap();
108+
}
109+
100110
// Check that if we serialize and then deserialize all our channel monitors we get the
101111
// same set of outputs to watch for on chain as we have now. Note that if we write
102112
// tests that fully close channels and remove the monitors at some point this may break.

0 commit comments

Comments
 (0)