Skip to content

Commit

Permalink
tests: Add generate_to_address integration test.
Browse files Browse the repository at this point in the history
  • Loading branch information
ceyhunsen committed Jul 4, 2024
1 parent b4881c1 commit 4ea539b
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions tests/address.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,19 @@ use bitcoin_mock_rpc::{Client, RpcApiWrapper};
use bitcoincore_rpc::{Auth, RpcApi};
use std::thread;

#[test]
fn generate_to_address() {
let rpc = Client::new("", Auth::None).unwrap();
let address = rpc.get_new_address(None, None).unwrap().assume_checked();

let initial_balance = rpc.get_balance(None, None).unwrap();

rpc.generate_to_address(101, &address).unwrap();
assert!(rpc.get_balance(None, None).unwrap() > initial_balance);
}

#[test]
fn generate_to_address_multi_threaded() {
// Bacause `thread::spawn` moves value to closure, cloning a new is needed. This is good,
// because cloning an rpc struct should have a persistent ledger even though there are more than
// one accessors.
let rpc = Client::new("", Auth::None).unwrap();
let cloned_rpc = rpc.clone();
let address = rpc.get_new_address(None, None).unwrap().assume_checked();
Expand Down

0 comments on commit 4ea539b

Please sign in to comment.