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

Function test_node_bias_persistence

tests/test_askrene.py:444–499  ·  view source on GitHub ↗

Test node bias persistence.

(node_factory)

Source from the content-addressed store, hash-verified

442
443
444def test_node_bias_persistence(node_factory):
445 """Test node bias persistence."""
446 # remove xpay, since it creates a layer!
447 l1, l2 = node_factory.line_graph(
448 2, wait_for_announce=True, opts={"disable-plugin": "cln-xpay"}
449 )
450
451 expect = {
452 "layer": "mylayer",
453 "persistent": True,
454 "disabled_nodes": [],
455 "created_channels": [],
456 "channel_updates": [],
457 "constraints": [],
458 "biases": [],
459 "node_biases": [],
460 }
461 l1.rpc.askrene_create_layer(layer="mylayer", persistent=True)
462 r = l1.rpc.askrene_bias_node(
463 layer="mylayer", node=l2.info["id"], direction="out", bias=14, relative=False
464 )
465 expect["node_biases"] = [
466 {
467 "node": l2.info["id"],
468 "in_bias": 0,
469 "out_bias": 14,
470 "timestamp": r["node_biases"][0]["timestamp"],
471 }
472 ]
473 assert l1.rpc.askrene_listlayers("mylayer") == {"layers": [expect]}
474 # restarting the node we see the same data again
475 l2.restart()
476 assert l1.rpc.askrene_listlayers("mylayer") == {"layers": [expect]}
477
478 r = l1.rpc.askrene_bias_node(
479 layer="mylayer",
480 node=l2.info["id"],
481 direction="in",
482 bias=11,
483 relative=False,
484 description="Some description",
485 )
486 expect["node_biases"] = [
487 {
488 "node": l2.info["id"],
489 "in_bias": 11,
490 "out_bias": 14,
491 "timestamp": r["node_biases"][0]["timestamp"],
492 "description": "Some description",
493 }
494 ]
495 assert l1.rpc.askrene_listlayers("mylayer") == {"layers": [expect]}
496
497 # restarting the node we see the same data again
498 l2.restart()
499 assert l1.rpc.askrene_listlayers("mylayer") == {"layers": [expect]}
500
501

Callers

nothing calls this directly

Calls 3

line_graphMethod · 0.80
askrene_bias_nodeMethod · 0.80
restartMethod · 0.80

Tested by

no test coverage detected