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

Added Tests of Addresses in each pool for existing Test Example Wallets #1421

Merged
merged 13 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
79 changes: 78 additions & 1 deletion zingolib/src/wallet/disk/testing/examples.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
use zcash_client_backend::PoolType;
use zcash_client_backend::ShieldedProtocol;

use super::super::LightWallet;

/// ExampleWalletNetworkCase sorts first by Network, then seed, then last saved version.
Expand Down Expand Up @@ -220,7 +223,7 @@ impl ExampleWalletNetwork {
}
}
/// picks the seed (or ufvk) string associated with an example wallet
pub async fn example_wallet_base(&self) -> String {
pub fn example_wallet_base(&self) -> String {
match self {
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::HMVASMUVWMSSVICHCARBPOCT(
_,
Expand All @@ -245,4 +248,78 @@ impl ExampleWalletNetwork {
)) => "hotel humor crunch crack language awkward lunar term priority critic cushion keep coin sketch soap laugh pretty cement noodle enjoy trip bicycle list return".to_string(),
}
}
/// picks the first receiver associated with an example wallet
pub fn example_wallet_address(&self, pool: PoolType) -> String {
match pool {
PoolType::Transparent => match self {
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::HMVASMUVWMSSVICHCARBPOCT(
_,
)) => "tmFLszfkjgim4zoUMAXpuohnFBAKy99rr2i".to_string(),
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::AAAAAAAAAAAAAAAAAAAAAAAA(
_,
)) => "tmBsTi2xWTjUdEXnuTceL7fecEQKeWaPDJd".to_string(),
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::AADAALACAADAALACAADAALAC(
_,
)) => "tmS9nbexug7uT8x1cMTLP1ABEyKXpMjR5F1".to_string(),
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR(
_,
)) => "tmYd5GP6JxUxTUcz98NLPumEotvaMPaXytz".to_string(),
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::MSKMGDBHOTBPETCJWCSPGOPP(
_,
)) => "tmEVmDAnveCakZkvV4a6FT1TfYApTv937E7".to_string(),
ExampleWalletNetwork::Mainnet(ExampleMainnetWalletSeed::VTFCORFBCBPCTCFUPMEGMWBP(
_,
)) => "t1P8tQtYFLR7TWsqtauc71RGQdqqwfFBbb4".to_string(),
ExampleWalletNetwork::Mainnet(ExampleMainnetWalletSeed::HHCCLALTPCCKCSSLPCNETBLR(
_,
)) => "t1XnsupYhvhSDSFJ4nzZ2kADhLMR22wg35y".to_string(),
},
PoolType::Shielded(ShieldedProtocol::Sapling) => match self {
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::HMVASMUVWMSSVICHCARBPOCT(
_,
)) => "zregtestsapling1fkc26vpg566hgnx33n5uvgye4neuxt4358k68atnx78l5tg2dewdycesmr4m5pn56ffzsa7lyj6".to_string(),
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::AAAAAAAAAAAAAAAAAAAAAAAA(
_,
)) => "zregtestsapling1fmq2ufux3gm0v8qf7x585wj56le4wjfsqsj27zprjghntrerntggg507hxh2ydcdkn7sx8kya7p".to_string(),
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::AADAALACAADAALACAADAALAC(
_,
)) => "zregtestsapling1lhjvuj4s3ghhccnjaefdzuwp3h3mfluz6tm8h0dsq2ym3f77zsv0wrrszpmaqlezm3kt6ajdvlw".to_string(),
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR(
_,
)) => "ztestsapling1etnl5s47cqves0g5hk2dx5824rme4xv4aeauwzp4d6ys3qxykt5sw5rnaqh9syxry8vgxu60uhj".to_string(),
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::MSKMGDBHOTBPETCJWCSPGOPP(
_,
)) => "ztestsapling1h8l5mzlwhmqmd9x7ehquayqckzg6jwa6955f3w9mnkn5p5yfhqy04yz6yjrqfcztxx05xlh3prq".to_string(),
ExampleWalletNetwork::Mainnet(ExampleMainnetWalletSeed::VTFCORFBCBPCTCFUPMEGMWBP(
_,
)) => "zs1kgdrzfe6xuq3tg64vnezp3duyp43u7wcpgduqcpwz9wsnfqm4cecafu9qkmpsjtqxzf27n34z9k".to_string(),
ExampleWalletNetwork::Mainnet(ExampleMainnetWalletSeed::HHCCLALTPCCKCSSLPCNETBLR(
_,
)) => "zs1zgffhwsnh7efu4auv8ql9egteangyferp28rv8r7hmu76u0ee8mthcpflx575emx2zygqcuedzn".to_string(),
},
PoolType::Shielded(ShieldedProtocol::Orchard) => match self {
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::HMVASMUVWMSSVICHCARBPOCT(
_,
)) => "uregtest1wdukkmv5p5n824e8ytnc3m6m77v9vwwl7hcpj0wangf6z23f9x0fnaen625dxgn8cgp67vzw6swuar6uwp3nqywfvvkuqrhdjffxjfg644uthqazrtxhrgwac0a6ujzgwp8y9cwthjeayq8r0q6786yugzzyt9vevxn7peujlw8kp3vf6d8p4fvvpd8qd5p7xt2uagelmtf3vl6w3u8".to_string(),
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::AAAAAAAAAAAAAAAAAAAAAAAA(
_,
)) => "uregtest1zkuzfv5m3yhv2j4fmvq5rjurkxenxyq8r7h4daun2zkznrjaa8ra8asgdm8wwgwjvlwwrxx7347r8w0ee6dqyw4rufw4wg9djwcr6frzkezmdw6dud3wsm99eany5r8wgsctlxquu009nzd6hsme2tcsk0v3sgjvxa70er7h27z5epr67p5q767s2z5gt88paru56mxpm6pwz0cu35m".to_string(),
ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::AADAALACAADAALACAADAALAC(
_,
)) => "uregtest1qtqr46fwkhmdn336uuyvvxyrv0l7trgc0z9clpryx6vtladnpyt4wvq99p59f4rcyuvpmmd0hm4k5vv6j8edj6n8ltk45sdkptlk7rtzlm4uup4laq8ka8vtxzqemj3yhk6hqhuypupzryhv66w65lah9ms03xa8nref7gux2zzhjnfanxnnrnwscmz6szv2ghrurhu3jsqdx25y2yh".to_string(),
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR(
_,
)) => "utest17wwv8nuvdnpjsxtu6ndz6grys5x8wphcwtzmg75wkx607c7cue9qz5kfraqzc7k9dfscmylazj4nkwazjj26s9rhyjxm0dcqm837ykgh2suv0at9eegndh3kvtfjwp3hhhcgk55y9d2ys56zkw8aaamcrv9cy0alj0ndvd0wll4gxhrk9y4yy9q9yg8yssrencl63uznqnkv7mk3w05".to_string(),
ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::MSKMGDBHOTBPETCJWCSPGOPP(
_,
)) => "utest19zd9laj93deq4lkay48xcfyh0tjec786x6yrng38fp6zusgm0c84h3el99fngh8eks4kxv020r2h2njku6pf69anpqmjq5c3suzcjtlyhvpse0aqje09la48xk6a2cnm822s2yhuzfr47pp4dla9rakdk90g0cee070z57d3trqk87wwj4swz6uf6ts6p5z6lep3xyvueuvt7392tww".to_string(),
ExampleWalletNetwork::Mainnet(ExampleMainnetWalletSeed::VTFCORFBCBPCTCFUPMEGMWBP(
_,
)) => "u1n5zgv8c9px4hfmq7cr9f9t0av6q9nj5dwca9w0z9jxegut65gxs2y4qnx7ppng6k2hyt0asyycqrywalzyasxu2302xt4spfqnkh25nevr3h9exc3clh9tfpr5hyhc9dwee50l0cxm7ajun5xs9ycqhlw8rd39jql8z5zlv9hw4q8azcgpv04dez5547geuvyh8pfzezpw52cg2qknm".to_string(),
ExampleWalletNetwork::Mainnet(ExampleMainnetWalletSeed::HHCCLALTPCCKCSSLPCNETBLR(
_,
)) => "u14lrpa0myuh5ax8dtyaj64jddk8m80nk2wgd3sjlu7g3ejwxs3qkfj5hntakjte8ena3qnk40ht0ats5ad0lcwhjtn9hak6733fdf33fhkl7umgqy2vtcfmhmca9pjdlrsz68euuw06swnl9uzzpadmvztd50xen4ruw738t995x7mhdcx3mjv7eh5hntgtvhtv6vgp9l885eqg6xpm8".to_string(),
},
}
}
}
53 changes: 35 additions & 18 deletions zingolib/src/wallet/disk/testing/tests.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
use bip0039::Mnemonic;
use zcash_address::unified::Encoding;
use zcash_client_backend::PoolType;
use zcash_client_backend::ShieldedProtocol;

