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

Function test_single_hop

tests/benchmark.py:47–77  ·  view source on GitHub ↗
(node_factory, executor)

Source from the content-addressed store, hash-verified

45
46
47def test_single_hop(node_factory, executor):
48 l1 = get_bench_node(node_factory)
49 l2 = get_bench_node(node_factory)
50
51 l1.rpc.connect(l2.rpc.getinfo()['id'], 'localhost:%d' % l2.port)
52 l1.openchannel(l2, 4000000)
53
54 print("Collecting invoices")
55 fs = []
56 invoices = []
57 for i in tqdm(range(num_payments)):
58 inv = l2.rpc.invoice(1000, 'invoice-%d' % (i), 'desc')
59 invoices.append((inv['payment_hash'], inv['payment_secret']))
60
61 route = l1.single_route(l2.rpc.getinfo()['id'], 1000)
62 print("Sending payments")
63 start_time = time()
64
65 def do_pay(i, s):
66 p = l1.rpc.sendpay(route, i, payment_secret=s)
67 r = l1.rpc.waitsendpay(p['payment_hash'])
68 return r
69
70 for i, s in invoices:
71 fs.append(executor.submit(do_pay, i, s))
72
73 for f in tqdm(futures.as_completed(fs), total=len(fs)):
74 f.result()
75
76 diff = time() - start_time
77 print("Done. %d payments performed in %f seconds (%f payments per second)" % (num_payments, diff, num_payments / diff))
78
79
80def test_single_payment(node_factory, benchmark):

Callers

nothing calls this directly

Calls 6

get_bench_nodeFunction · 0.85
openchannelMethod · 0.80
single_routeMethod · 0.80
connectMethod · 0.45
getinfoMethod · 0.45
invoiceMethod · 0.45

Tested by

no test coverage detected