Skip to content

Commit

Permalink
fixes the rest of wallet_grpc_test
Browse files Browse the repository at this point in the history
  • Loading branch information
arya2 committed Dec 10, 2024
1 parent 5cd9155 commit d150018
Showing 1 changed file with 31 additions and 31 deletions.
62 changes: 31 additions & 31 deletions zebrad/tests/common/lightwalletd/wallet_grpc_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,6 +334,37 @@ pub async fn run() -> Result<()> {

all_stream_addresses.push(stream_address);
all_balance_streams.push(balance_stream.value_zat);

// Call `GetAddressUtxos` with the active funding stream address that will always have utxos
let utxos = rpc_client
.get_address_utxos(GetAddressUtxosArg {
addresses: vec![fs_address.to_string()],
start_height: 1,
max_entries: 1,
})
.await?
.into_inner();

// As we requested one entry we should get a response of length 1
assert_eq!(utxos.address_utxos.len(), 1);

// Call `GetAddressUtxosStream` with the active funding stream address that will always have utxos
let mut utxos_zf = rpc_client
.get_address_utxos_stream(GetAddressUtxosArg {
addresses: vec![fs_address.to_string()],
start_height: 1,
max_entries: 2,
})
.await?
.into_inner();

let mut counter = 0;
while let Some(_utxos) = utxos_zf.message().await? {
counter += 1;
}
// As we are in a "in sync" chain we know there are more than 2 utxos for this address (coinbase maturity rule)
// but we will receive the max of 2 from the stream response because we used a limit of 2 `max_entries`.
assert_eq!(2, counter);
}

if let Some(expected_total_balance) = all_balance_streams.into_iter().reduce(|a, b| a + b) {
Expand Down Expand Up @@ -375,37 +406,6 @@ pub async fn run() -> Result<()> {
*zebra_test::vectors::SAPLING_TREESTATE_MAINNET_419201_STRING
);

// Call `GetAddressUtxos` with the ZF funding stream address that will always have utxos
let utxos = rpc_client
.get_address_utxos(GetAddressUtxosArg {
addresses: vec!["t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1".to_string()],
start_height: 1,
max_entries: 1,
})
.await?
.into_inner();

// As we requested one entry we should get a response of length 1
assert_eq!(utxos.address_utxos.len(), 1);

// Call `GetAddressUtxosStream` with the ZF funding stream address that will always have utxos
let mut utxos_zf = rpc_client
.get_address_utxos_stream(GetAddressUtxosArg {
addresses: vec!["t3dvVE3SQEi7kqNzwrfNePxZ1d4hUyztBA1".to_string()],
start_height: 1,
max_entries: 2,
})
.await?
.into_inner();

let mut counter = 0;
while let Some(_utxos) = utxos_zf.message().await? {
counter += 1;
}
// As we are in a "in sync" chain we know there are more than 2 utxos for this address
// but we will receive the max of 2 from the stream response because we used a limit of 2 `max_entries`.
assert_eq!(2, counter);

// Call `GetLightdInfo`
let lightd_info = rpc_client.get_lightd_info(Empty {}).await?.into_inner();

Expand Down

0 comments on commit d150018

Please sign in to comment.