From 72c841ef34035501c49e2bbcb6adfedc3a93c7b7 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Wed, 7 Jan 2026 10:05:11 +1030 Subject: [PATCH] pytest: fix flake if rune tests are slow. If one second has passed during testing, checkrune might pass: ``` # default (sec) rune_per_default = l1.rpc.createrune(restrictions=[["per=1"]])['rune'] assert rune_per_default == 'NrM7go6C4qzfRQDkUSv1DtRroJWSKqdjIOuvGS4TLFE9NCZwZXI9MQ==' > do_test_rune_per_restriction(l1, rune_per_default, 1) tests/test_runes.py:269: _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ l1 = rune_to_test = 'NrM7go6C4qzfRQDkUSv1DtRroJWSKqdjIOuvGS4TLFE9NCZwZXI9MQ==' per_sec = 1 def do_test_rune_per_restriction(l1, rune_to_test, per_sec): ... # cannot use same rune till 'per_sec' seconds > with pytest.raises(RpcError, match='Not permitted:') as exc_info: E Failed: DID NOT RAISE tests/test_runes.py:217: Failed ``` Signed-off-by: Rusty Russell --- tests/test_runes.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tests/test_runes.py b/tests/test_runes.py index 4c080a8ba..ad21719c7 100644 --- a/tests/test_runes.py +++ b/tests/test_runes.py @@ -244,9 +244,9 @@ def test_createrune_per_restriction(node_factory): l1 = node_factory.get_node() # 1 sec = 1,000,000,000 nanoseconds (nsec) - rune_per_nano_sec = l1.rpc.createrune(restrictions=[["per=1000000000nsec"]])['rune'] - assert rune_per_nano_sec == 'Bl0V_vkVkGr4h356JbCMCcoDyyKE8djkoQ2156iPB509MCZwZXI9MTAwMDAwMDAwMG5zZWM=' - do_test_rune_per_restriction(l1, rune_per_nano_sec, 1) + rune_per_nano_sec = l1.rpc.createrune(restrictions=[["per=2000000000nsec"]])['rune'] + assert rune_per_nano_sec == 'FU709V1zX-JJR2hlpBfN2hpPEqahtzi6q65fZxnRRhM9MCZwZXI9MjAwMDAwMDAwMG5zZWM=' + do_test_rune_per_restriction(l1, rune_per_nano_sec, 2) # 1 sec = 1,000,000 microseconds (usec) rune_per_micro_sec = l1.rpc.createrune(restrictions=[["per=2000000usec"]])['rune'] @@ -254,9 +254,9 @@ def test_createrune_per_restriction(node_factory): do_test_rune_per_restriction(l1, rune_per_micro_sec, 2) # 1 sec = 1,000 milliseconds (msec) - rune_per_milli_sec = l1.rpc.createrune(restrictions=[["per=1000msec"]])['rune'] - assert rune_per_milli_sec == 'EzVpQwjYe2aoNQiRa4_s7FJtomD3kWzx7lusMpzA59w9MiZwZXI9MTAwMG1zZWM=' - do_test_rune_per_restriction(l1, rune_per_milli_sec, 1) + rune_per_milli_sec = l1.rpc.createrune(restrictions=[["per=2000msec"]])['rune'] + assert rune_per_milli_sec == 'eoEyi0Na_GeXBpmQ_cXQHrvmAuGWwq4bJrYo0jKk6V09MiZwZXI9MjAwMG1zZWM=' + do_test_rune_per_restriction(l1, rune_per_milli_sec, 2) # 1 sec rune_per_sec = l1.rpc.createrune(restrictions=[["per=2sec"]])['rune'] @@ -264,9 +264,9 @@ def test_createrune_per_restriction(node_factory): do_test_rune_per_restriction(l1, rune_per_sec, 2) # default (sec) - rune_per_default = l1.rpc.createrune(restrictions=[["per=1"]])['rune'] - assert rune_per_default == 'NrM7go6C4qzfRQDkUSv1DtRroJWSKqdjIOuvGS4TLFE9NCZwZXI9MQ==' - do_test_rune_per_restriction(l1, rune_per_default, 1) + rune_per_default = l1.rpc.createrune(restrictions=[["per=2"]])['rune'] + assert rune_per_default == 'pd0Xr2U3uv-mJQfsp801doqTN5zpRRuc2Clp5Yb8zmU9NCZwZXI9Mg==' + do_test_rune_per_restriction(l1, rune_per_default, 2) # 1 minute rune_per_min = l1.rpc.createrune(restrictions=[["per=1min"]])['rune']