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

Function test_onion

tests/test_onion.py:30–51  ·  view source on GitHub ↗

Generate a 5 hop onion and then decode it.

(directory, oniontool)

Source from the content-addressed store, hash-verified

28
29
30def test_onion(directory, oniontool):
31 """ Generate a 5 hop onion and then decode it.
32 """
33 tempfile = os.path.join(directory, 'onion')
34 out = subprocess.check_output(
35 [oniontool, 'generate'] + pubkeys
36 ).decode('ASCII').strip().split('\n')
37 assert(len(out) == 1)
38
39 def store_onion(o):
40 with open(tempfile, 'w') as f:
41 f.write(o)
42
43 store_onion(out[0])
44
45 for i, pk in enumerate(privkeys):
46 out = subprocess.check_output([oniontool, 'decode', tempfile, pk]).decode('ASCII').strip().split('\n')
47 store_onion(out[-1][5:])
48
49 # Final payload:
50 # amt_to_forward=4,outgoing_cltv_value=4
51 assert(out == ['payload=06020104040104'])
52
53
54def test_rendezvous_onion(directory, oniontool):

Callers

nothing calls this directly

Calls 3

store_onionFunction · 0.85
joinMethod · 0.80
decodeMethod · 0.45

Tested by

no test coverage detected