Skip to content

Commit

Permalink
Merge branch 'dev' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
zancas committed Oct 28, 2024
2 parents 5e319f4 + 3045bea commit bd9a552
Show file tree
Hide file tree
Showing 31 changed files with 345 additions and 367 deletions.
4 changes: 2 additions & 2 deletions darkside-tests/tests/advanced_reorg_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ async fn reorg_changes_outgoing_tx_index() {
//

// stage empty blocks from height 205 to cause a Reorg
_ = connector.stage_blocks_create(sent_tx_height, 20, 1).await;
_ = connector.stage_blocks_create(sent_tx_height, 20, 102).await;

_ = connector
.stage_transactions_stream(
Expand All @@ -1060,7 +1060,7 @@ async fn reorg_changes_outgoing_tx_index() {
)
.await;

_ = connector.apply_staged(211).await;
_ = connector.apply_staged(312).await;

let reorg_sync_result = light_client.do_sync(true).await;

Expand Down
4 changes: 2 additions & 2 deletions darkside-tests/tests/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,8 +181,8 @@ async fn sent_transaction_reorged_into_mempool() {
.await
.unwrap();
let connector = DarksideConnector(server_id.clone());
connector.stage_blocks_create(4, 1, 0).await.unwrap();
connector.apply_staged(4).await.unwrap();
connector.stage_blocks_create(4, 102, 0).await.unwrap();
connector.apply_staged(105).await.unwrap();
sleep(std::time::Duration::from_secs(1)).await;

recipient.do_sync(false).await.unwrap();
Expand Down
72 changes: 6 additions & 66 deletions libtonode-tests/tests/concrete.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1084,10 +1084,10 @@ mod slow {
scenarios::faucet_recipient_default().await;

// 2. Get an incoming transaction to a t address
let taddr = get_base_address_macro!(recipient, "transparent");
let recipient_taddr = get_base_address_macro!(recipient, "transparent");
let value = 100_000;

from_inputs::quick_send(&faucet, vec![(taddr.as_str(), value, None)])
from_inputs::quick_send(&faucet, vec![(recipient_taddr.as_str(), value, None)])
.await
.unwrap();

Expand All @@ -1099,7 +1099,10 @@ mod slow {
// 3. Test the list
let list = recipient.do_list_transactions().await;
assert_eq!(list[0]["block_height"].as_u64().unwrap(), 4);
assert_eq!(list[0]["address"], taddr);
assert_eq!(
recipient.do_addresses().await[0]["receivers"]["transparent"].to_string(),
recipient_taddr
);
assert_eq!(list[0]["amount"].as_u64().unwrap(), value);

// 4. We can't spend the funds, as they're transparent. We need to shield first
Expand Down Expand Up @@ -3228,69 +3231,6 @@ mod slow {
serde_json::to_string_pretty(&recipient.do_balance().await).unwrap()
);
}
#[tokio::test]
async fn dont_write_pending() {
let regtest_network = RegtestNetwork::all_upgrades_active();
let (regtest_manager, _cph, faucet, recipient) = scenarios::faucet_recipient(
PoolType::Shielded(ShieldedProtocol::Orchard),
regtest_network,
)
.await;
from_inputs::quick_send(
&faucet,
vec![(
&get_base_address_macro!(recipient, "unified"),
100_000,
Some("funding to be received by the recipient"),
)],
)
.await
.unwrap();

zingolib::testutils::increase_height_and_wait_for_client(&regtest_manager, &recipient, 2)
.await
.unwrap();
let recipient_balance = recipient.do_balance().await;
assert_eq!(
recipient_balance,
PoolBalances {
sapling_balance: Some(0),
verified_sapling_balance: Some(0),
spendable_sapling_balance: Some(0),
unverified_sapling_balance: Some(0),
orchard_balance: Some(100000),
verified_orchard_balance: Some(100000),
spendable_orchard_balance: Some(100000),
unverified_orchard_balance: Some(0),
transparent_balance: Some(0)
}
);
from_inputs::quick_send(
&recipient,
vec![(
&get_base_address_macro!(faucet, "unified"),
25_000,
Some("an pending transaction, that shall not be synced"),
)],
)
.await
.unwrap();
let recipient_balance = recipient.do_balance().await;

dbg!(&recipient_balance.unverified_orchard_balance);
assert_eq!(
recipient_balance.unverified_orchard_balance.unwrap(),
65_000
);

let loaded_client =
zingolib::testutils::lightclient::new_client_from_save_buffer(&recipient)
.await
.unwrap();
let loaded_balance = loaded_client.do_balance().await;
assert_eq!(loaded_balance.unverified_orchard_balance, Some(0),);
check_client_balances!(loaded_client, o: 100_000 s: 0 t: 0 );
}

#[tokio::test]
async fn by_address_finsight() {
Expand Down
35 changes: 20 additions & 15 deletions libtonode-tests/tests/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,37 +101,40 @@ mod load_wallet {
);
let expected_pre_sync_transactions = r#"[
{
"outgoing_metadata": [],
"amount": 100000,
"memo": "null, null",
"block_height": 3,
"pending": false,
"datetime": 1692212261,
"position": 0,
"txid": "7a9d41caca143013ebd2f710e4dad04f0eb9f0ae98b42af0f58f25c61a9d439e",
"amount": 100000,
"zec_price": null,
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8",
"memo": null
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8"
},
{
"outgoing_metadata": [],
"amount": 50000,
"memo": "null, null",
"block_height": 8,
"pending": false,
"datetime": 1692212266,
"position": 0,
"txid": "122f8ab8dc5483e36256a4fbd7ff8d60eb7196670716a6690f9215f1c2a4d841",
"amount": 50000,
"zec_price": null,
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8",
"memo": null
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8"
},
{
"outgoing_metadata": [],
"amount": 30000,
"memo": "null, null",
"block_height": 9,
"pending": false,
"datetime": 1692212299,
"position": 0,
"txid": "0a014017add7dc9eb57ada3e70f905c9dce610ef055e135b03f4907dd5dc99a4",
"amount": 30000,
"zec_price": null,
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8",
"memo": null
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8"
}
]"#;
assert_eq!(
Expand All @@ -141,26 +144,28 @@ mod load_wallet {
recipient.do_sync(false).await.unwrap();
let expected_post_sync_transactions = r#"[
{
"outgoing_metadata": [],
"amount": 100000,
"memo": "null, null",
"block_height": 3,
"pending": false,
"datetime": 1692212261,
"position": 0,
"txid": "7a9d41caca143013ebd2f710e4dad04f0eb9f0ae98b42af0f58f25c61a9d439e",
"amount": 100000,
"zec_price": null,
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8",
"memo": null
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8"
},
{
"outgoing_metadata": [],
"amount": 50000,
"memo": "null, null",
"block_height": 8,
"pending": false,
"datetime": 1692212266,
"position": 0,
"txid": "122f8ab8dc5483e36256a4fbd7ff8d60eb7196670716a6690f9215f1c2a4d841",
"amount": 50000,
"zec_price": null,
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8",
"memo": null
"address": "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8"
}
]"#;
assert_eq!(
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.81"
channel = "1.82"
components = [ "clippy", "rustfmt" ]
4 changes: 2 additions & 2 deletions zingo-memo/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub enum ParsedMemo {
/// the list of unified addresses
uas: Vec<UnifiedAddress>,
/// The ephemeral address indexes
ephemeral_address_indexes: Vec<u32>,
rejection_address_indexes: Vec<u32>,
},
}

Expand Down Expand Up @@ -99,7 +99,7 @@ pub fn parse_zingo_memo(memo: [u8; 511]) -> io::Result<ParsedMemo> {
}),
1 => Ok(ParsedMemo::Version1 {
uas: Vector::read(&mut reader, |r| read_unified_address_from_raw_encoding(r))?,
ephemeral_address_indexes: Vector::read(&mut reader, |r| CompactSize::read_t(r))?,
rejection_address_indexes: Vector::read(&mut reader, |r| CompactSize::read_t(r))?,
}),
_ => Err(io::Error::new(
io::ErrorKind::InvalidData,
Expand Down
3 changes: 1 addition & 2 deletions zingo-netutils/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ use client::client_from_connector;
use http::{uri::PathAndQuery, Uri};
use http_body_util::combinators::UnsyncBoxBody;
use hyper_util::client::legacy::connect::HttpConnector;
use thiserror::Error;
use tokio_rustls::rustls::pki_types::{Der, TrustAnchor};
use tokio_rustls::rustls::{ClientConfig, RootCertStore};
use tonic::Status;
Expand All @@ -26,7 +25,7 @@ pub type UnderlyingService = BoxCloneService<
>;

#[allow(missing_docs)] // error types document themselves
#[derive(Debug, Error)]
#[derive(Debug, thiserror::Error)]
pub enum GetClientError {
#[error("bad uri: invalid scheme")]
InvalidScheme,
Expand Down
34 changes: 18 additions & 16 deletions zingocli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,28 +84,30 @@ fn parse_uri(s: &str) -> Result<http::Uri, String> {
/// currently this is just a whitespace delimited string of 24 words. I am
/// poking around to use the actual BIP39 parser (presumably from librustzcash).
fn parse_seed(s: &str) -> Result<String, String> {
if let Ok(s) = s.parse::<String>() {
let count = s.split_whitespace().count();
if count == 24 {
Ok(s)
} else {
Err(format!("Expected 24 words, but received: {}.", count))
match s.parse::<String>() {
Ok(s) => {
let count = s.split_whitespace().count();
if count == 24 {
Ok(s)
} else {
Err(format!("Expected 24 words, but received: {}.", count))
}
}
} else {
Err("Unexpected failure to parse String!!".to_string())
Err(_) => Err("Unexpected failure to parse String!!".to_string()),
}
}
/// Parse encoded UFVK to String and check for whitespaces
fn parse_ufvk(s: &str) -> Result<String, String> {
if let Ok(s) = s.parse::<String>() {
let count = s.split_whitespace().count();
if count == 1 {
Ok(s)
} else {
Err("Encoded UFVK should not contain whitespace!".to_string())
match s.parse::<String>() {
Ok(s) => {
let count = s.split_whitespace().count();
if count == 1 {
Ok(s)
} else {
Err("Encoded UFVK should not contain whitespace!".to_string())
}
}
} else {
Err("Unexpected failure to parse String!!".to_string())
Err(_) => Err("Unexpected failure to parse String!!".to_string()),
}
}
#[cfg(target_os = "linux")]
Expand Down
2 changes: 1 addition & 1 deletion zingolib/src/blaze/fetch_taddr_transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ impl FetchTaddrTransactions {
.iter()
.filter_map(|ua| ua.transparent())
.chain(
wc.transparent_child_ephemeral_addresses()
wc.get_rejection_addresses()
.iter()
.map(|(taddr, _metadata)| taddr),
)
Expand Down
2 changes: 1 addition & 1 deletion zingolib/src/lightclient/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ impl LightClient {
create_send_value_transfers(&mut value_transfers, tx);
}
TransactionKind::Received => {
// create 1 received value tansfer for each pool recieved to
// create 1 received value tansfer for each pool received to
if !tx.orchard_notes().is_empty() {
let value: u64 =
tx.orchard_notes().iter().map(|output| output.value()).sum();
Expand Down
15 changes: 7 additions & 8 deletions zingolib/src/lightclient/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,14 @@ pub mod send_with_proposal {

use zcash_primitives::transaction::{Transaction, TxId};

use thiserror::Error;
use zingo_status::confirmation_status::ConfirmationStatus;

use crate::lightclient::LightClient;
use crate::wallet::now;
use crate::wallet::propose::{ProposeSendError, ProposeShieldError};

#[allow(missing_docs)] // error types document themselves
#[derive(Clone, Debug, Error)]
#[derive(Clone, Debug, thiserror::Error)]
pub enum TransactionCacheError {
#[error("No witness trees. This is viewkey watch, not spendkey wallet.")]
NoSpendCapability,
Expand All @@ -55,7 +54,7 @@ pub mod send_with_proposal {
}

#[allow(missing_docs)] // error types document themselves
#[derive(Clone, Debug, Error)]
#[derive(Clone, Debug, thiserror::Error)]
pub enum BroadcastCachedTransactionsError {
#[error("Cant broadcast: {0:?}")]
Cache(#[from] TransactionCacheError),
Expand All @@ -66,7 +65,7 @@ pub mod send_with_proposal {
}

#[allow(missing_docs)] // error types document themselves
#[derive(Debug, Error)]
#[derive(Debug, thiserror::Error)]
pub enum RecordCachedTransactionsError {
#[error("Cant record: {0:?}")]
Cache(#[from] TransactionCacheError),
Expand All @@ -77,7 +76,7 @@ pub mod send_with_proposal {
}

#[allow(missing_docs)] // error types document themselves
#[derive(Debug, Error)]
#[derive(Debug, thiserror::Error)]
pub enum CompleteAndBroadcastError {
#[error("The transaction could not be calculated: {0:?}")]
BuildTransaction(#[from] crate::wallet::send::BuildTransactionError),
Expand All @@ -90,7 +89,7 @@ pub mod send_with_proposal {
}

#[allow(missing_docs)] // error types document themselves
#[derive(Debug, Error)]
#[derive(Debug, thiserror::Error)]
pub enum CompleteAndBroadcastStoredProposalError {
#[error("No proposal. Call do_propose first.")]
NoStoredProposal,
Expand All @@ -99,7 +98,7 @@ pub mod send_with_proposal {
}

#[allow(missing_docs)] // error types document themselves
#[derive(Debug, Error)]
#[derive(Debug, thiserror::Error)]
pub enum QuickSendError {
#[error("propose send {0:?}")]
ProposeSend(#[from] ProposeSendError),
Expand All @@ -108,7 +107,7 @@ pub mod send_with_proposal {
}

#[allow(missing_docs)] // error types document themselves
#[derive(Debug, Error)]
#[derive(Debug, thiserror::Error)]
pub enum QuickShieldError {
#[error("propose shield {0:?}")]
Propose(#[from] ProposeShieldError),
Expand Down
2 changes: 1 addition & 1 deletion zingolib/src/testutils/chain_generics/with_assertions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ use crate::testutils::{
};
use zingo_status::confirmation_status::ConfirmationStatus;

/// sends to any combo of recipient clients checks that each recipient also recieved the expected balances
/// sends to any combo of recipient clients checks that each recipient also received the expected balances
/// test-only generic
/// NOTICE this function bumps the chain and syncs the client
/// only compatible with zip317
Expand Down
Loading

0 comments on commit bd9a552

Please sign in to comment.