Skip to content

Commit

Permalink
pytest: check nonstandard onion generation.
Browse files Browse the repository at this point in the history
Signed-off-by: Rusty Russell <rusty@rustcorp.com.au>
  • Loading branch information
rustyrussell committed May 23, 2021
1 parent 0973cce commit d4a2b27
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion tests/test_pay.py
Original file line number Diff line number Diff line change
Expand Up @@ -2816,7 +2816,8 @@ def test_partial_payment_htlc_loss(node_factory, bitcoind):
def test_createonion_limits(node_factory):
l1, = node_factory.get_nodes(1)
hops = [{
"pubkey": "02eec7245d6b7d2ccb30380bfbe2a3648cd7a942653f5aa340edcea1f283686619",
# privkey: 41bfd2660762506c9933ade59f1debf7e6495b10c14a92dbcd2d623da2507d3d
"pubkey": "0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518",
"payload": "00" * 228
}, {
"pubkey": "0324653eac434488002cc06bbfb7f10fe18991e35f9fe4302dbea6d2353dc0ab1c",
Expand All @@ -2840,6 +2841,20 @@ def test_createonion_limits(node_factory):
hops[0]['payload'] += '01'
l1.rpc.createonion(hops=hops, assocdata="BB" * 32)

# But with a larger onion, it will work!
oniontool = os.path.join(os.path.dirname(__file__), "..", "devtools", "onion")
onion = l1.rpc.createonion(hops=hops, assocdata="BB" * 32, onion_size=1301)['onion']

# Oniontool wants a filename :(
onionfile = os.path.join(l1.daemon.lightning_dir, 'onion')
with open(onionfile, "w") as f:
f.write(onion)

subprocess.check_output(
[oniontool, '--assoc-data', "BB" * 32,
'decode', onionfile, "41bfd2660762506c9933ade59f1debf7e6495b10c14a92dbcd2d623da2507d3d"]
)


@pytest.mark.developer("needs use_shadow")
def test_blockheight_disagreement(node_factory, bitcoind, executor):
Expand Down

0 comments on commit d4a2b27

Please sign in to comment.