Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Owls a.1 #1345

Merged
merged 26 commits into from
Aug 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
2575ff5
re-identify
fluidvanadium Aug 27, 2024
3116a35
Merge branch 'owls-0.3' into owls-1.0
fluidvanadium Aug 27, 2024
bfafb2c
added long ignored testnet test
fluidvanadium Aug 27, 2024
9bb585d
parameteritized assertion function
fluidvanadium Aug 27, 2024
2f533c4
decomposed assertions and commented dead tests
fluidvanadium Aug 27, 2024
f200bec
added dbg! to create_send_to_self_with_zfz_active
fluidvanadium Aug 16, 2024
03aca37
combine boxes
fluidvanadium Aug 27, 2024
273c052
one function is sufficient for filtering
fluidvanadium Aug 27, 2024
198b0ac
remove unused test clause
fluidvanadium Aug 27, 2024
8da5221
cargo fmt
fluidvanadium Aug 27, 2024
56ac12f
straightup use the phrase transparent_balance
fluidvanadium Aug 27, 2024
5340998
added ZENNIES_FOR_ZINGO_TESTNET_ADDRESS
fluidvanadium Aug 27, 2024
1019195
loaded mskmgd to lasct commit
fluidvanadium Aug 28, 2024
67183a7
basic tests for mskmgd
fluidvanadium Aug 28, 2024
3cfc038
simplified parameters
fluidvanadium Aug 27, 2024
dd7f489
added and edited comments
fluidvanadium Aug 20, 2024
5ea0d71
delete unused duplicate Arc<RwLock<Arc<RwLock<Uri>>>>
fluidvanadium Aug 20, 2024
4b5f71c
simplified lightwalletd_uri lookup
fluidvanadium Aug 21, 2024
e3f1d6f
cargo clippy --fix --tests --all-features
fluidvanadium Aug 21, 2024
b05db6f
add LightWallet.get_seed_string()
fluidvanadium Aug 28, 2024
93971fe
added seed phrase forward assertion
fluidvanadium Aug 28, 2024
13ced1e
added the example seed phrase to verify_exapmle_wallet_testnet_mskmgd
fluidvanadium Aug 28, 2024
6546df6
helperized an assertion
fluidvanadium Aug 28, 2024
5849295
moved helpers
fluidvanadium Aug 28, 2024
45e5312
added balance assertions to mskmgd
fluidvanadium Aug 28, 2024
2b2ec5a
Merge remote-tracking branch 'labs/dev' into owls-a.1
fluidvanadium Aug 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions zingolib/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,12 @@ use zcash_primitives::consensus::{
/// TODO: Add Doc Comment Here!
pub const DEVELOPER_DONATION_ADDRESS: &str = "u1w47nzy4z5g9zvm4h2s4ztpl8vrdmlclqz5sz02742zs5j3tz232u4safvv9kplg7g06wpk5fx0k0rx3r9gg4qk6nkg4c0ey57l0dyxtatqf8403xat7vyge7mmen7zwjcgvryg22khtg3327s6mqqkxnpwlnrt27kxhwg37qys2kpn2d2jl2zkk44l7j7hq9az82594u3qaescr3c9v";
/// TODO: Add Doc Comment Here!
pub const ZENNIES_FOR_ZINGO_DONATION_ADDRESS: &str = "u1p32nu0pgev5cr0u6t4ja9lcn29kaw37xch8nyglwvp7grl07f72c46hxvw0u3q58ks43ntg324fmulc2xqf4xl3pv42s232m25vaukp05s6av9z76s3evsstax4u6f5g7tql5yqwuks9t4ef6vdayfmrsymenqtshgxzj59hdydzygesqa7pdpw463hu7afqf4an29m69kfasdwr494";
/// TODO: Add Doc Comment Here!
pub const ZENNIES_FOR_ZINGO_REGTEST_ADDRESS: &str = "uregtest14emvr2anyul683p43d0ck55c04r65ld6f0shetcn77z8j7m64hm4ku3wguf60s75f0g3s7r7g89z22f3ff5tsfgr45efj4pe2gyg5krqp5vvl3afu0280zp9ru2379zat5y6nkqkwjxsvpq5900kchcgzaw8v8z3ggt5yymnuj9hymtv3p533fcrk2wnj48g5vg42vle08c2xtanq0e";
/// TODO: Add Doc Comment Here!
pub const ZENNIES_FOR_ZINGO_TESTNET_ADDRESS: &str = "utest19zd9laj93deq4lkay48xcfyh0tjec786x6yrng38fp6zusgm0c84h3el99fngh8eks4kxv020r2h2njku6pf69anpqmjq5c3suzcjtlyhvpse0aqje09la48xk6a2cnm822s2yhuzfr47pp4dla9rakdk90g0cee070z57d3trqk87wwj4swz6uf6ts6p5z6lep3xyvueuvt7392tww";
/// TODO: Add Doc Comment Here!
pub const ZENNIES_FOR_ZINGO_DONATION_ADDRESS: &str = "u1p32nu0pgev5cr0u6t4ja9lcn29kaw37xch8nyglwvp7grl07f72c46hxvw0u3q58ks43ntg324fmulc2xqf4xl3pv42s232m25vaukp05s6av9z76s3evsstax4u6f5g7tql5yqwuks9t4ef6vdayfmrsymenqtshgxzj59hdydzygesqa7pdpw463hu7afqf4an29m69kfasdwr494";
/// TODO: Add Doc Comment Here!
pub const ZENNIES_FOR_ZINGO_AMOUNT: u64 = 1_000_000;
/// TODO: Add Doc Comment Here!
pub const DEFAULT_LIGHTWALLETD_SERVER: &str = "https://zec.rocks:443";
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 @@ -98,7 +98,7 @@ impl LightClient {
spendable_orchard_balance,
unverified_orchard_balance,

transparent_balance: self.wallet.tbalance().await,
transparent_balance: self.wallet.get_transparent_balance().await,
}
}

