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

Function test_xpay_error_update_wrong_channel

tests/test_xpay.py:1310–1353  ·  view source on GitHub ↗
(node_factory)

Source from the content-addressed store, hash-verified

1308
1309
1310def test_xpay_error_update_wrong_channel(node_factory):
1311 plugin = os.path.join(os.path.dirname(__file__), 'plugins/htlc_accepted-failmessage.py')
1312 l1, l2, l3, l4, l5 = node_factory.line_graph(
1313 5, opts=[{}, {'plugin': plugin}, {}, {}, {}], wait_for_announce=True)
1314
1315 # this is the channel which will actually fail (l2 fails every HTLC it gets)
1316 real_scidd = first_scidd(l2, l3)
1317
1318 # an innocent channel elsewhere in the graph, nowhere near this route
1319 victim_scidd = first_scidd(l4, l5)
1320 victim_scid, victim_dir = victim_scidd.split('/')
1321
1322 channel_update = (
1323 struct.pack('>H', 258) # WIRE_CHANNEL_UPDATE
1324 + bytes(64) # signature - we don't check it
1325 + bytes(32) # chain_hash - irrelevant here
1326 + struct.pack('>Q', scid_to_int(victim_scid))
1327 + struct.pack('>I', 1) # timestamp
1328 + struct.pack('>B', 1) # message_flags
1329 + struct.pack('>B', int(victim_dir)) # channel_flags - enabled, given direction
1330 + struct.pack('>H', 40) # cltv_expiry_delta
1331 + struct.pack('>Q', 0) # htlc_minimum_msat
1332 + struct.pack('>I', 999000) # fee_base_msat - high
1333 + struct.pack('>I', 42) # fee_proportional_millionths
1334 + struct.pack('>Q', 1000000) # htlc_maximum_msat
1335 )
1336 failmsg = (struct.pack('>H', 0x1007) # WIRE_TEMPORARY_CHANNEL_FAILURE
1337 + struct.pack('>H', len(channel_update))
1338 + channel_update).hex()
1339 l2.rpc.setfailmsg(msg=failmsg)
1340
1341 inv = l3.rpc.invoice(123000, 'test_xpay_error_update_wrong_channel', 'desc')['bolt11']
1342
1343 with pytest.raises(RpcError, match=r'temporary_channel_failure'):
1344 l1.rpc.xpay(inv)
1345
1346 l1.daemon.wait_for_log(
1347 r"Ignoring channel_update for {} in error temporary_channel_failure:"
1348 r" does not match failing channel {}".format(re.escape(victim_scidd),
1349 re.escape(real_scidd)))
1350
1351 # and we must not have treated it as a legitimate update
1352 assert not l1.daemon.is_in_log(
1353 r'Got channel_update from error for {}'.format(re.escape(victim_scidd)))
1354
1355
1356def test_error_messages(node_factory):

Callers

nothing calls this directly

Calls 8

first_sciddFunction · 0.90
scid_to_intFunction · 0.90
joinMethod · 0.80
line_graphMethod · 0.80
wait_for_logMethod · 0.80
is_in_logMethod · 0.80
invoiceMethod · 0.45
xpayMethod · 0.45

Tested by

no test coverage detected