MCPcopy Create free account
hub / github.com/ElementsProject/lightning / test_rendezvous_onion

Function test_rendezvous_onion

tests/test_onion.py:54–89  ·  view source on GitHub ↗

Create a compressed onion, decompress it at the RV node and then forward normally.

(directory, oniontool)

Source from the content-addressed store, hash-verified

52
53
54def test_rendezvous_onion(directory, oniontool):
55 """Create a compressed onion, decompress it at the RV node and then forward normally.
56 """
57 tempfile = os.path.join(directory, 'onion')
58 out = subprocess.check_output(
59 [oniontool, '--rendezvous-id', pubkeys[0], 'generate'] + pubkeys
60 ).decode('ASCII').strip().split('\n')
61 assert(len(out) == 2)
62 compressed = out[0].split(' ')[-1]
63 uncompressed = out[1]
64
65 assert(len(compressed) < len(uncompressed))
66
67 # Now decompress the onion to get back the original onion
68 out2 = subprocess.check_output(
69 [oniontool, 'decompress', privkeys[0], compressed]
70 ).decode('ASCII').strip().split('\n')
71 decompressed = out2[-1].split(' ')[-1]
72
73 assert(uncompressed == decompressed)
74
75 # And now just for safety make sure the following nodes can still process
76 # and forward the onion.
77 def store_onion(o):
78 with open(tempfile, 'w') as f:
79 f.write(o)
80
81 store_onion(decompressed)
82
83 for i, pk in enumerate(privkeys):
84 out = subprocess.check_output([oniontool, 'decode', tempfile, pk]).decode('ASCII').strip().split('\n')
85 store_onion(out[-1][5:])
86
87 # Final payload:
88 # amt_to_forward=4,outgoing_cltv_value=4
89 assert(out == ['payload=06020104040104'])

Callers

nothing calls this directly

Calls 3

store_onionFunction · 0.85
joinMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected