Skip to content

Commit 549be04

Browse files
committed
Add debug assertion in Channel::funding_signed
This is a sanity check that ChannelPhase and ChannelState do not go out of sync.
1 parent e93aa01 commit 549be04

File tree

2 files changed

+4
-0
lines changed

2 files changed

+4
-0
lines changed
48.5 KB
Binary file not shown.

lightning/src/ln/channel.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1392,13 +1392,17 @@ impl<SP: Deref> Channel<SP> where
13921392
{
13931393
let phase = core::mem::replace(&mut self.phase, ChannelPhase::Undefined);
13941394
let result = if let ChannelPhase::UnfundedOutboundV1(chan) = phase {
1395+
#[cfg(debug_assertions)]
1396+
let channel_state = chan.context.channel_state;
13951397
let logger = WithChannelContext::from(logger, &chan.context, None);
13961398
match chan.funding_signed(msg, best_block, signer_provider, &&logger) {
13971399
Ok((chan, monitor)) => {
1400+
debug_assert!(matches!(chan.context.channel_state, ChannelState::AwaitingChannelReady(_)));
13981401
self.phase = ChannelPhase::Funded(chan);
13991402
Ok(monitor)
14001403
},
14011404
Err((chan, e)) => {
1405+
debug_assert_eq!(chan.context.channel_state, channel_state);
14021406
self.phase = ChannelPhase::UnfundedOutboundV1(chan);
14031407
Err(e)
14041408
},

0 commit comments

Comments
 (0)