Skip to content

Commit

Permalink
Fix receivedbyaddress
Browse files Browse the repository at this point in the history
Fix the integration test for `recievedbyaddress`. Requires fixing the
client method implementation also because I forgot to pass in the
address - duh.
  • Loading branch information
tcharding committed Dec 6, 2024
1 parent c533676 commit f011171
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 7 deletions.
9 changes: 6 additions & 3 deletions client/src/client_sync/v17/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,11 @@ macro_rules! impl_client_v17__getrawchangeaddress {
macro_rules! impl_client_v17__getreceivedbyaddress {
() => {
impl Client {
pub fn get_received_by_address(&self) -> Result<GetReceivedByAddress> {
self.call("getreceivedbyaddress", &[])
pub fn get_received_by_address(
&self,
address: &Address<NetworkChecked>,
) -> Result<GetReceivedByAddress> {
self.call("getreceivedbyaddress", &[address.to_string().into()])
}
}
};
Expand Down Expand Up @@ -406,7 +409,7 @@ macro_rules! impl_client_v17__sendtoaddress {
macro_rules! impl_client_v17__signmessage {
() => {
impl Client {
pub fn sign_message(&self, address: Address, message: &str) -> Result<SignMessage> {
pub fn sign_message(&self, address: &Address, message: &str) -> Result<SignMessage> {
self.call("signmessage", &[into_json(address)?, into_json(message)?])
}
}
Expand Down
19 changes: 16 additions & 3 deletions integration_test/tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,11 +136,24 @@ fn get_raw_change_address() {
}

#[test]
#[cfg(feature = "TODO")]
fn get_received_by_address() {
let amount = Amount::from_sat(10_000);

let node = Node::new_with_default_wallet();
let json = node.client.get_received_by_address().expect("getreceivedbyaddress");
assert!(json.into_model().is_ok());
node.fund_wallet();
let address = node.client.new_address().expect("failed to create new address");

let _txid = node
.client
.send_to_address(&address, amount)
.expect("sendtoaddress")
.txid()
.unwrap();
node.mine_a_block();

let json = node.client.get_received_by_address(&address).expect("getreceivedbyaddress");
let model = json.into_model().expect("into_model failed");
assert_eq!(model.0, amount);
}

#[test]
Expand Down
2 changes: 1 addition & 1 deletion types/src/v17/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@
//! | getnewaddress | done |
//! | getrawchangeaddress | done |
//! | getreceivedbyaccount | omitted |
//! | getreceivedbyaddress | done (untested) |
//! | getreceivedbyaddress | done |
//! | gettransaction | done |
//! | getunconfirmedbalance | done (untested) |
//! | getwalletinfo | done (untested) |
Expand Down

0 comments on commit f011171

Please sign in to comment.