Skip to content

Commit 4cdfc21

Browse files
committed
tests: fixed feerate tolerance and signature detection(Fixes #8493)
Changelog-None
1 parent 4c38125 commit 4cdfc21

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

tests/utils.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
from pyln.client import Millisatoshi
55
from pyln.testing.utils import EXPERIMENTAL_DUAL_FUND, EXPERIMENTAL_SPLICING
66
from pyln.proto.onion import TlvPayload
7+
import pytest
78
import struct
89
import subprocess
910
import tempfile
@@ -669,18 +670,16 @@ def serialize_payload_final_tlv(amount_msat, delay, total_msat, blockheight, pay
669670
# I wish we could force libwally to use different entropy and thus force it to
670671
# create 71-byte sigs always!
671672
def did_short_sig(node):
672-
# This can take a moment to appear in the log!
673-
time.sleep(2)
674-
return node.daemon.is_in_log('overgrind: short signature length')
673+
try:
674+
wait_for(lambda: node.daemon.is_in_log('overgrind: short signature length'), timeout=5)
675+
return True
676+
except (TimeoutError, ValueError):
677+
return False
675678

676679

677680
def check_feerate(nodes, actual_feerate, expected_feerate):
678-
# Feerate can't be lower.
679-
680-
tolerance = 10
681-
assert actual_feerate > expected_feerate - tolerance
682-
if actual_feerate >= expected_feerate + tolerance:
681+
assert actual_feerate >= expected_feerate - 10
682+
if actual_feerate >= expected_feerate + 10:
683683
if any([did_short_sig(n) for n in nodes]):
684684
return
685-
# Use assert as it shows the actual values on failure
686-
assert actual_feerate < expected_feerate + tolerance
685+
assert actual_feerate == pytest.approx(expected_feerate, rel=0.001, abs=10)

0 commit comments

Comments
 (0)