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

Function test_node_bias_persistence

tests/test_askrene.py:451–546  ·  view source on GitHub ↗

Test node bias persistence.

(node_factory)

Source from the content-addressed store, hash-verified

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

Callers

nothing calls this directly

Calls 3

askrene_bias_nodeMethod · 0.80
restartMethod · 0.80
get_nodeMethod · 0.45

Tested by

no test coverage detected