Skip to content

Commit

Permalink
Merge branch '42-test-remove-rpc' into 46-test-list-rpc
Browse files Browse the repository at this point in the history
  • Loading branch information
fmhoeger committed Dec 19, 2023
2 parents b0b9795 + 4a32a83 commit 586475d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 2 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ async fn add(plugin: Plugin<State>, args: AddArgs) -> Result<serde_json::Value,
};
let mut dw_clone = dw.clone();
let wallet = dw_clone
.fetch_wallet(db_dir.clone(), brpc_host, brpc_port, brpc_auth)
.fetch_wallet(db_dir, brpc_host, brpc_port, brpc_auth)
.await?;
let bdk_transactions_iter = wallet.transactions();
let mut transactions = Vec::<CanonicalTx<'_, Transaction, ConfirmationTimeAnchor>>::new();
Expand Down Expand Up @@ -374,9 +374,8 @@ async fn add(plugin: Plugin<State>, args: AddArgs) -> Result<serde_json::Value,
.map_err(|e| anyhow!("Error calling listdatastore: {:?}", e))?;
let name = &dw.get_name()?;
let message = format!("Wallet with deterministic name {} successfully added", name);
let db_path = dw_clone.get_db_file_path(db_dir).unwrap();
log::info!("{}", message);
Ok(json!({"name": name, "message": message, "db_path": db_path}))
Ok(json!({"name": name, "message": message}))
}

#[derive(Debug, Deserialize, Serialize, Clone)]
Expand Down
6 changes: 3 additions & 3 deletions tests/test_rpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,19 @@ def test_rpc_remove(node_factory, bitcoind):
# add wallet to smaug
wallet = l1.rpc.smaug("add", external_descriptor, internal_descriptor)
wallet_name = wallet["name"]
db_path = wallet["db_path"]
db_file_path = f"{str(l1.lightning_dir)}/regtest/.smaug/{wallet_name}.db"
smaug_wallets = l1.rpc.smaug("ls")
assert len(smaug_wallets) == 1
assert wallet_name in smaug_wallets
assert os.path.isfile(db_path)
assert os.path.isfile(db_file_path)

# remove wallet from smaug
result = l1.rpc.smaug("remove", wallet_name)

smaug_wallets = l1.rpc.smaug("ls")
assert len(smaug_wallets) == 0
assert result == f"Deleted wallet: {wallet_name}"
assert not os.path.isfile(db_path)
assert not os.path.isfile(db_file_path)


def test_rpc_list(node_factory, bitcoind):
Expand Down

0 comments on commit 586475d

Please sign in to comment.