mirror of
https://github.com/ElementsProject/lightning.git
synced 2025-02-22 14:42:40 +01:00
pytest: Add a test for the cln-plugin logging integration
This commit is contained in:
parent
f5e1829117
commit
fe21b89b56
2 changed files with 19 additions and 7 deletions
|
@ -6,9 +6,10 @@ use tokio;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), anyhow::Error> {
|
async fn main() -> Result<(), anyhow::Error> {
|
||||||
env_logger::init();
|
|
||||||
|
|
||||||
let (plugin, stdin) = Builder::new((), tokio::io::stdin(), tokio::io::stdout()).build();
|
let (plugin, stdin) = Builder::new((), tokio::io::stdin(), tokio::io::stdout()).build();
|
||||||
plugin.run(stdin).await;
|
tokio::spawn(async {
|
||||||
Ok(())
|
tokio::time::sleep(tokio::time::Duration::from_millis(1000)).await;
|
||||||
|
log::info!("Hello world");
|
||||||
|
});
|
||||||
|
plugin.run(stdin).await
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@ from fixtures import * # noqa: F401,F403
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from pyln.testing.utils import env, TEST_NETWORK
|
from pyln.testing.utils import env, TEST_NETWORK
|
||||||
import subprocess
|
import subprocess
|
||||||
import os
|
|
||||||
import pytest
|
import pytest
|
||||||
|
|
||||||
|
|
||||||
|
@ -12,8 +11,6 @@ pytestmark = pytest.mark.skipif(
|
||||||
reason='RUST is not enabled, skipping rust-dependent tests'
|
reason='RUST is not enabled, skipping rust-dependent tests'
|
||||||
)
|
)
|
||||||
|
|
||||||
os.environ['RUST_LOG'] = "trace"
|
|
||||||
|
|
||||||
|
|
||||||
def test_rpc_client(node_factory):
|
def test_rpc_client(node_factory):
|
||||||
l1 = node_factory.get_node()
|
l1 = node_factory.get_node()
|
||||||
|
@ -21,3 +18,17 @@ def test_rpc_client(node_factory):
|
||||||
rpc_path = Path(l1.daemon.lightning_dir) / TEST_NETWORK / "lightning-rpc"
|
rpc_path = Path(l1.daemon.lightning_dir) / TEST_NETWORK / "lightning-rpc"
|
||||||
out = subprocess.check_output([bin_path, rpc_path], stderr=subprocess.STDOUT)
|
out = subprocess.check_output([bin_path, rpc_path], stderr=subprocess.STDOUT)
|
||||||
assert(b'0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518' in out)
|
assert(b'0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518' in out)
|
||||||
|
|
||||||
|
|
||||||
|
def test_plugin_start(node_factory):
|
||||||
|
"""Start a minimal plugin and ensure it is well-behaved
|
||||||
|
"""
|
||||||
|
bin_path = Path.cwd() / "target" / "debug" / "examples" / "cln-plugin-startup"
|
||||||
|
l1 = node_factory.get_node(options={"plugin": str(bin_path)})
|
||||||
|
|
||||||
|
# The plugin should be in the list of active plugins
|
||||||
|
plugins = l1.rpc.plugin('list')['plugins']
|
||||||
|
assert len([p for p in plugins if 'cln-plugin-startup' in p['name'] and p['active']]) == 1
|
||||||
|
|
||||||
|
# Logging should also work through the log integration
|
||||||
|
l1.daemon.wait_for_log(r'Hello world')
|
||||||
|
|
Loading…
Add table
Reference in a new issue