forked from ElementsProject/lightning
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
pytest: Test the rust bindings from cln-rpc
- Loading branch information
Showing
5 changed files
with
47 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
use anyhow::Context; | ||
use cln_rpc::{model::GetinfoRequest, ClnRpc, Request}; | ||
use log::info; | ||
use std::env::args; | ||
use std::path::Path; | ||
use tokio; | ||
|
||
#[tokio::main] | ||
async fn main() -> Result<(), anyhow::Error> { | ||
env_logger::init(); | ||
let rpc_path = args().nth(1).context("missing argument: socket path")?; | ||
let p = Path::new(&rpc_path); | ||
|
||
let mut rpc = ClnRpc::new(p).await?; | ||
let response = rpc.call(Request::Getinfo(GetinfoRequest {})).await?; | ||
info!("{}", serde_json::to_string_pretty(&response)?); | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
from fixtures import * # noqa: F401,F403 | ||
from pathlib import Path | ||
from pyln.testing.utils import env, TEST_NETWORK | ||
import subprocess | ||
import os | ||
import pytest | ||
|
||
|
||
# Skip the entire module if we don't have Rust. | ||
pytestmark = pytest.mark.skipif( | ||
env('RUST') != '1', | ||
reason='RUST is not enabled, skipping rust-dependent tests' | ||
) | ||
|
||
os.environ['RUST_LOG'] = "trace" | ||
|
||
|
||
def test_rpc_client(node_factory): | ||
l1 = node_factory.get_node() | ||
bin_path = Path.cwd() / "target" / "debug" / "examples" / "cln-rpc-getinfo" | ||
rpc_path = Path(l1.daemon.lightning_dir) / TEST_NETWORK / "lightning-rpc" | ||
out = subprocess.check_output([bin_path, rpc_path], stderr=subprocess.STDOUT) | ||
assert(b'0266e4598d1d3c415f572a8488830b60f7e744ed9235eb0b1ba93283b315c03518' in out) |