Browse Source

fix: suppress duplicated channel_state_changed events

bump-pyln-proto
Michael Schmoock 4 years ago
committed by Rusty Russell
parent
commit
160c564e5f
  1. 16
      lightningd/channel.c
  2. 8
      tests/test_plugin.py

16
lightningd/channel.c

@ -399,13 +399,15 @@ void channel_set_state(struct channel *channel,
wallet_channel_save(channel->peer->ld->wallet, channel);
/* plugin notification channel_state_changed */
derive_channel_id(&cid, &channel->funding_txid, channel->funding_outnum);
notify_channel_state_changed(channel->peer->ld,
&channel->peer->id,
&cid,
channel->scid,
old_state,
state);
if (state != old_state) { /* see issue #4029 */
derive_channel_id(&cid, &channel->funding_txid, channel->funding_outnum);
notify_channel_state_changed(channel->peer->ld,
&channel->peer->id,
&cid,
channel->scid,
old_state,
state);
}
}
void channel_fail_permanent(struct channel *channel, const char *fmt, ...)

8
tests/test_plugin.py

@ -731,14 +731,6 @@ def test_channel_state_changed_unilateral(node_factory, bitcoind):
bitcoind.generate_block(100) # so it gets settled
msg = l2.daemon.wait_for_log("channel_state_changed.*new_state.*")
event = ast.literal_eval(re.findall(".*({.*}).*", msg)[0])
assert(event['peer_id'] == peer_id)
assert(event['channel_id'] == cid)
assert(event['short_channel_id'] == scid)
assert(event['old_state'] == "AWAITING_UNILATERAL") # this actually happens
assert(event['new_state'] == "AWAITING_UNILATERAL") # note: same states
msg = l2.daemon.wait_for_log("channel_state_changed.*new_state.*")
event = ast.literal_eval(re.findall(".*({.*}).*", msg)[0])
assert(event['peer_id'] == peer_id)

Loading…
Cancel
Save