From d4a2b27530afd113618b12e710e6484c85791b97 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Mon, 17 May 2021 10:03:11 +0930 Subject: [PATCH] pytest: check nonstandard onion generation. Signed-off-by: Rusty Russell --- tests/test_pay.py | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/test_pay.py b/tests/test_pay.py index 0316e7ef7a3b..7b38bb445e4b 100644 --- a/tests/test_pay.py +++ b/tests/test_pay.py @@ -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", @@ -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):