diff --git a/crates/core/src/masp.rs b/crates/core/src/masp.rs index 29a75dfdb9..d7765b4060 100644 --- a/crates/core/src/masp.rs +++ b/crates/core/src/masp.rs @@ -827,11 +827,10 @@ mod test { .address(); assert_eq!(addr.unwrap(), address::testing::established_address_1()); - let addr = - TransferSource::ExtendedSpendingKey( - masp_primitives::zip32::ExtendedSpendingKey::master(&[0_u8]).into(), - ) - .address(); + let addr = TransferSource::ExtendedSpendingKey( + masp_primitives::zip32::ExtendedSpendingKey::master(&[0_u8]).into(), + ) + .address(); assert!(addr.is_none()); } @@ -845,11 +844,10 @@ mod test { TAddrData::Addr(address::testing::established_address_1()) ); - let addr = - TransferSource::ExtendedSpendingKey( - masp_primitives::zip32::ExtendedSpendingKey::master(&[0_u8]).into(), - ) - .address(); + let addr = TransferSource::ExtendedSpendingKey( + masp_primitives::zip32::ExtendedSpendingKey::master(&[0_u8]).into(), + ) + .address(); assert!(addr.is_none()); } diff --git a/crates/node/src/shell/testing/client.rs b/crates/node/src/shell/testing/client.rs index 21ff520bff..8bf1236b4a 100644 --- a/crates/node/src/shell/testing/client.rs +++ b/crates/node/src/shell/testing/client.rs @@ -47,11 +47,15 @@ pub fn run( NamadaClient::WithoutContext(Box::new((sub_cmd, global))) } }; - rt.block_on(CliApi::handle_client_command( + let result = rt.block_on(CliApi::handle_client_command( Some(node.clone()), cmd, TestingIo, - )) + )); + if let Err(err) = &result { + TestingIo.eprintln(format!("{}", err)); + } + result } Bin::Wallet => { args.insert(0, "wallet"); diff --git a/crates/sdk/src/signing.rs b/crates/sdk/src/signing.rs index c2818209c4..ff8f8fddfa 100644 --- a/crates/sdk/src/signing.rs +++ b/crates/sdk/src/signing.rs @@ -287,8 +287,9 @@ where // Then try to sign the raw header using the hardware wallet for pubkey in &signing_data.public_keys { - if !used_pubkeys.contains(pubkey) && - (*pubkey != signing_data.fee_payer || args.wrapper_signature.is_some()) + if !used_pubkeys.contains(pubkey) + && (*pubkey != signing_data.fee_payer + || args.wrapper_signature.is_some()) { if let Ok(ntx) = sign( tx.clone(), @@ -329,7 +330,7 @@ where Signable::FeeRawHeader, user_data, ) - .await?; + .await?; if signing_data.public_keys.contains(&signing_data.fee_payer) { used_pubkeys.insert(signing_data.fee_payer.clone()); } diff --git a/crates/shielded_token/src/masp/shielded_wallet.rs b/crates/shielded_token/src/masp/shielded_wallet.rs index 2720af3abb..bc6dbc9ce8 100644 --- a/crates/shielded_token/src/masp/shielded_wallet.rs +++ b/crates/shielded_token/src/masp/shielded_wallet.rs @@ -48,8 +48,8 @@ use rand_core::{OsRng, SeedableRng}; use crate::masp::utils::MaspClient; use crate::masp::{ - cloned_pair, ContextSyncStatus, Conversions, MaspAmount, - MaspDataLog, MaspFeeData, MaspSourceTransferData, MaspTargetTransferData, + cloned_pair, ContextSyncStatus, Conversions, MaspAmount, MaspDataLog, + MaspFeeData, MaspSourceTransferData, MaspTargetTransferData, MaspTransferData, MaspTxReorderedData, NoteIndex, ShieldedSyncConfig, ShieldedTransfer, ShieldedUtils, SpentNotesTracker, TransferErr, WalletMap, WitnessMap, NETWORK, @@ -1472,9 +1472,7 @@ pub trait ShieldedApi: // If we are sending to a shielded address, we need the outgoing // viewing key in the following computations. let ovk_opt = source.clone().and_then(|source| { - source - .spending_key() - .map(|x| x.to_viewing_key().fvk.ovk) + source.spending_key().map(|x| x.to_viewing_key().fvk.ovk) }); // Make transaction output tied to the current token, // denomination, and epoch. diff --git a/crates/tests/src/e2e/helpers.rs b/crates/tests/src/e2e/helpers.rs index 530e392484..d58ab83684 100644 --- a/crates/tests/src/e2e/helpers.rs +++ b/crates/tests/src/e2e/helpers.rs @@ -31,8 +31,8 @@ use namada_sdk::wallet::Wallet; use toml::Value; use super::setup::{ - self, ensure_hot_key, run_gaia_cmd, sleep, NamadaBgCmd, NamadaCmd, Test, - ENV_VAR_DEBUG, ENV_VAR_USE_PREBUILT_BINARIES, + self, run_gaia_cmd, sleep, NamadaBgCmd, NamadaCmd, Test, ENV_VAR_DEBUG, + ENV_VAR_USE_PREBUILT_BINARIES, }; use crate::e2e::setup::{constants, Bin, Who, APPS_PACKAGE}; use crate::strings::{LEDGER_STARTED, TX_APPLIED_SUCCESS}; @@ -130,7 +130,10 @@ pub fn find_address(test: &Test, alias: impl AsRef) -> Result
{ } /// Find the address of an account by its alias from the wallet -pub fn find_payment_address(test: &Test, alias: impl AsRef) -> Result { +pub fn find_payment_address( + test: &Test, + alias: impl AsRef, +) -> Result { let mut find = run!( test, Bin::Wallet, @@ -587,9 +590,7 @@ fn make_hermes_chain_config(test: &Test) -> Value { chain.insert("account_prefix".to_owned(), Value::String("".to_owned())); chain.insert( "key_name".to_owned(), - Value::String( - ensure_hot_key(setup::constants::CHRISTEL_KEY).to_owned(), - ), + Value::String(constants::FRANK_KEY.to_owned()), ); chain.insert("store_prefix".to_owned(), Value::String("ibc".to_owned())); let mut table = toml::map::Map::new(); diff --git a/crates/tests/src/e2e/ibc_tests.rs b/crates/tests/src/e2e/ibc_tests.rs index b0e5b79ada..99439d60e8 100644 --- a/crates/tests/src/e2e/ibc_tests.rs +++ b/crates/tests/src/e2e/ibc_tests.rs @@ -212,7 +212,8 @@ fn ibc_transfers() -> Result<()> { &port_id_namada, &channel_id_namada, )?; - let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); + let masp_receiver = + find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); transfer_from_gaia( &test_gaia, GAIA_USER, @@ -273,7 +274,8 @@ fn ibc_transfers() -> Result<()> { &port_id_namada, &channel_id_namada, )?; - let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); + let masp_receiver = + find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); transfer_from_gaia( &test_gaia, GAIA_USER, @@ -405,7 +407,8 @@ fn ibc_transfers() -> Result<()> { check_gaia_balance(&test_gaia, GAIA_USER, GAIA_COIN, 810)?; // Missing memo - let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); + let masp_receiver = + find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); transfer_from_gaia( &test_gaia, GAIA_USER, @@ -432,7 +435,8 @@ fn ibc_transfers() -> Result<()> { &port_id_namada, &channel_id_namada, )?; - let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); + let masp_receiver = + find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); transfer_from_gaia( &test_gaia, GAIA_USER, @@ -711,7 +715,8 @@ fn ibc_token_inflation() -> Result<()> { &port_id_namada, &channel_id_namada, )?; - let masp_receiver = find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); + let masp_receiver = + find_payment_address(&test, AA_PAYMENT_ADDRESS)?.to_string(); transfer_from_gaia( &test_gaia, GAIA_USER, diff --git a/crates/tests/src/e2e/ledger_tests.rs b/crates/tests/src/e2e/ledger_tests.rs index 973dfb9f33..cd7b0aef4b 100644 --- a/crates/tests/src/e2e/ledger_tests.rs +++ b/crates/tests/src/e2e/ledger_tests.rs @@ -27,8 +27,8 @@ use namada_apps_lib::config::genesis::templates::TokenBalances; use namada_apps_lib::config::utils::convert_tm_addr_to_socket_addr; use namada_apps_lib::config::{self, ethereum_bridge}; use namada_apps_lib::tendermint_config::net::Address as TendermintAddress; -use namada_apps_lib::wallet::{self, Alias}; use namada_apps_lib::wallet::defaults::is_use_device; +use namada_apps_lib::wallet::{self, Alias}; use namada_core::chain::ChainId; use namada_core::token::NATIVE_MAX_DECIMAL_PLACES; use namada_sdk::address::Address; diff --git a/crates/tests/src/e2e/setup.rs b/crates/tests/src/e2e/setup.rs index 586eedb4e1..497b254598 100644 --- a/crates/tests/src/e2e/setup.rs +++ b/crates/tests/src/e2e/setup.rs @@ -86,18 +86,6 @@ pub fn apply_use_device(mut tx_args: Vec<&str>) -> Vec<&str> { tx_args } -/// Replace the given key with a key that is stored unencrypted in the wallet. -/// This is useful for IBC tests where a keypair needs to be added to the Hermes -/// keyring or where IBC messages unsupported by the hardware wallet need to be -/// signed -pub fn ensure_hot_key(key: &str) -> &str { - if is_use_device() { - constants::FRANK_KEY - } else { - key - } -} - /// Default functions for offsetting ports when /// adding multiple validators to a network pub fn default_port_offset(ix: u8) -> u16 { diff --git a/crates/tests/src/integration/helpers.rs b/crates/tests/src/integration/helpers.rs index f142362583..c2447a3a50 100644 --- a/crates/tests/src/integration/helpers.rs +++ b/crates/tests/src/integration/helpers.rs @@ -7,6 +7,7 @@ use namada_node::shell::testing::client::run; use namada_node::shell::testing::node::MockNode; use namada_node::shell::testing::utils::{Bin, CapturedOutput}; use namada_sdk::key::common; + use crate::e2e::setup::constants::{FRANK, FRANK_KEY}; use crate::strings::TX_APPLIED_SUCCESS; @@ -112,8 +113,7 @@ pub fn make_temp_account( "--node", ledger_address, ]; - let captured = - CapturedOutput::of(|| run(node, Bin::Client, reveal_args)); + let captured = CapturedOutput::of(|| run(node, Bin::Client, reveal_args)); assert!(captured.result.is_ok()); assert!(captured.contains(TX_APPLIED_SUCCESS)); // c. Send some funds to the implicit account. @@ -133,8 +133,7 @@ pub fn make_temp_account( "--node", ledger_address, ]; - let captured = - CapturedOutput::of(|| run(node, Bin::Client, credit_args)); + let captured = CapturedOutput::of(|| run(node, Bin::Client, credit_args)); assert!(captured.result.is_ok()); assert!(captured.contains(TX_APPLIED_SUCCESS)); // d. Obtain the key pair associated with the new address diff --git a/crates/tests/src/integration/ledger_tests.rs b/crates/tests/src/integration/ledger_tests.rs index 7649c72413..3dde4003f4 100644 --- a/crates/tests/src/integration/ledger_tests.rs +++ b/crates/tests/src/integration/ledger_tests.rs @@ -9,9 +9,7 @@ use borsh::BorshDeserialize; use borsh_ext::BorshSerializeExt; use color_eyre::eyre::Result; use data_encoding::HEXLOWER; -use namada_apps_lib::wallet::defaults::{ - self, get_unencrypted_keypair, is_use_device, -}; +use namada_apps_lib::wallet::defaults::{self, is_use_device}; use namada_core::chain::Epoch; use namada_core::dec::Dec; use namada_core::hash::Hash; @@ -32,14 +30,14 @@ use namada_test_utils::TestWasms; use test_log::test; use crate::e2e::ledger_tests::prepare_proposal_data; +use crate::e2e::setup::apply_use_device; use crate::e2e::setup::constants::{ ALBERT, ALBERT_KEY, APFEL, BERTHA, BERTHA_KEY, BTC, CHRISTEL, CHRISTEL_KEY, DAEWON, DOT, ESTER, ETH, GOVERNANCE_ADDRESS, KARTOFFEL, NAM, PGF_ADDRESS, SCHNITZEL, }; -use crate::e2e::setup::{apply_use_device, ensure_hot_key}; use crate::integration::helpers::{ - find_address, find_keypair, prepare_steward_commission_update_data, + find_address, make_temp_account, prepare_steward_commission_update_data, }; use crate::integration::setup; use crate::strings::{ @@ -551,10 +549,10 @@ fn pos_rewards() -> Result<()> { }); assert_matches!(captured.result, Ok(_)); let _res = captured - .matches(r"Current annual staking rewards rate: 63.483") + .matches(r"Current annual staking rewards rate: 65.705255877354") .expect("Test failed"); let _res = captured - .matches(r"PoS inflation rate: 0.066") + .matches(r"PoS inflation rate: 0.066593164444") .expect("Test failed"); Ok(()) @@ -985,20 +983,20 @@ fn inflation() -> Result<()> { })?; let pos_inflation = [ - 114400000.785983, - 114400001.632333, - 114400002.53905, - 114400003.506134, - 114400004.533585, + 118400000.813463, + 118400001.689407, + 118400002.627832, + 118400003.628738, + 118400004.692125, ]; let steward_inflation = [ - 1980000.36276, - 1980000.72552, - 1980001.08828, - 1980001.45104, - 1980001.8138, + 1980000.375443, + 1980000.750886, + 1980001.126329, + 1980001.501772, + 1980001.877215, ]; - let pgf_inflation = [0.399038, 0.792006, 1.200066, 1.623217, 2.06146]; + let pgf_inflation = [0.41299, 0.819698, 1.242026, 1.679974, 2.133543]; for epoch in 0..5 { node.next_epoch(); @@ -1283,7 +1281,7 @@ fn pgf_governance_proposal() -> Result<()> { let captured = CapturedOutput::of(|| run(&node, Bin::Client, query_balance_args)); assert_matches!(captured.result, Ok(_)); - assert!(captured.contains("nam: 13.785266")); + assert!(captured.contains("nam: 14.267253")); let query_total_supply_args = vec![ "total-supply", @@ -1296,7 +1294,7 @@ fn pgf_governance_proposal() -> Result<()> { CapturedOutput::of(|| run(&node, Bin::Client, query_total_supply_args)); assert_matches!(captured.result, Ok(_)); assert!(captured.contains( - "token tnam1q9kn74xfzytqkqyycfrhycr8ajam8ny935cge0z5: 114400023.904507" + "token tnam1q9kn74xfzytqkqyycfrhycr8ajam8ny935cge0z5: 118400024.740301" )); let query_native_supply_args = @@ -1305,7 +1303,7 @@ fn pgf_governance_proposal() -> Result<()> { run(&node, Bin::Client, query_native_supply_args) }); assert_matches!(captured.result, Ok(_)); - assert!(captured.contains("nam: 114400010.119241")); + assert!(captured.contains("nam: 118400010.473048")); // 8. Submit proposal funding let albert = defaults::albert_address(); @@ -1695,9 +1693,16 @@ fn change_validator_metadata() -> Result<()> { fn offline_sign() -> Result<()> { // This address doesn't matter for tests. But an argument is required. let validator_one_rpc = "http://127.0.0.1:26567"; + // 1. start the ledger node let (node, _services) = setup::setup()?; + // Initialize accounts we can access the secret keys of + let (bradley_alias, _bradley_key) = + make_temp_account(&node, validator_one_rpc, "Bradley", NAM, 500_000)?; + let (cooper_alias, _cooper_key) = + make_temp_account(&node, validator_one_rpc, "Cooper", NAM, 500_000)?; + let output_folder = tempfile::tempdir().unwrap(); // 2. Dump a wrapped transfer tx @@ -1708,7 +1713,7 @@ fn offline_sign() -> Result<()> { apply_use_device(vec![ "transparent-transfer", "--source", - BERTHA, + bradley_alias.as_ref(), "--target", ALBERT, "--token", @@ -1720,7 +1725,7 @@ fn offline_sign() -> Result<()> { "--gas-price", "1", "--gas-payer", - CHRISTEL_KEY, + cooper_alias.as_ref(), "--node", &validator_one_rpc, "--dump-wrapper-tx", @@ -1739,26 +1744,23 @@ fn offline_sign() -> Result<()> { .display() .to_string(); - let bertha_sk = find_keypair(&node, BERTHA_KEY).unwrap().to_string(); - let christel_sk = find_keypair(&node, CHRISTEL_KEY).unwrap().to_string(); - // 3. Sign the transaction offline let captured = CapturedOutput::of(|| { run( &node, Bin::Client, - apply_use_device(vec![ + vec![ "utils", "sign-offline", "--data-path", &offline_tx, "--secret-keys", - &bertha_sk, + &bradley_alias.as_ref(), "--secret-key", - &christel_sk, + &cooper_alias.as_ref(), "--output-folder-path", &output_folder.path().to_str().unwrap(), - ]), + ], ) }); assert!(captured.result.is_ok()); @@ -1821,7 +1823,7 @@ fn offline_sign() -> Result<()> { vec![ "balance", "--owner", - ensure_hot_key(BERTHA), + bradley_alias.as_ref(), "--token", NAM, "--node", @@ -1830,7 +1832,7 @@ fn offline_sign() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("nam: 1999900")); + assert!(captured.contains("nam: 499900")); let captured = CapturedOutput::of(|| { run( &node, @@ -1838,7 +1840,7 @@ fn offline_sign() -> Result<()> { vec![ "balance", "--owner", - ensure_hot_key(CHRISTEL_KEY), + cooper_alias.as_ref(), "--token", NAM, "--node", @@ -1847,7 +1849,7 @@ fn offline_sign() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("nam: 1800000")); + assert!(captured.contains("nam: 300000")); Ok(()) } @@ -1862,6 +1864,10 @@ fn enforce_fee_payment() -> Result<()> { // 1. start the ledger node let (node, _services) = setup::setup()?; + // Initialize accounts we can access the secret keys of + let (adam_alias, adam_key) = + make_temp_account(&node, validator_one_rpc, "Adam", NAM, 2_000_000)?; + let tempdir = tempfile::tempdir().unwrap(); let mut txs_bytes = vec![]; @@ -1872,7 +1878,7 @@ fn enforce_fee_payment() -> Result<()> { vec![ "balance", "--owner", - ensure_hot_key(ALBERT_KEY), + adam_alias.as_ref(), "--token", NAM, "--node", @@ -1889,7 +1895,7 @@ fn enforce_fee_payment() -> Result<()> { apply_use_device(vec![ "transparent-transfer", "--source", - ensure_hot_key(ALBERT_KEY), + adam_alias.as_ref(), "--target", BERTHA, "--token", @@ -1925,7 +1931,7 @@ fn enforce_fee_payment() -> Result<()> { apply_use_device(vec![ "transparent-transfer", "--source", - ensure_hot_key(ALBERT_KEY), + adam_alias.as_ref(), "--target", CHRISTEL, "--token", @@ -1933,7 +1939,7 @@ fn enforce_fee_payment() -> Result<()> { "--amount", "50", "--gas-payer", - ensure_hot_key(ALBERT_KEY), + adam_alias.as_ref(), "--output-folder-path", tempdir.path().to_str().unwrap(), "--dump-tx", @@ -1953,9 +1959,7 @@ fn enforce_fee_payment() -> Result<()> { txs_bytes.push(std::fs::read(&file_path).unwrap()); std::fs::remove_file(&file_path).unwrap(); - let sk = get_unencrypted_keypair( - &ensure_hot_key("albert-key").to_ascii_lowercase(), - ); + let sk = adam_key; let pk = sk.to_public(); let native_token = node @@ -2020,7 +2024,7 @@ fn enforce_fee_payment() -> Result<()> { vec![ "balance", "--owner", - ensure_hot_key(ALBERT_KEY), + adam_alias.as_ref(), "--token", NAM, "--node", @@ -2093,7 +2097,7 @@ fn apply_snapshot() -> Result<()> { for _ in 0..3 { node.next_epoch(); } - let tx_args = vec![ + let tx_args = apply_use_device(vec![ "transparent-transfer", "--source", BERTHA, @@ -2108,7 +2112,7 @@ fn apply_snapshot() -> Result<()> { "--node", &validator_one_rpc, "--force", - ]; + ]); let captured = CapturedOutput::of(|| run(&node, Bin::Client, tx_args)); assert_matches!(captured.result, Ok(_)); diff --git a/crates/tests/src/integration/masp.rs b/crates/tests/src/integration/masp.rs index 568f2ab6f6..b6f83aa3df 100644 --- a/crates/tests/src/integration/masp.rs +++ b/crates/tests/src/integration/masp.rs @@ -3,10 +3,10 @@ use std::str::FromStr; use color_eyre::eyre::Result; use color_eyre::owo_colors::OwoColorize; -use namada_core::address::Address; use namada_apps_lib::wallet::defaults::{ get_unencrypted_keypair, is_use_device, }; +use namada_core::address::Address; use namada_core::dec::Dec; use namada_core::masp::{MaspTxId, TokenMap}; use namada_node::shell::testing::client::run; @@ -24,13 +24,13 @@ use namada_sdk::{tx, DEFAULT_GAS_LIMIT}; use test_log::test; use super::{helpers, setup}; +use crate::e2e::setup::apply_use_device; use crate::e2e::setup::constants::{ AA_PAYMENT_ADDRESS, AA_VIEWING_KEY, AB_PAYMENT_ADDRESS, AB_VIEWING_KEY, AC_PAYMENT_ADDRESS, AC_VIEWING_KEY, ALBERT, ALBERT_KEY, A_SPENDING_KEY, BB_PAYMENT_ADDRESS, BERTHA, BERTHA_KEY, BTC, B_SPENDING_KEY, CHRISTEL, CHRISTEL_KEY, C_SPENDING_KEY, ETH, FRANK_KEY, MASP, NAM, }; -use crate::e2e::setup::{apply_use_device, ensure_hot_key}; use crate::integration::helpers::make_temp_account; use crate::strings::TX_APPLIED_SUCCESS; @@ -106,7 +106,7 @@ fn init_null_rewards() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "shield", "--source", BERTHA, @@ -118,7 +118,7 @@ fn init_null_rewards() -> Result<()> { "1000000", "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -245,7 +245,7 @@ fn init_null_rewards() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -259,7 +259,7 @@ fn init_null_rewards() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -302,7 +302,7 @@ fn init_null_rewards() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "transfer", "--source", A_SPENDING_KEY, @@ -316,7 +316,7 @@ fn init_null_rewards() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -359,7 +359,7 @@ fn init_null_rewards() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -373,7 +373,7 @@ fn init_null_rewards() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -470,7 +470,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "shield", "--source", BERTHA, @@ -482,7 +482,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { HALF_TEST_TOKEN_INITIAL_SUPPLY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -552,7 +552,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -566,7 +566,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -639,7 +639,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "shield", "--source", BERTHA, @@ -651,7 +651,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { HALF_TEST_TOKEN_INITIAL_SUPPLY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -724,7 +724,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -740,7 +740,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { RPC, "--gas-limit", "65000", - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -783,7 +783,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "shield", "--source", BERTHA_KEY, @@ -797,7 +797,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -842,7 +842,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -859,7 +859,7 @@ fn values_spanning_multiple_masp_digits() -> Result<()> { C_SPENDING_KEY, "--gas-limit", "65000", - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -948,7 +948,7 @@ fn enable_rewards_after_shielding() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "shield", "--source", BERTHA, @@ -960,7 +960,7 @@ fn enable_rewards_after_shielding() -> Result<()> { "1000000", "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -1111,7 +1111,7 @@ fn enable_rewards_after_shielding() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -1125,7 +1125,7 @@ fn enable_rewards_after_shielding() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -1171,7 +1171,7 @@ fn enable_rewards_after_shielding() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "shield", "--source", BERTHA, @@ -1183,7 +1183,7 @@ fn enable_rewards_after_shielding() -> Result<()> { "1000000", "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -1273,7 +1273,7 @@ fn enable_rewards_after_shielding() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -1287,7 +1287,7 @@ fn enable_rewards_after_shielding() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -1330,7 +1330,7 @@ fn enable_rewards_after_shielding() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "transfer", "--source", A_SPENDING_KEY, @@ -1344,7 +1344,7 @@ fn enable_rewards_after_shielding() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -1387,7 +1387,7 @@ fn enable_rewards_after_shielding() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -1401,7 +1401,7 @@ fn enable_rewards_after_shielding() -> Result<()> { BERTHA_KEY, "--node", RPC, - ], + ]), ) }); assert!(captured.result.is_ok(), "{:?}", captured.result); @@ -2714,6 +2714,10 @@ fn multiple_unfetched_txs_same_block() -> Result<()> { let (mut node, _services) = setup::setup()?; _ = node.next_epoch(); + // Initialize accounts we can access the secret keys of + let (cooper_alias, cooper_key) = + make_temp_account(&node, validator_one_rpc, "Cooper", NAM, 500_000)?; + // 1. Shield tokens _ = node.next_epoch(); let captured = CapturedOutput::of(|| { @@ -2847,7 +2851,7 @@ fn multiple_unfetched_txs_same_block() -> Result<()> { "--amount", "50", "--gas-payer", - CHRISTEL_KEY, + cooper_alias.as_ref(), "--output-folder-path", tempdir.path().to_str().unwrap(), "--dump-tx", @@ -2884,7 +2888,7 @@ fn multiple_unfetched_txs_same_block() -> Result<()> { "--amount", "50", "--gas-payer", - CHRISTEL_KEY, + cooper_alias.as_ref(), "--output-folder-path", tempdir.path().to_str().unwrap(), "--dump-tx", @@ -2906,9 +2910,7 @@ fn multiple_unfetched_txs_same_block() -> Result<()> { txs_bytes.push(std::fs::read(&file_path).unwrap()); std::fs::remove_file(&file_path).unwrap(); - let sk = get_unencrypted_keypair( - &ensure_hot_key(CHRISTEL_KEY).to_ascii_lowercase(), - ); + let sk = cooper_key; let pk = sk.to_public(); let native_token = node @@ -2954,6 +2956,10 @@ fn expired_masp_tx() -> Result<()> { let (mut node, _services) = setup::setup()?; _ = node.next_epoch(); + // Initialize accounts we can access the secret keys of + let (cooper_alias, cooper_key) = + make_temp_account(&node, validator_one_rpc, "Cooper", NAM, 500_000)?; + // 1. Shield tokens _ = node.next_epoch(); run( @@ -3000,7 +3006,7 @@ fn expired_masp_tx() -> Result<()> { "--amount", "50", "--gas-payer", - CHRISTEL_KEY, + cooper_alias.as_ref(), // We want to create an expired masp tx. Doing so will also set // the expiration field of the header which can // be a problem because this would lead to the @@ -3034,9 +3040,7 @@ fn expired_masp_tx() -> Result<()> { let tx_bytes = std::fs::read(&file_path).unwrap(); std::fs::remove_file(&file_path).unwrap(); - let sk = get_unencrypted_keypair( - &ensure_hot_key(CHRISTEL_KEY).to_ascii_lowercase(), - ); + let sk = cooper_key; let pk = sk.to_public(); let native_token = node @@ -3294,7 +3298,7 @@ fn dynamic_assets() -> Result<()> { }); assert!(captured.result.is_ok()); assert!(captured.contains(TX_APPLIED_SUCCESS)); - + // sync the shielded context run( &node, @@ -3430,7 +3434,7 @@ fn dynamic_assets() -> Result<()> { }); assert!(captured.result.is_ok()); assert!(captured.contains(TX_APPLIED_SUCCESS)); - + // sync the shielded context run( &node, @@ -3759,7 +3763,7 @@ fn dynamic_assets() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -3773,7 +3777,7 @@ fn dynamic_assets() -> Result<()> { BERTHA_KEY, "--ledger-address", validator_one_rpc, - ], + ]), ) }); assert!(captured.result.is_ok()); @@ -3810,7 +3814,7 @@ fn dynamic_assets() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "unshield", "--source", A_SPENDING_KEY, @@ -3824,7 +3828,7 @@ fn dynamic_assets() -> Result<()> { BERTHA_KEY, "--ledger-address", validator_one_rpc, - ], + ]), ) }); assert!(captured.result.is_ok()); @@ -3898,7 +3902,7 @@ fn masp_fee_payment() -> Result<()> { }); assert!(captured.result.is_ok()); assert!(captured.contains(TX_APPLIED_SUCCESS)); - + _ = node.next_masp_epoch(); // sync shielded context run( @@ -3983,7 +3987,7 @@ fn masp_fee_payment() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "transparent-transfer", "--source", ALBERT_KEY, @@ -3997,7 +4001,7 @@ fn masp_fee_payment() -> Result<()> { CHRISTEL_KEY, "--ledger-address", validator_one_rpc, - ], + ]), ) }); assert!(captured.result.is_ok()); @@ -4027,7 +4031,7 @@ fn masp_fee_payment() -> Result<()> { run( &node, Bin::Client, - vec![ + apply_use_device(vec![ "transparent-transfer", "--source", BERTHA_KEY, @@ -4043,7 +4047,7 @@ fn masp_fee_payment() -> Result<()> { validator_one_rpc, // Force to skip check in client "--force", - ], + ]), ) }); assert!(captured.result.is_err()); @@ -4093,7 +4097,7 @@ fn masp_fee_payment() -> Result<()> { }); assert!(captured.result.is_ok()); assert!(captured.contains(TX_APPLIED_SUCCESS)); - + // sync shielded context run( &node, @@ -4902,6 +4906,12 @@ fn identical_output_descriptions() -> Result<()> { _ = node.next_masp_epoch(); let tempdir = tempfile::tempdir().unwrap(); + // Initialize accounts we can access the secret keys of + let (adam_alias, adam_key) = + make_temp_account(&node, validator_one_rpc, "Adam", NAM, 500_000)?; + let (bradley_alias, bradley_key) = + make_temp_account(&node, validator_one_rpc, "Bradley", NAM, 500_000)?; + // Generate a tx to shield some tokens let captured = CapturedOutput::of(|| { run( @@ -4910,7 +4920,7 @@ fn identical_output_descriptions() -> Result<()> { apply_use_device(vec![ "shield", "--source", - ensure_hot_key(ALBERT_KEY), + adam_alias.as_ref(), "--target", AA_PAYMENT_ADDRESS, "--token", @@ -4918,7 +4928,7 @@ fn identical_output_descriptions() -> Result<()> { "--amount", "1000", "--gas-payer", - ensure_hot_key(ALBERT_KEY), + bradley_alias.as_ref(), "--output-folder-path", tempdir.path().to_str().unwrap(), "--dump-wrapper-tx", @@ -4928,7 +4938,7 @@ fn identical_output_descriptions() -> Result<()> { ) }); assert!(captured.result.is_ok()); - + let file_path = tempdir .path() .read_dir() @@ -4952,15 +4962,12 @@ fn identical_output_descriptions() -> Result<()> { tx_clone.header.batch.clear(); tx_clone.header.batch.insert(cmt); - let keypair = get_unencrypted_keypair( - &ensure_hot_key(ALBERT_KEY).to_ascii_lowercase(), - ); let signing_data = SigningTxData { owner: None, - public_keys: vec![keypair.to_public()], + public_keys: vec![adam_key.to_public()], threshold: 1, account_public_keys_map: None, - fee_payer: keypair.to_public(), + fee_payer: adam_key.to_public(), shielded_hash: None, }; @@ -4971,13 +4978,13 @@ fn identical_output_descriptions() -> Result<()> { .unwrap(); batched_tx.sign_raw( - vec![keypair.clone()], + vec![adam_key.clone()], AccountPublicKeysMap::from_iter( - vec![(keypair.to_public())].into_iter(), + vec![(adam_key.to_public())].into_iter(), ), None, ); - batched_tx.sign_wrapper(keypair); + batched_tx.sign_wrapper(bradley_key); let wrapper_hash = batched_tx.wrapper_hash(); let inner_cmts = batched_tx.commitments(); @@ -5059,7 +5066,7 @@ fn identical_output_descriptions() -> Result<()> { vec![ "balance", "--owner", - ALBERT_KEY, + adam_alias.as_ref(), "--token", NAM, "--node", @@ -5068,7 +5075,7 @@ fn identical_output_descriptions() -> Result<()> { ) }); assert!(captured.result.is_ok()); - assert!(captured.contains("nam: 1998000")); + assert!(captured.contains("nam: 498000")); let captured = CapturedOutput::of(|| { run( @@ -5277,14 +5284,20 @@ fn masp_batch() -> Result<()> { for (tx0, tx1) in [(tx0.clone(), tx1.clone()), (tx1, tx0)] { let (mut batched_tx, _signing_data) = namada_sdk::tx::build_batch(vec![ - (tx0.clone(), SigningTxData { - shielded_hash: get_shielded_hash(&tx0), - ..signing_data.clone() - }), - (tx1.clone(), SigningTxData { - shielded_hash: get_shielded_hash(&tx1), - ..signing_data.clone() - }), + ( + tx0.clone(), + SigningTxData { + shielded_hash: get_shielded_hash(&tx0), + ..signing_data.clone() + }, + ), + ( + tx1.clone(), + SigningTxData { + shielded_hash: get_shielded_hash(&tx1), + ..signing_data.clone() + }, + ), ]) .unwrap(); batched_tx.header.atomic = false; @@ -5526,14 +5539,20 @@ fn masp_atomic_batch() -> Result<()> { for (tx0, tx1) in [(tx0.clone(), tx1.clone()), (tx1, tx0)] { let (mut batched_tx, _signing_data) = namada_sdk::tx::build_batch(vec![ - (tx0.clone(), SigningTxData { - shielded_hash: get_shielded_hash(&tx0), - ..signing_data.clone() - }), - (tx1.clone(), SigningTxData { - shielded_hash: get_shielded_hash(&tx1), - ..signing_data.clone() - }), + ( + tx0.clone(), + SigningTxData { + shielded_hash: get_shielded_hash(&tx0), + ..signing_data.clone() + }, + ), + ( + tx1.clone(), + SigningTxData { + shielded_hash: get_shielded_hash(&tx1), + ..signing_data.clone() + }, + ), ]) .unwrap(); batched_tx.header.atomic = true;