Skip to content

Commit

Permalink
add test
Browse files Browse the repository at this point in the history
  • Loading branch information
raphjaph committed Jan 16, 2023
1 parent 45a55fc commit 08395d2
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 0 deletions.
4 changes: 4 additions & 0 deletions test-bitcoincore-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,10 @@ impl Handle {
Network::Regtest => Network::Regtest.to_string(),
}
}

pub fn loaded_wallets(&self) -> BTreeSet<String> {
self.state().loaded_wallets.clone()
}
}

impl Drop for Handle {
Expand Down
1 change: 1 addition & 0 deletions test-bitcoincore-rpc/src/server.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ impl Api for Server {

fn load_wallet(&self, wallet: String) -> Result<LoadWalletResult, jsonrpc_core::Error> {
if self.state().wallets.contains(&wallet) {
self.state().loaded_wallets.insert(wallet.clone());
Ok(LoadWalletResult {
name: wallet,
warning: None,
Expand Down
2 changes: 2 additions & 0 deletions test-bitcoincore-rpc/src/state.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ pub(crate) struct State {
pub(crate) version: usize,
pub(crate) wallet_name: String,
pub(crate) wallets: BTreeSet<String>,
pub(crate) loaded_wallets: BTreeSet<String>,
}

impl State {
Expand Down Expand Up @@ -47,6 +48,7 @@ impl State {
version,
wallet_name: wallet_name.to_string(),
wallets: BTreeSet::new(),
loaded_wallets: BTreeSet::new(),
}
}

Expand Down
4 changes: 4 additions & 0 deletions tests/wallet/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,14 @@ fn transactions() {
let rpc_server = test_bitcoincore_rpc::spawn();
create_wallet(&rpc_server);

assert_eq!(rpc_server.loaded_wallets().len(), 0);

CommandBuilder::new("wallet transactions")
.rpc_server(&rpc_server)
.run();

assert_eq!(rpc_server.loaded_wallets().len(), 1);

rpc_server.mine_blocks(1);

CommandBuilder::new("wallet transactions")
Expand Down

0 comments on commit 08395d2

Please sign in to comment.