(node_factory)
| 21 | |
| 22 | |
| 23 | def test_pay_fakenet(node_factory): |
| 24 | hash1 = sha256(bytes.fromhex('00' + '00' * 31)).hexdigest() |
| 25 | hash2 = sha256(bytes.fromhex('01' + '00' * 31)).hexdigest() |
| 26 | failhash = '00' * 32 |
| 27 | |
| 28 | # Create gossip map of channels from l2 (aka nodemap[0]) |
| 29 | gsfile, nodemap = generate_gossip_store([GenChannel(0, 1, capacity_sats=100_000), |
| 30 | GenChannel(1, 2, capacity_sats=100_000), |
| 31 | GenChannel(2, 3, capacity_sats=200_000)], |
| 32 | nodemap={0: '033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a'}) |
| 33 | |
| 34 | # l2 will warn l1 about its invalid gossip: ignore. |
| 35 | l1, l2 = node_factory.line_graph(2, |
| 36 | opts=[{'gossip_store_file': gsfile.name, |
| 37 | 'subdaemon': 'channeld:../tests/plugins/channeld_fakenet', |
| 38 | 'allow_warning': True}, {}]) |
| 39 | |
| 40 | # l1 needs to know l2's shaseed for the channel so it can make revocations |
| 41 | hsmfile = os.path.join(l2.daemon.lightning_dir, TEST_NETWORK, "hsm_secret") |
| 42 | # Needs peer node id and channel dbid (1, it's the first channel), prints out: |
| 43 | # "shaseed: xxxxxxx\n" |
| 44 | shaseed = subprocess.check_output(["tools/lightning-hsmtool", "dumpcommitments", l1.info['id'], "1", "0", hsmfile]).decode('utf-8').strip().partition(": ")[2] |
| 45 | l1.rpc.dev_peer_shachain(l2.info['id'], shaseed) |
| 46 | |
| 47 | # Failure from final (unknown payment hash) |
| 48 | l1.rpc.sendpay(route=[{'id': l2.info['id'], |
| 49 | 'channel': first_scid(l1, l2), |
| 50 | 'delay': 18 + 6, |
| 51 | 'amount_msat': 1000001}, |
| 52 | {'id': nodemap[1], |
| 53 | 'channel': '0x1x0', |
| 54 | 'delay': 18, |
| 55 | 'amount_msat': 100000}], |
| 56 | payment_hash=failhash) |
| 57 | |
| 58 | with pytest.raises(RpcError, match="WIRE_INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS") as err: |
| 59 | l1.rpc.waitsendpay(payment_hash=failhash, timeout=TIMEOUT) |
| 60 | |
| 61 | assert err.value.error['data']['erring_node'] == nodemap[1] |
| 62 | |
| 63 | # Success from final (known payment hash) |
| 64 | l1.rpc.sendpay(route=[{'id': l2.info['id'], |
| 65 | 'channel': first_scid(l1, l2), |
| 66 | 'delay': 18 + 6, |
| 67 | 'amount_msat': 1000001}, |
| 68 | {'id': nodemap[1], |
| 69 | 'channel': '0x1x0', |
| 70 | 'delay': 18, |
| 71 | 'amount_msat': 100000}], |
| 72 | payment_hash=hash1) |
| 73 | l1.rpc.waitsendpay(payment_hash=hash1, timeout=TIMEOUT) |
| 74 | |
| 75 | # Failure from node 2 (unknown scid) |
| 76 | l1.rpc.sendpay(route=[{'id': l2.info['id'], |
| 77 | 'channel': first_scid(l1, l2), |
| 78 | 'delay': 18 + 6 + 6, |
| 79 | 'amount_msat': 1000002}, |
| 80 | {'id': nodemap[1], |
nothing calls this directly
no test coverage detected