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

Function test_errors

tests/test_renepay.py:99–145  ·  view source on GitHub ↗
(node_factory, bitcoind)

Source from the content-addressed store, hash-verified

97
98
99def test_errors(node_factory, bitcoind):
100 opts = [
101 {"disable-mpp": None, "fee-base": 0, "fee-per-satoshi": 0, 'allow-deprecated-apis': True},
102 ]
103 l1, l2, l3, l4, l5, l6 = node_factory.get_nodes(6, opts=opts * 6)
104 send_amount = Millisatoshi("21sat")
105 inv = l6.rpc.invoice(send_amount, "test_renepay", "description")["bolt11"]
106 inv_deleted = l6.rpc.invoice(send_amount, "test_renepay2", "description2")["bolt11"]
107 l6.rpc.delinvoice("test_renepay2", "unpaid")
108
109 failmsg = r"We don\'t have any channels"
110 with pytest.raises(RpcError, match=failmsg):
111 l1.rpc.call("renepay", {"invstring": inv})
112 node_factory.join_nodes([l1, l2, l4], wait_for_announce=True, fundamount=1000000)
113 node_factory.join_nodes([l1, l3, l5], wait_for_announce=True, fundamount=1000000)
114
115 failmsg = r"failed to find a feasible flow"
116 with pytest.raises(RpcError, match=failmsg):
117 l1.rpc.call("renepay", {"invstring": inv})
118
119 l4.rpc.connect(l6.info["id"], "localhost", l6.port)
120 l5.rpc.connect(l6.info["id"], "localhost", l6.port)
121
122 scid46, _ = l4.fundchannel(l6, 10**6, wait_for_active=False)
123 scid56, _ = l5.fundchannel(l6, 10**6, wait_for_active=False)
124 mine_funding_to_announce(bitcoind, [l1, l2, l3, l4, l5, l6])
125
126 l1.daemon.wait_for_logs(
127 [
128 r"update for channel {}/0 now ACTIVE".format(scid46),
129 r"update for channel {}/1 now ACTIVE".format(scid46),
130 r"update for channel {}/0 now ACTIVE".format(scid56),
131 r"update for channel {}/1 now ACTIVE".format(scid56),
132 ]
133 )
134 details = l1.rpc.call("renepay", {"invstring": inv})
135 assert details["status"] == "complete"
136 assert details["amount_msat"] == send_amount
137 assert details["destination"] == l6.info["id"]
138
139 # Test error from final node.
140 with pytest.raises(RpcError) as err:
141 l1.rpc.call("renepay", {"invstring": inv_deleted})
142
143 PAY_DESTINATION_PERM_FAIL = 203
144 assert err.value.error["code"] == PAY_DESTINATION_PERM_FAIL
145 assert "Unknown invoice" in err.value.error["message"]
146
147
148@pytest.mark.openchannel("v1")

Callers

nothing calls this directly

Calls 10

MillisatoshiClass · 0.90
mine_funding_to_announceFunction · 0.90
get_nodesMethod · 0.80
delinvoiceMethod · 0.80
join_nodesMethod · 0.80
wait_for_logsMethod · 0.80
invoiceMethod · 0.45
callMethod · 0.45
connectMethod · 0.45
fundchannelMethod · 0.45

Tested by

no test coverage detected