Skip to content

Commit

Permalink
pytest: re-enable modern/obsolete fetchonion tests.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <[email protected]>
  • Loading branch information
rustyrussell committed Nov 30, 2021
1 parent 5361107 commit 605b3bf
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 3 deletions.
13 changes: 10 additions & 3 deletions lightningd/onion_message.c
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
size_t submsglen;
const u8 *subptr;

payload = tal(ld, struct onion_message_hook_payload);
payload = tal(tmpctx, struct onion_message_hook_payload);
payload->our_alias = tal(payload, struct pubkey);

if (!fromwire_gossipd_got_onionmsg_to_us(payload, msg,
Expand All @@ -162,6 +162,13 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
return;
}

#if DEVELOPER
if (!obs2 && ld->dev_ignore_modern_onion)
return;
if (obs2 && ld->dev_ignore_obsolete_onion)
return;
#endif

/* If there's no self_id, or it's not correct, ignore alias: alias
* means we created the path it's using. */
if (!self_id || !secret_eq_consttime(self_id, &ld->onion_reply_secret))
Expand All @@ -174,7 +181,6 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
payload->obs2_om = tlv_obs2_onionmsg_payload_new(payload);
if (!fromwire_obs2_onionmsg_payload(&subptr,
&submsglen, payload->obs2_om)) {
tal_free(payload);
log_broken(ld->log, "bad got_onionmsg_tous obs2 om: %s",
tal_hex(tmpctx, msg));
return;
Expand All @@ -183,7 +189,6 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
payload->obs2_om = NULL;
payload->om = tlv_onionmsg_payload_new(payload);
if (!fromwire_onionmsg_payload(&subptr, &submsglen, payload->om)) {
tal_free(payload);
log_broken(ld->log, "bad got_onionmsg_tous om: %s",
tal_hex(tmpctx, msg));
return;
Expand All @@ -203,6 +208,8 @@ void handle_onionmsg_to_us(struct lightningd *ld, const u8 *msg)
payload->our_alias ? " via-ourpath": "",
payload->reply_path ? " reply_path": "");

/* We'll free this on return */
tal_steal(ld, payload);
if (payload->our_alias)
plugin_hook_call_onion_message_ourpath(ld, payload);
else
Expand Down
17 changes: 17 additions & 0 deletions tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -4352,6 +4352,23 @@ def test_fetchinvoice_3hop(node_factory, bitcoind):

l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12']})

# Test with obsolete onion.
l4.stop()
l4.daemon.opts['dev-no-modern-onion'] = None
l4.start()
l4.rpc.connect(l3.info['id'], 'localhost', l3.port)

l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12']})

# Test with modern onion.
l4.stop()
del l4.daemon.opts['dev-no-modern-onion']
l4.daemon.opts['dev-no-obsolete-onion'] = None
l4.start()
l4.rpc.connect(l3.info['id'], 'localhost', l3.port)

l1.rpc.call('fetchinvoice', {'offer': offer1['bolt12']})


def test_fetchinvoice(node_factory, bitcoind):
# We remove the conversion plugin on l3, causing it to get upset.
Expand Down

0 comments on commit 605b3bf

Please sign in to comment.