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

Function test_node_bias_rpc

tests/test_askrene.py:335–441  ·  view source on GitHub ↗

Test manipulating node bias in layers.

(node_factory)

Source from the content-addressed store, hash-verified

333
334
335def test_node_bias_rpc(node_factory):
336 """Test manipulating node bias in layers."""
337 # remove xpay, since it creates a layer!
338 l1, l2 = node_factory.line_graph(
339 2, wait_for_announce=True, opts={"disable-plugin": "cln-xpay"}
340 )
341
342 # Simply test the presence of 'node_biases'
343 expect = {
344 "layer": "test_layers",
345 "persistent": False,
346 "disabled_nodes": [],
347 "created_channels": [],
348 "channel_updates": [],
349 "constraints": [],
350 "biases": [],
351 "node_biases": [],
352 }
353 l1.rpc.askrene_create_layer("test_layers")
354 assert l1.rpc.askrene_listlayers("test_layers") == {"layers": [expect]}
355
356 # Adding a node bias in the out direction
357 r = l1.rpc.askrene_bias_node(
358 layer="test_layers",
359 node=l2.info["id"],
360 direction="out",
361 bias=3,
362 relative=False,
363 )
364 # Adding a node bias in the in direction
365 r = l1.rpc.askrene_bias_node(
366 layer="test_layers",
367 node=l2.info["id"],
368 direction="in",
369 bias=-3,
370 relative=False,
371 )
372 expect["node_biases"] = [
373 {
374 "node": l2.info["id"],
375 "in_bias": -3,
376 "out_bias": 3,
377 "timestamp": r["node_biases"][0]["timestamp"],
378 }
379 ]
380 listlayers = l1.rpc.askrene_listlayers("test_layers")
381 assert listlayers == {"layers": [expect]}
382
383 # Testing relative bias and descriptions
384 r = l1.rpc.askrene_bias_node(
385 layer="test_layers",
386 node=l2.info["id"],
387 direction="in",
388 bias=-3,
389 relative=True,
390 description="testing node bias",
391 )
392 r = l1.rpc.askrene_bias_node(

Callers

nothing calls this directly

Calls 2

line_graphMethod · 0.80
askrene_bias_nodeMethod · 0.80

Tested by

no test coverage detected