Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(test): run core lightning with the plugin directly #171

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion coffee_testing/src/cln.rs
Original file line number Diff line number Diff line change
Expand Up @@ -73,17 +73,22 @@ impl Drop for Node {

impl Node {
pub async fn tmp() -> anyhow::Result<Self> {
Self::with_params("").await
}

pub async fn with_params(params: &str) -> anyhow::Result<Self> {
let btc = BtcNode::tmp().await?;

let dir = tempfile::tempdir()?;

let process = macros::lightningd!(
dir,
port::random_free_port().unwrap(),
"--network=regtest --log-level=debug --bitcoin-rpcuser={} --bitcoin-rpcpassword={} --bitcoin-rpcport={}",
"--network=regtest --log-level=debug --bitcoin-rpcuser={} --bitcoin-rpcpassword={} --bitcoin-rpcport={} {}",
btc.user,
btc.pass,
btc.port,
params,
)?;

let rpc = LightningRPC::new(dir.path().join(".lightning/regtest").join("lightning-rpc"));
Expand Down
40 changes: 6 additions & 34 deletions tests/src/coffee_plugin_integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,23 +8,13 @@ use crate::init;
pub async fn init_cln_with_coffee_plugin_test() {
init();

let mut cln = Node::tmp().await.unwrap();

let cargo_target = concat!(env!("CARGO_MANIFEST_DIR"), "/..");
let path = std::path::Path::new(cargo_target).to_str().unwrap();
let plugin_path = format!("{path}/target/debug/coffee_plugin");
log::info!("plugin path {plugin_path}");
let result: serde_json::Value = cln
.rpc()
.call(
"plugin",
serde_json::json!({
"subcommand": "start",
"plugin": plugin_path,
}),
)
let mut cln = Node::with_params(&format!("--plugin={plugin_path}"))
.await
.unwrap();
log::info!("cln response {result}");
cln.stop().await.unwrap();
}

Expand All @@ -33,22 +23,13 @@ pub async fn init_cln_with_coffee_plugin_test() {
pub async fn init_cln_with_coffee_add_remore_test() {
init();

let mut cln = Node::tmp().await.unwrap();

let cargo_target = concat!(env!("CARGO_MANIFEST_DIR"), "/..");
let path = std::path::Path::new(cargo_target).to_str().unwrap();
let plugin_path = format!("{path}/target/debug/coffee_plugin");
log::info!("plugin path {plugin_path}");

let _: serde_json::Value = cln
.rpc()
.call(
"plugin",
serde_json::json!({
"subcommand": "start",
"plugin": plugin_path,
}),
)
let mut cln = Node::with_params(&format!("--plugin={plugin_path}"))
.await
.unwrap();

let result: serde_json::Value = cln
Expand All @@ -71,22 +52,13 @@ pub async fn init_cln_with_coffee_add_remore_test() {
pub async fn init_cln_with_coffee_install_plugin_test() {
init();

let mut cln = Node::tmp().await.unwrap();

let cargo_target = concat!(env!("CARGO_MANIFEST_DIR"), "/..");
let path = std::path::Path::new(cargo_target).to_str().unwrap();
let plugin_path = format!("{path}/target/debug/coffee_plugin");
log::info!("plugin path {plugin_path}");

let _: serde_json::Value = cln
.rpc()
.call(
"plugin",
serde_json::json!({
"subcommand": "start",
"plugin": plugin_path,
}),
)
let mut cln = Node::with_params(&format!("--plugin={plugin_path}"))
.await
.unwrap();

let result: serde_json::Value = cln
Expand Down
Loading