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