diff --git a/libtonode-tests/tests/wallet.rs b/libtonode-tests/tests/wallet.rs index ea6a1eab0..3293eb9b4 100644 --- a/libtonode-tests/tests/wallet.rs +++ b/libtonode-tests/tests/wallet.rs @@ -17,6 +17,7 @@ mod load_wallet { use zingolib::testutils::paths::get_cargo_manifest_dir; use zingolib::testutils::scenarios; use zingolib::utils; + use zingolib::wallet::disk::testing::examples; use zingolib::wallet::LightWallet; #[tokio::test] @@ -73,9 +74,11 @@ mod load_wallet { let _cph = regtest_manager.launch(false).unwrap(); println!("loading wallet"); - let wallet = LightWallet::load_example_wallet_legacy( - zingolib::wallet::disk::testing::examples::LegacyWalletCase::OldWalletReorgTestWallet, - ) + let wallet = LightWallet::load_example_wallet(examples::ExampleWalletNetwork::Regtest( + examples::ExampleRegtestWalletSeed::HMVASMUVWMSSVICHCARBPOCT( + examples::ExampleHMVASMUVWMSSVICHCARBPOCTWalletVersion::V27, + ), + )) .await; // let wallet = zingolib::testutils::load_wallet( diff --git a/zingolib/src/wallet/disk.rs b/zingolib/src/wallet/disk.rs index f99a45ab9..68b4a3c0c 100644 --- a/zingolib/src/wallet/disk.rs +++ b/zingolib/src/wallet/disk.rs @@ -32,7 +32,13 @@ use super::{ }; impl LightWallet { - /// TODO: Add Doc Comment Here! + /// Changes in version 27: + /// - The wallet does not have to have a mnemonic. + /// Absence of mnemonic is represented by an empty byte vector in v27. + /// v26 serialized wallet is always loaded with `Some(mnemonic)`. + /// - The wallet capabilities can be restricted from spending to view-only or none. + /// We introduce `Capability` type represent different capability types in v27. + /// v26 serialized wallet is always loaded with `Capability::Spend(sk)`. pub const fn serialized_version() -> u64 { 28 } diff --git a/zingolib/src/wallet/disk/testing/examples.rs b/zingolib/src/wallet/disk/testing/examples.rs index a8b8b2278..0e64e2dd6 100644 --- a/zingolib/src/wallet/disk/testing/examples.rs +++ b/zingolib/src/wallet/disk/testing/examples.rs @@ -1,161 +1,172 @@ use super::super::LightWallet; -/// as opposed to [LegacyWalletCase], which enumerates test cases compiled from the history of zingo wallt tests, this ExampleWalletNetworkCase is meant to fully organize the set of test cases. +/// ExampleWalletNetworkCase sorts first by Network, then seed, then last saved version. +/// It is public so that any consumer can select and load any example wallet. #[non_exhaustive] #[derive(Clone)] -pub enum ExampleWalletNetworkCase { +pub enum ExampleWalletNetwork { /// / - Mainnet(ExampleMainnetWalletSeedCase), + Regtest(ExampleRegtestWalletSeed), /// / - Testnet(ExampleTestnetWalletSeedCase), + Testnet(ExampleTestnetWalletSeed), /// / - Regtest(ExampleRegtestWalletSeedCase), + Mainnet(ExampleMainnetWalletSeed), } /// / #[non_exhaustive] #[derive(Clone)] -pub enum ExampleMainnetWalletSeedCase { - /// this is a mainnet seed - VTFCORFBCBPCTCFUPMEGMWBP(ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersionCase), +pub enum ExampleMainnetWalletSeed { + /// this is a mainnet wallet originally called missing_data_test + VTFCORFBCBPCTCFUPMEGMWBP(ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersion), } /// / #[non_exhaustive] #[derive(Clone)] -pub enum ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersionCase { +pub enum ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersion { /// wallet was last saved in this serialization version V28, } /// / #[non_exhaustive] #[derive(Clone)] -pub enum ExampleTestnetWalletSeedCase { - /// This is a testnet seed. - MSKMGDBHOTBPETCJWCSPGOPP(ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersionCase), +pub enum ExampleTestnetWalletSeed { + /// This is a testnet seed, generated by fluidvanadium at the beginning of owls (this example wallet enumeration) + MSKMGDBHOTBPETCJWCSPGOPP(ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion), + /// this testnet wallet was generated at the beginning of serialization v28 by fluidvanadium + CBBHRWIILGBRABABSSHSMTPR(ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion), } /// / #[non_exhaustive] #[derive(Clone)] -pub enum ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersionCase { +pub enum ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion { /// wallet was last saved by the code in this commit Gab72a38b, } +/// 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" +/// with 3 addresses containing all receivers. +/// including orchard and sapling transactions +#[non_exhaustive] +#[derive(Clone)] +pub enum ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion { + /// wallet was last saved in this serialization version + V26, + /// wallet was last saved in this serialization version + V27, + /// wallet was last saved in this serialization version + V28, +} /// / #[non_exhaustive] #[derive(Clone)] -pub enum ExampleRegtestWalletSeedCase {} - -/// loads test wallets -impl LightWallet { - /// loads any one of the test wallets included in the examples - pub async fn load_example_wallet(case: ExampleWalletNetworkCase) -> Self { - match case { - ExampleWalletNetworkCase::Mainnet( - ExampleMainnetWalletSeedCase::VTFCORFBCBPCTCFUPMEGMWBP( - ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersionCase::V28, - ), - ) => { - LightWallet::unsafe_from_buffer_mainnet(include_bytes!( - "examples/mainnet/vtfcorfbcbpctcfupmegmwbp/v28/zingo-wallet.dat" - )) - .await - } - ExampleWalletNetworkCase::Testnet( - ExampleTestnetWalletSeedCase::MSKMGDBHOTBPETCJWCSPGOPP( - ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersionCase::Gab72a38b, - ), - ) => { - LightWallet::unsafe_from_buffer_testnet(include_bytes!( - "examples/testnet/mskmgdbhotbpetcjwcspgopp/Gab72a38b/zingo-wallet.dat" - )) - .await - } - _ => unimplemented!(), - } - } +pub enum ExampleRegtestWalletSeed { + /// this is a regtest wallet originally called old_wallet_reorg_test_wallet + HMVASMUVWMSSVICHCARBPOCT(ExampleHMVASMUVWMSSVICHCARBPOCTWalletVersion), + /// this is a regtest wallet originally called v26/sap_only + AAAAAAAAAAAAAAAAAAAAAAAA(ExampleAAAAAAAAAAAAAAAAAAAAAAAAWalletVersion), } - -/// i do not know the difference between these wallets but i will find out soon -/// what can these files do? +/// / #[non_exhaustive] #[derive(Clone)] -pub enum LegacyWalletCaseZingoV26 { - /// / - One, - /// / - Two, - /// regtest sap only wallet - RegtestSapOnly, +pub enum ExampleHMVASMUVWMSSVICHCARBPOCTWalletVersion { + /// wallet was last saved in this serialization version + V27, } -/// an enumeration of cases to test +/// / #[non_exhaustive] #[derive(Clone)] -pub enum LegacyWalletCase { - /// at this version, legacy testing began - ZingoV26(LegacyWalletCaseZingoV26), - /// ? - ZingoV28, - /// ... - OldWalletReorgTestWallet, +pub enum ExampleAAAAAAAAAAAAAAAAAAAAAAAAWalletVersion { + /// wallet was last saved in this serialization version + V26, } -/// loads test wallets impl LightWallet { + /// loads test wallets + /// this function can be improved by a macro. even better would be to derive directly from the enum. + // this file is fuc /// loads any one of the test wallets included in the examples - pub async fn load_example_wallet_legacy(case: LegacyWalletCase) -> Self { + pub async fn load_example_wallet(case: ExampleWalletNetwork) -> Self { match case { - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::One) => { + ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::HMVASMUVWMSSVICHCARBPOCT( + ExampleHMVASMUVWMSSVICHCARBPOCTWalletVersion::V27, + )) => { + LightWallet::unsafe_from_buffer_regtest(include_bytes!( + "examples/regtest/hmvasmuvwmssvichcarbpoct/v27/zingo-wallet.dat" + )) + .await + } + ExampleWalletNetwork::Regtest(ExampleRegtestWalletSeed::AAAAAAAAAAAAAAAAAAAAAAAA( + ExampleAAAAAAAAAAAAAAAAAAAAAAAAWalletVersion::V26, + )) => { + LightWallet::unsafe_from_buffer_regtest(include_bytes!( + "examples/regtest/aaaaaaaaaaaaaaaaaaaaaaaa/v26/zingo-wallet.dat" + )) + .await + } + ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::MSKMGDBHOTBPETCJWCSPGOPP( + ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion::Gab72a38b, + )) => { LightWallet::unsafe_from_buffer_testnet(include_bytes!( - "examples/v26-1/zingo-wallet.dat" + "examples/testnet/mskmgdbhotbpetcjwcspgopp/Gab72a38b/zingo-wallet.dat" )) .await } - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::Two) => { + ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR( + ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V26, + )) => { LightWallet::unsafe_from_buffer_testnet(include_bytes!( - "examples/v26-2/zingo-wallet.dat" + "examples/testnet/cbbhrwiilgbrababsshsmtpr/v26/zingo-wallet.dat" )) .await } - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::RegtestSapOnly) => { - LightWallet::unsafe_from_buffer_regtest(include_bytes!( - "examples/v26/202302_release/regtest/sap_only/zingo-wallet.dat" + ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR( + ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V27, + )) => { + LightWallet::unsafe_from_buffer_testnet(include_bytes!( + "examples/testnet/cbbhrwiilgbrababsshsmtpr/v27/zingo-wallet.dat" )) .await } - LegacyWalletCase::ZingoV28 => { + ExampleWalletNetwork::Testnet(ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR( + ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V28, + )) => { LightWallet::unsafe_from_buffer_testnet(include_bytes!( - "examples/zingo-wallet-v28.dat" + "examples/testnet/cbbhrwiilgbrababsshsmtpr/v28/zingo-wallet.dat" )) .await } - LegacyWalletCase::OldWalletReorgTestWallet => { - LightWallet::unsafe_from_buffer_regtest(include_bytes!( - "examples/old_wallet_reorg_test_wallet/zingo-wallet.dat" + ExampleWalletNetwork::Mainnet(ExampleMainnetWalletSeed::VTFCORFBCBPCTCFUPMEGMWBP( + ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersion::V28, + )) => { + LightWallet::unsafe_from_buffer_mainnet(include_bytes!( + "examples/mainnet/vtfcorfbcbpctcfupmegmwbp/v28/zingo-wallet.dat" )) .await } } } +} - /// each wallet file has a saved balance - pub fn example_expected_balance(case: LegacyWalletCase) -> u64 { - match case { - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::One) => 0, - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::Two) => 10177826, - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::RegtestSapOnly) => todo!(), - LegacyWalletCase::ZingoV28 => 10342837, - LegacyWalletCase::OldWalletReorgTestWallet => todo!(), - } - } +// /// loads test wallets +// impl LightWallet { +// /// each wallet file has a saved balance +// pub fn example_expected_balance(case: LegacyWalletCase) -> u64 { +// match case { +// // LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::One) => 0, +// // LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::Two) => 10177826, +// LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::RegtestSapOnly) => todo!(), +// LegacyWalletCase::ZingoV28 => 10342837, +// } +// } - /// each wallet file has a saved balance - pub fn example_expected_num_addresses(case: LegacyWalletCase) -> usize { - match case { - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::One) => 3, - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::Two) => 1, - LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::RegtestSapOnly) => todo!(), - LegacyWalletCase::ZingoV28 => 3, - LegacyWalletCase::OldWalletReorgTestWallet => todo!(), - } - } -} +// /// each wallet file has a saved balance +// pub fn example_expected_num_addresses(case: LegacyWalletCase) -> usize { +// match case { +// // LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::One) => 3, +// // LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::Two) => 1, +// LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::RegtestSapOnly) => todo!(), +// LegacyWalletCase::ZingoV28 => 3, +// } +// } +// } diff --git a/zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/sap_only/zingo-wallet.dat b/zingolib/src/wallet/disk/testing/examples/regtest/aaaaaaaaaaaaaaaaaaaaaaaa/v26/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/sap_only/zingo-wallet.dat rename to zingolib/src/wallet/disk/testing/examples/regtest/aaaaaaaaaaaaaaaaaaaaaaaa/v26/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/orch_and_sapl/zingo-wallet.dat b/zingolib/src/wallet/disk/testing/examples/regtest/aadaalacaadaalacaadaalac/orch_and_sapl/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/orch_and_sapl/zingo-wallet.dat rename to zingolib/src/wallet/disk/testing/examples/regtest/aadaalacaadaalacaadaalac/orch_and_sapl/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/orch_only/zingo-wallet.dat b/zingolib/src/wallet/disk/testing/examples/regtest/aadaalacaadaalacaadaalac/orch_only/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/orch_only/zingo-wallet.dat rename to zingolib/src/wallet/disk/testing/examples/regtest/aadaalacaadaalacaadaalac/orch_only/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/taddr_only/zingo-wallet.dat b/zingolib/src/wallet/disk/testing/examples/regtest/hmvasmuvwmssvichcarbpoct/v26/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/v26/202302_release/regtest/taddr_only/zingo-wallet.dat rename to zingolib/src/wallet/disk/testing/examples/regtest/hmvasmuvwmssvichcarbpoct/v26/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/examples/old_wallet_reorg_test_wallet/zingo-wallet.dat b/zingolib/src/wallet/disk/testing/examples/regtest/hmvasmuvwmssvichcarbpoct/v27/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/old_wallet_reorg_test_wallet/zingo-wallet.dat rename to zingolib/src/wallet/disk/testing/examples/regtest/hmvasmuvwmssvichcarbpoct/v27/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/examples/v26-1/zingo-wallet.dat b/zingolib/src/wallet/disk/testing/examples/testnet/cbbhrwiilgbrababsshsmtpr/v26/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/v26-1/zingo-wallet.dat rename to zingolib/src/wallet/disk/testing/examples/testnet/cbbhrwiilgbrababsshsmtpr/v26/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/examples/v26-2/zingo-wallet.dat b/zingolib/src/wallet/disk/testing/examples/testnet/cbbhrwiilgbrababsshsmtpr/v27/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/v26-2/zingo-wallet.dat rename to zingolib/src/wallet/disk/testing/examples/testnet/cbbhrwiilgbrababsshsmtpr/v27/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/examples/zingo-wallet-v28.dat b/zingolib/src/wallet/disk/testing/examples/testnet/cbbhrwiilgbrababsshsmtpr/v28/zingo-wallet.dat similarity index 100% rename from zingolib/src/wallet/disk/testing/examples/zingo-wallet-v28.dat rename to zingolib/src/wallet/disk/testing/examples/testnet/cbbhrwiilgbrababsshsmtpr/v28/zingo-wallet.dat diff --git a/zingolib/src/wallet/disk/testing/tests.rs b/zingolib/src/wallet/disk/testing/tests.rs index e5ea3a644..15e90d65e 100644 --- a/zingolib/src/wallet/disk/testing/tests.rs +++ b/zingolib/src/wallet/disk/testing/tests.rs @@ -6,29 +6,81 @@ use crate::lightclient::LightClient; use super::super::LightWallet; -use super::examples::ExampleMainnetWalletSeedCase; -use super::examples::LegacyWalletCase; -use super::examples::LegacyWalletCaseZingoV26; +use super::examples::ExampleWalletNetwork::Mainnet; +use super::examples::ExampleWalletNetwork::Regtest; +use super::examples::ExampleWalletNetwork::Testnet; + +use super::examples::ExampleMainnetWalletSeed::VTFCORFBCBPCTCFUPMEGMWBP; +use super::examples::ExampleRegtestWalletSeed::AAAAAAAAAAAAAAAAAAAAAAAA; +use super::examples::ExampleRegtestWalletSeed::HMVASMUVWMSSVICHCARBPOCT; +use super::examples::ExampleTestnetWalletSeed::CBBHRWIILGBRABABSSHSMTPR; +use super::examples::ExampleTestnetWalletSeed::MSKMGDBHOTBPETCJWCSPGOPP; + +use super::examples::ExampleAAAAAAAAAAAAAAAAAAAAAAAAWalletVersion; +use super::examples::ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion; +use super::examples::ExampleHMVASMUVWMSSVICHCARBPOCTWalletVersion; +use super::examples::ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion; +use super::examples::ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersion; + +// moving toward completeness: each of these tests should assert everything known about the LightWallet without network. #[tokio::test] -async fn verify_example_wallet_mainnet_vtfcorfbcbpctcfupmegmwbp_v28() { - let _wallet = - LightWallet::load_example_wallet(super::examples::ExampleWalletNetworkCase::Mainnet( - ExampleMainnetWalletSeedCase::VTFCORFBCBPCTCFUPMEGMWBP( - super::examples::ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersionCase::V28, - ), - )) - .await; +async fn verify_example_wallet_regtest_hmvasmuvwmssvichcarbpoct_v27() { + let _wallet = LightWallet::load_example_wallet(Regtest(HMVASMUVWMSSVICHCARBPOCT( + ExampleHMVASMUVWMSSVICHCARBPOCTWalletVersion::V27, + ))) + .await; } +#[ignore = "test fails because ZFZ panics in regtest"] #[tokio::test] -async fn verify_example_wallet_mainnet_mskmgdbhotbpetcjwcspgopp_gab72a38b() { - let _wallet = - LightWallet::load_example_wallet(super::examples::ExampleWalletNetworkCase::Testnet( - super::examples::ExampleTestnetWalletSeedCase::MSKMGDBHOTBPETCJWCSPGOPP( - super::examples::ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersionCase::Gab72a38b, - ), - )) - .await; +async fn verify_example_wallet_regtest_aaaaaaaaaaaaaaaaaaaaaaaa_v26() { + let wallet = LightWallet::load_example_wallet(Regtest(AAAAAAAAAAAAAAAAAAAAAAAA( + ExampleAAAAAAAAAAAAAAAAAAAAAAAAWalletVersion::V26, + ))) + .await; + + loaded_wallet_assert(wallet, 10342837, 3).await; +} + +#[tokio::test] +async fn verify_example_wallet_testnet_mskmgdbhotbpetcjwcspgopp_gab72a38b() { + let _wallet = LightWallet::load_example_wallet(Testnet(MSKMGDBHOTBPETCJWCSPGOPP( + ExampleMSKMGDBHOTBPETCJWCSPGOPPWalletVersion::Gab72a38b, + ))) + .await; +} +#[tokio::test] +async fn verify_example_wallet_testnet_cbbhrwiilgbrababsshsmtpr_v26() { + let wallet = LightWallet::load_example_wallet(Testnet(CBBHRWIILGBRABABSSHSMTPR( + ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V26, + ))) + .await; + + loaded_wallet_assert(wallet, 0, 3).await; +} +#[ignore = "test proves note has no index bug is a breaker"] +#[tokio::test] +async fn verify_example_wallet_testnet_cbbhrwiilgbrababsshsmtpr_v27() { + let wallet = LightWallet::load_example_wallet(Testnet(CBBHRWIILGBRABABSSHSMTPR( + ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V27, + ))) + .await; + + loaded_wallet_assert(wallet, 10177826, 1).await; +} +#[tokio::test] +async fn verify_example_wallet_testnet_cbbhrwiilgbrababsshsmtpr_v28() { + let _wallet = LightWallet::load_example_wallet(Testnet(CBBHRWIILGBRABABSSHSMTPR( + ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V28, + ))) + .await; +} +#[tokio::test] +async fn verify_example_wallet_mainnet_vtfcorfbcbpctcfupmegmwbp_v28() { + let _wallet = LightWallet::load_example_wallet(Mainnet(VTFCORFBCBPCTCFUPMEGMWBP( + ExampleVTFCORFBCBPCTCFUPMEGMWBPWalletVersion::V28, + ))) + .await; } async fn loaded_wallet_assert( @@ -119,87 +171,6 @@ async fn loaded_wallet_assert( } } -#[tokio::test] -async fn load_and_parse_different_wallet_versions() { - let _loaded_wallet = LightWallet::load_example_wallet_legacy(LegacyWalletCase::ZingoV26( - LegacyWalletCaseZingoV26::RegtestSapOnly, - )) - .await; -} - -#[tokio::test] -async fn load_wallet_from_v26_dat_file() { - // We test that the LightWallet can be read from v26 .dat file - // Changes in version 27: - // - The wallet does not have to have a mnemonic. - // Absence of mnemonic is represented by an empty byte vector in v27. - // v26 serialized wallet is always loaded with `Some(mnemonic)`. - // - The wallet capabilities can be restricted from spending to view-only or none. - // We introduce `Capability` type represent different capability types in v27. - // v26 serialized wallet is always loaded with `Capability::Spend(sk)`. - - // 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" - // with 3 addresses containing all receivers. - // including orchard and sapling transactions - let case = LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::One); - - let wallet = LightWallet::load_example_wallet_legacy(case.clone()).await; - - loaded_wallet_assert( - wallet, - LightWallet::example_expected_balance(case.clone()), - LightWallet::example_expected_num_addresses(case), - ) - .await; -} - -#[ignore = "test proves note has no index bug is a breaker"] -#[tokio::test] -async fn load_wallet_from_v26_2_dat_file() { - // We test that the LightWallet can be read from v26 .dat file - // Changes in version 27: - // - The wallet does not have to have a mnemonic. - // Absence of mnemonic is represented by an empty byte vector in v27. - // v26 serialized wallet is always loaded with `Some(mnemonic)`. - // - The wallet capabilities can be restricted from spending to view-only or none. - // We introduce `Capability` type represent different capability types in v27. - // v26 serialized wallet is always loaded with `Capability::Spend(sk)`. - - // 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" - // with 3 addresses containing all receivers. - // including orchard and sapling transactions - let case = LegacyWalletCase::ZingoV26(LegacyWalletCaseZingoV26::Two); - - let wallet = LightWallet::load_example_wallet_legacy(case.clone()).await; - - loaded_wallet_assert( - wallet, - LightWallet::example_expected_balance(case.clone()), - LightWallet::example_expected_num_addresses(case), - ) - .await; -} - -#[ignore = "test fails because ZFZ panics in regtest"] -#[tokio::test] -async fn load_wallet_from_v28_dat_file() { - // We test that the LightWallet can be read from v28 .dat file - // --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" - // with 3 addresses containing all receivers. - let case = LegacyWalletCase::ZingoV28; - - let wallet = LightWallet::load_example_wallet_legacy(case.clone()).await; - - loaded_wallet_assert( - wallet, - LightWallet::example_expected_balance(case.clone()), - LightWallet::example_expected_num_addresses(case), - ) - .await; -} - #[tokio::test] async fn reload_wallet_from_buffer() { use zcash_primitives::consensus::Parameters; @@ -210,13 +181,10 @@ async fn reload_wallet_from_buffer() { use crate::wallet::WalletBase; use crate::wallet::WalletCapability; - // We test that the LightWallet can be read from v28 .dat file - // 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" - // --birthday 0 - // --nosync - // with 3 addresses containing all receivers. - let mid_wallet = LightWallet::load_example_wallet_legacy(LegacyWalletCase::ZingoV28).await; + let mid_wallet = LightWallet::load_example_wallet(Testnet(CBBHRWIILGBRABABSSHSMTPR( + ExampleCBBHRWIILGBRABABSSHSMTPRWalletVersion::V28, + ))) + .await; let mid_client = LightClient::create_from_wallet_async(mid_wallet) .await