From b7465883564eb1f3ef4f2783f5ed96e363e94423 Mon Sep 17 00:00:00 2001 From: Rusty Russell Date: Thu, 18 May 2023 15:44:01 +0930 Subject: [PATCH] pytest: fix tests/test_cln_rs.py to avoid race. When we release too fast, the plugin crashes: ``` thread 'tokio-runtime-worker' panicked at 'called Result::unwrap() on an Err value: SendError(())', plugins/examples/cln-plugin-reentrant.rs:31:27 note: run with RUST_BACKTRACE=1 environment variable to display a backtrace ``` This happens with CI under VALGRIND! Signed-off-by: Rusty Russell --- tests/test_cln_rs.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/test_cln_rs.py b/tests/test_cln_rs.py index 19ccbba0e..1abe2f318 100644 --- a/tests/test_cln_rs.py +++ b/tests/test_cln_rs.py @@ -4,7 +4,7 @@ from pathlib import Path from pyln.testing import node_pb2 as nodepb from pyln.testing import node_pb2_grpc as nodegrpc from pyln.testing import primitives_pb2 as primitivespb -from pyln.testing.utils import env, TEST_NETWORK, wait_for, sync_blockheight +from pyln.testing.utils import env, TEST_NETWORK, wait_for, sync_blockheight, TIMEOUT import grpc import pytest import subprocess @@ -275,14 +275,13 @@ def test_cln_plugin_reentrant(node_factory, executor): f1 = executor.submit(l2.rpc.pay, i1) f2 = executor.submit(l2.rpc.pay, i2) - import time - time.sleep(3) + l1.daemon.wait_for_logs(["plugin-cln-plugin-reentrant: Holding on to incoming HTLC Object"] * 2) print("Releasing HTLCs after holding them") l1.rpc.call('release') - assert f1.result() - assert f2.result() + assert f1.result(timeout=TIMEOUT) + assert f2.result(timeout=TIMEOUT) def test_grpc_keysend_routehint(bitcoind, node_factory):