mirror of
https://github.com/aljazceru/plugins.git
synced 2025-12-24 00:24:19 +01:00
rebalance: test a full rebalanceall run
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import os
|
||||
from pyln.testing.fixtures import * # noqa: F401,F403
|
||||
from pyln.testing.utils import wait_for
|
||||
from pyln.client import Millisatoshi
|
||||
|
||||
plugin_path = os.path.join(os.path.dirname(__file__), "rebalance.py")
|
||||
@@ -101,5 +102,18 @@ def test_rebalance_all(node_factory, bitcoind):
|
||||
wait_for_all_active(nodes, scids)
|
||||
|
||||
# check the rebalanceall starts
|
||||
result = l1.rpc.rebalanceall()
|
||||
result = l1.rpc.rebalanceall(feeratio=5.0) # we need high fees to work
|
||||
assert result['message'].startswith('Rebalance started')
|
||||
l1.daemon.wait_for_log(f"Try to rebalance: {scid12} -> {scid31}")
|
||||
wait_for(lambda: not l1.rpc.rebalanceall()['message'].startswith("Rebalance is already running"))
|
||||
result = l1.rpc.rebalancestop()
|
||||
assert result['message'] == "Rebalance stopped"
|
||||
|
||||
# wait until listpeers is up2date
|
||||
wait_for_all_htlcs(nodes)
|
||||
|
||||
# check that channels are now balanced
|
||||
c12 = l1.rpc.listpeers(l2.info['id'])['peers'][0]['channels'][0]
|
||||
c13 = l1.rpc.listpeers(l3.info['id'])['peers'][0]['channels'][0]
|
||||
assert abs(0.5 - (Millisatoshi(c12['to_us_msat']) / Millisatoshi(c12['total_msat']))) < 0.01
|
||||
assert abs(0.5 - (Millisatoshi(c13['to_us_msat']) / Millisatoshi(c13['total_msat']))) < 0.01
|
||||
|
||||
Reference in New Issue
Block a user