use crate::get_base_address_macro;
use crate::lightclient::LightClient;

use super::super::LightWallet;
Expand Down Expand Up @@ -32,9 +33,21 @@ use super::examples::ExampleVTFCORFBCBPCTCFUPMEGMWBPVersion;

impl ExampleWalletNetwork {
/// this is enough data to restore wallet from! thus, it is the bronze test for backward compatibility
async fn load_example_wallet_with_seed_verification(&self) -> LightWallet {
async fn load_example_wallet_with_verification(&self) -> LightWallet {
let wallet = self.load_example_wallet().await;
assert_wallet_capability_matches_seed(&wallet, self.example_wallet_base().await).await;
assert_wallet_capability_matches_seed(&wallet, self.example_wallet_base()).await;
for pool in vec![
PoolType::Transparent,
PoolType::Shielded(ShieldedProtocol::Sapling),
PoolType::Shielded(ShieldedProtocol::Orchard),
] {
assert_eq!(
wallet
.get_first_address(pool)
.expect("can find the first address"),
self.example_wallet_address(pool)
);
}
wallet
}
}
Expand All @@ -44,31 +57,31 @@ async fn verify_example_wallet_regtest_aaaaaaaaaaaaaaaaaaaaaaaa_v26() {
Regtest(AAAAAAAAAAAAAAAAAAAAAAAA(
ExampleAAAAAAAAAAAAAAAAAAAAAAAAVersion::V26,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_regtest_aadaalacaadaalacaadaalac_orch_and_sapl() {
Regtest(AADAALACAADAALACAADAALAC(
ExampleAADAALACAADAALACAADAALACVersion::OrchAndSapl,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_regtest_aadaalacaadaalacaadaalac_orch_only() {
Regtest(AADAALACAADAALACAADAALAC(
ExampleAADAALACAADAALACAADAALACVersion::OrchOnly,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_regtest_hmvasmuvwmssvichcarbpoct_v27() {
Regtest(HMVASMUVWMSSVICHCARBPOCT(
ExampleHMVASMUVWMSSVICHCARBPOCTVersion::V27,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
/// unlike other, more basic tests, this test also checks number of addresses and balance
Expand All @@ -77,7 +90,7 @@ async fn verify_example_wallet_testnet_cbbhrwiilgbrababsshsmtpr_v26() {
let wallet = Testnet(CBBHRWIILGBRABABSSHSMTPR(
ExampleCBBHRWIILGBRABABSSHSMTPRVersion::V26,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;

loaded_wallet_assert(
Expand All @@ -95,7 +108,7 @@ async fn verify_example_wallet_testnet_cbbhrwiilgbrababsshsmtpr_v27() {
let wallet = Testnet(CBBHRWIILGBRABABSSHSMTPR(
ExampleCBBHRWIILGBRABABSSHSMTPRVersion::V27,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;

loaded_wallet_assert(
Expand All @@ -111,55 +124,55 @@ async fn verify_example_wallet_testnet_cbbhrwiilgbrababsshsmtpr_v28() {
Testnet(CBBHRWIILGBRABABSSHSMTPR(
ExampleCBBHRWIILGBRABABSSHSMTPRVersion::V28,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_testnet_cbbhrwiilgbrababsshsmtpr_g2f3830058() {
Testnet(CBBHRWIILGBRABABSSHSMTPR(
ExampleCBBHRWIILGBRABABSSHSMTPRVersion::G2f3830058,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_testnet_mskmgdbhotbpetcjwcspgopp_gab72a38b() {
Testnet(MSKMGDBHOTBPETCJWCSPGOPP(
ExampleMSKMGDBHOTBPETCJWCSPGOPPVersion::Gab72a38b,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_testnet_mskmgdbhotbpetcjwcspgopp_g93738061a() {
Testnet(MSKMGDBHOTBPETCJWCSPGOPP(
ExampleMSKMGDBHOTBPETCJWCSPGOPPVersion::G93738061a,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_testnet_mskmgdbhotbpetcjwcspgopp_ga74fed621() {
Testnet(MSKMGDBHOTBPETCJWCSPGOPP(
ExampleMSKMGDBHOTBPETCJWCSPGOPPVersion::Ga74fed621,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_mainnet_vtfcorfbcbpctcfupmegmwbp_v28() {
Mainnet(VTFCORFBCBPCTCFUPMEGMWBP(
ExampleVTFCORFBCBPCTCFUPMEGMWBPVersion::V28,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}
#[tokio::test]
async fn verify_example_wallet_mainnet_hhcclaltpcckcsslpcnetblr_gf0aaf9347() {
Mainnet(HHCCLALTPCCKCSSLPCNETBLR(
ExampleHHCCLALTPCCKCSSLPCNETBLRVersion::Gf0aaf9347,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;
}

Expand Down Expand Up @@ -187,7 +200,11 @@ async fn loaded_wallet_assert(
if expected_balance > 0 {
crate::testutils::lightclient::from_inputs::quick_send(
&client,
vec![(&get_base_address_macro!(client, "sapling"), 11011, None)],
vec![(
&crate::get_base_address_macro!(client, "sapling"),
11011,
None,
)],
)
.await
.unwrap();
Expand Down Expand Up @@ -219,7 +236,7 @@ async fn reload_wallet_from_buffer() {
let mid_wallet = Testnet(CBBHRWIILGBRABABSSHSMTPR(
ExampleCBBHRWIILGBRABABSSHSMTPRVersion::V28,
))
.load_example_wallet_with_seed_verification()
.load_example_wallet_with_verification()
.await;

let mid_client = LightClient::create_from_wallet_async(mid_wallet)
Expand Down
Loading