Expand Down
25 changes: 24 additions & 1 deletion zingolib/src/lightclient/send.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,9 +247,19 @@ pub mod send_with_proposal {

#[cfg(all(test, feature = "testvectors"))]
mod tests {
use crate::{
lightclient::LightClient,
wallet::{
disk::testing::examples::{
ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion, ExampleTestnetWalletSeed,
ExampleWalletNetwork,
},
LightWallet,
},
};

#[tokio::test]
async fn complete_and_broadcast() {
async fn complete_and_broadcast_unconnected_error() {
use crate::{
config::ZingoConfigBuilder,
lightclient::{send::send_with_proposal::CompleteAndBroadcastError, LightClient},
Expand All @@ -275,5 +285,18 @@ pub mod send_with_proposal {
.to_string(),
);
}

#[ignore]
zancas marked this conversation as resolved.
Show resolved Hide resolved
#[tokio::test]
async fn sync_testnet() {
let wallet = LightWallet::load_example_wallet(ExampleWalletNetwork::Testnet(
ExampleTestnetWalletSeed::MSKMGDBHOTBPETCJWCSPGOPP(
ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion::Gab72a38b,
),
))
.await;
let lc = LightClient::create_from_wallet_async(wallet).await.unwrap();
let _ = lc.do_sync(true).await;
}
}
}
8 changes: 5 additions & 3 deletions zingolib/src/wallet/describe.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,11 @@ impl LightWallet {
}
// Core shielded_balance function, other public methods dispatch specific sets of filters to this
// method for processing.
// This methods ensures that None is returned in the case of a missing view capability
/// Returns the sum of unspent notes recorded by the wallet
/// with optional filtering.
/// This method ensures that None is returned in the case of a missing view capability.
#[allow(clippy::type_complexity)]
async fn get_filtered_balance<D>(
pub async fn get_filtered_balance<D>(
&self,
filter_function: Box<dyn Fn(&&D::WalletNote, &TransactionRecord) -> bool + '_>,
) -> Option<u64>
Expand Down Expand Up @@ -102,7 +104,7 @@ impl LightWallet {
}
}
/// Sums the transparent balance (unspent)
pub async fn tbalance(&self) -> Option<u64> {
pub async fn get_transparent_balance(&self) -> Option<u64> {
if self.wallet_capability().transparent.can_view() {
Some(
self.get_utxos()
Expand Down
73 changes: 73 additions & 0 deletions zingolib/src/wallet/disk/testing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,3 +51,76 @@ pub mod examples;
/// tests
#[cfg(test)]
pub mod tests;

// test helper functions

/// asserts that a fresh capability generated with the seed matches the extant capability, which also can export the seed
pub async fn assert_wallet_capability_matches_seed(
wallet: &LightWallet,
expected_seed_phrase: String,
) {
let actual_seed_phrase = wallet.get_seed_phrase().await.unwrap();
assert_eq!(expected_seed_phrase, actual_seed_phrase);

let expected_mnemonic = (
zcash_primitives::zip339::Mnemonic::from_phrase(expected_seed_phrase).unwrap(),
0,
);
assert_eq!(wallet.mnemonic(), Some(&expected_mnemonic));

let expected_wc = crate::wallet::keys::unified::WalletCapability::new_from_phrase(
&wallet.transaction_context.config,
&expected_mnemonic.0,
expected_mnemonic.1,
)
.unwrap();
let wc = wallet.wallet_capability();

// We don't want the WalletCapability to impl. `Eq` (because it stores secret keys)
// so we have to compare each component instead

// Compare Orchard
let crate::wallet::keys::unified::Capability::Spend(orchard_sk) = &wc.orchard else {
panic!("Expected Orchard Spending Key");
};
assert_eq!(
orchard_sk.to_bytes(),
orchard::keys::SpendingKey::try_from(&expected_wc)
.unwrap()
.to_bytes()
);

// Compare Sapling
let crate::wallet::keys::unified::Capability::Spend(sapling_sk) = &wc.sapling else {
panic!("Expected Sapling Spending Key");
};
assert_eq!(
sapling_sk,
&zcash_client_backend::keys::sapling::ExtendedSpendingKey::try_from(&expected_wc).unwrap()
);

// Compare transparent
let crate::wallet::keys::unified::Capability::Spend(transparent_sk) = &wc.transparent else {
panic!("Expected transparent extended private key");
};
assert_eq!(
transparent_sk,
&crate::wallet::keys::extended_transparent::ExtendedPrivKey::try_from(&expected_wc)
.unwrap()
);
}

/// basically does what it says on the tin
pub async fn assert_wallet_capability_contains_n_triple_pool_receivers(
wallet: &LightWallet,
expected_num_addresses: usize,
) {
let wc = wallet.wallet_capability();

assert_eq!(wc.addresses().len(), expected_num_addresses);
for addr in wc.addresses().iter() {
assert!(addr.orchard().is_some());
assert!(addr.sapling().is_some());
assert!(addr.transparent().is_some());
}
}
10 changes: 10 additions & 0 deletions zingolib/src/wallet/disk/testing/examples.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ pub enum ExampleTestnetWalletSeed {
pub enum ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion {
/// wallet was last saved by the code in this commit
Gab72a38b,
/// this wallet was synced in this version. does it have a bunch of taz scattered around different addresses?
G93738061a,
}
/// A testnet wallet initiated with
/// --seed "chimney better bulb horror rebuild whisper improve intact letter giraffe brave rib appear bulk aim burst snap salt hill sad merge tennis phrase raise"
Expand Down Expand Up @@ -112,6 +114,14 @@ impl LightWallet {
))
.await
}
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::MSKMGDBHOTBPETCJWCSPGOPP(
ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion::G93738061a,
)) => {
LightWallet::unsafe_from_buffer_testnet(include_bytes!(
"examples/testnet/mskmgdbhotbpetcjwcspgopp/G93738061a/zingo-wallet.dat"
))
.await
}
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR(
ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V26,
)) => {
Expand Down
Binary file not shown.
Loading
Loading