Skip to content

Commit

Permalink
tests: fix regression
Browse files Browse the repository at this point in the history
  • Loading branch information
daywalker90 committed Mar 11, 2025
1 parent 86b7c9f commit 82d34b0
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 24 deletions.
26 changes: 12 additions & 14 deletions tests/test_holdinvoice_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
import threading
import time

from pyln.client import Millisatoshi
import pytest
from pyln.client import Millisatoshi, RpcError
from pyln.testing.fixtures import * # noqa: F403
from pyln.testing.utils import only_one, sync_blockheight, wait_for
from util import (
Expand Down Expand Up @@ -130,19 +131,16 @@ def test_inputs(node_factory, get_plugin): # noqa: F811
assert result["message"] == expected_message

# 0 amount_msat
result = node.rpc.call(
"holdinvoice",
{
"amount_msat": 0,
"description": "Invalid amount 0",
"label": generate_random_label(),
"cltv": 144,
},
)
assert result is not None
assert isinstance(result, dict) is True
expected_message = "should be positive msat or 'any': invalid token '\"0msat\"'"
assert expected_message in result["message"]
with pytest.raises(RpcError, match=r"amount_msat: should be positive msat or"):
node.rpc.call(
"holdinvoice",
{
"amount_msat": 0,
"description": "Invalid amount 0",
"label": generate_random_label(),
"cltv": 144,
},
)

# Negative expiry value
result = node.rpc.call(
Expand Down
30 changes: 20 additions & 10 deletions tests/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,18 +34,28 @@ def generate_random_number():
return random.randint(1, 20_000_000_000_000_00_000)


def pay_with_thread(node, bolt11, partial_msat):
def pay_with_thread(node, bolt11, partial_msat=None):
LOGGER = logging.getLogger(__name__)
try:
node.rpc.call(
"pay",
{
"bolt11": bolt11,
"dev_use_shadow": False,
"retry_for": 20,
"partial_msat": partial_msat,
},
)
if partial_msat:
node.rpc.call(
"pay",
{
"bolt11": bolt11,
"dev_use_shadow": False,
"retry_for": 20,
"partial_msat": partial_msat,
},
)
else:
node.rpc.call(
"pay",
{
"bolt11": bolt11,
"dev_use_shadow": False,
"retry_for": 20,
},
)
except Exception as e:
LOGGER.info(f"holdinvoice: Error paying payment hash:{e}")
pass
Expand Down

0 comments on commit 82d34b0

Please sign in to comment.