From 31fb89e992e349151987a5cc95d48817b4da23af Mon Sep 17 00:00:00 2001 From: fryorcraken Date: Mon, 16 Mar 2026 15:20:00 +1100 Subject: [PATCH] fix tests --- integration_tests/tests/amm.rs | 65 +++++--- .../tests/auth_transfer/private.rs | 44 +++-- .../tests/auth_transfer/public.rs | 23 ++- integration_tests/tests/indexer.rs | 36 ++++- integration_tests/tests/keys_restoration.rs | 45 +++--- integration_tests/tests/pinata.rs | 20 ++- integration_tests/tests/token.rs | 153 +++++++++++------- 7 files changed, 263 insertions(+), 123 deletions(-) diff --git a/integration_tests/tests/amm.rs b/integration_tests/tests/amm.rs index 42aa5f3f..1c6c5410 100644 --- a/integration_tests/tests/amm.rs +++ b/integration_tests/tests/amm.rs @@ -113,9 +113,12 @@ async fn amm_public() -> Result<()> { // Create new token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(definition_account_id_1), - supply_account_id: format_public_account_id(supply_account_id_1), - name: "A NAM1".to_owned(), + definition_account_id: Some(format_public_account_id(definition_account_id_1)), + definition_account_label: None, + supply_account_id: Some(format_public_account_id(supply_account_id_1)), + supply_account_label: None, + name: "A NAM1".to_string(), + total_supply: 37, }; wallet::cli::execute_subcommand(ctx.wallet_mut(), Command::Token(subcommand)).await?; @@ -124,8 +127,10 @@ async fn amm_public() -> Result<()> { // Transfer 7 tokens from `supply_acc` to the account at account_id `recipient_account_id_1` let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(supply_account_id_1), + from: Some(format_public_account_id(supply_account_id_1)), + from_label: None, to: Some(format_public_account_id(recipient_account_id_1)), + to_label: None, to_npk: None, to_vpk: None, amount: 7, @@ -137,9 +142,12 @@ async fn amm_public() -> Result<()> { // Create new token let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(definition_account_id_2), - supply_account_id: format_public_account_id(supply_account_id_2), - name: "A NAM2".to_owned(), + definition_account_id: Some(format_public_account_id(definition_account_id_2)), + definition_account_label: None, + supply_account_id: Some(format_public_account_id(supply_account_id_2)), + supply_account_label: None, + name: "A NAM2".to_string(), + total_supply: 37, }; wallet::cli::execute_subcommand(ctx.wallet_mut(), Command::Token(subcommand)).await?; @@ -148,8 +156,10 @@ async fn amm_public() -> Result<()> { // Transfer 7 tokens from `supply_acc` to the account at account_id `recipient_account_id_2` let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(supply_account_id_2), + from: Some(format_public_account_id(supply_account_id_2)), + from_label: None, to: Some(format_public_account_id(recipient_account_id_2)), + to_label: None, to_npk: None, to_vpk: None, amount: 7, @@ -181,9 +191,12 @@ async fn amm_public() -> Result<()> { // Send creation tx let subcommand = AmmProgramAgnosticSubcommand::New { - user_holding_a: format_public_account_id(recipient_account_id_1), - user_holding_b: format_public_account_id(recipient_account_id_2), - user_holding_lp: format_public_account_id(user_holding_lp), + user_holding_a: Some(format_public_account_id(recipient_account_id_1)), + user_holding_a_label: None, + user_holding_b: Some(format_public_account_id(recipient_account_id_2)), + user_holding_b_label: None, + user_holding_lp: Some(format_public_account_id(user_holding_lp)), + user_holding_lp_label: None, balance_a: 3, balance_b: 3, }; @@ -224,8 +237,10 @@ async fn amm_public() -> Result<()> { // Make swap let subcommand = AmmProgramAgnosticSubcommand::Swap { - user_holding_a: format_public_account_id(recipient_account_id_1), - user_holding_b: format_public_account_id(recipient_account_id_2), + user_holding_a: Some(format_public_account_id(recipient_account_id_1)), + user_holding_a_label: None, + user_holding_b: Some(format_public_account_id(recipient_account_id_2)), + user_holding_b_label: None, amount_in: 2, min_amount_out: 1, token_definition: definition_account_id_1.to_string(), @@ -267,8 +282,10 @@ async fn amm_public() -> Result<()> { // Make swap let subcommand = AmmProgramAgnosticSubcommand::Swap { - user_holding_a: format_public_account_id(recipient_account_id_1), - user_holding_b: format_public_account_id(recipient_account_id_2), + user_holding_a: Some(format_public_account_id(recipient_account_id_1)), + user_holding_a_label: None, + user_holding_b: Some(format_public_account_id(recipient_account_id_2)), + user_holding_b_label: None, amount_in: 2, min_amount_out: 1, token_definition: definition_account_id_2.to_string(), @@ -310,9 +327,12 @@ async fn amm_public() -> Result<()> { // Add liquidity let subcommand = AmmProgramAgnosticSubcommand::AddLiquidity { - user_holding_a: format_public_account_id(recipient_account_id_1), - user_holding_b: format_public_account_id(recipient_account_id_2), - user_holding_lp: format_public_account_id(user_holding_lp), + user_holding_a: Some(format_public_account_id(recipient_account_id_1)), + user_holding_a_label: None, + user_holding_b: Some(format_public_account_id(recipient_account_id_2)), + user_holding_b_label: None, + user_holding_lp: Some(format_public_account_id(user_holding_lp)), + user_holding_lp_label: None, min_amount_lp: 1, max_amount_a: 2, max_amount_b: 2, @@ -354,9 +374,12 @@ async fn amm_public() -> Result<()> { // Remove liquidity let subcommand = AmmProgramAgnosticSubcommand::RemoveLiquidity { - user_holding_a: format_public_account_id(recipient_account_id_1), - user_holding_b: format_public_account_id(recipient_account_id_2), - user_holding_lp: format_public_account_id(user_holding_lp), + user_holding_a: Some(format_public_account_id(recipient_account_id_1)), + user_holding_a_label: None, + user_holding_b: Some(format_public_account_id(recipient_account_id_2)), + user_holding_b_label: None, + user_holding_lp: Some(format_public_account_id(user_holding_lp)), + user_holding_lp_label: None, balance_lp: 2, min_amount_a: 1, min_amount_b: 1, diff --git a/integration_tests/tests/auth_transfer/private.rs b/integration_tests/tests/auth_transfer/private.rs index 59b4719a..01376386 100644 --- a/integration_tests/tests/auth_transfer/private.rs +++ b/integration_tests/tests/auth_transfer/private.rs @@ -8,7 +8,6 @@ use integration_tests::{ use log::info; use nssa::{AccountId, program::Program}; use nssa_core::{NullifierPublicKey, encryption::shared_key_derivation::Secp256k1Point}; -use sequencer_service_rpc::RpcClient as _; use tokio::test; use wallet::cli::{ Command, SubcommandReturnValue, @@ -24,8 +23,10 @@ async fn private_transfer_to_owned_account() -> Result<()> { let to: AccountId = ctx.existing_private_accounts()[1]; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: Some(format_private_account_id(to)), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -63,8 +64,10 @@ async fn private_transfer_to_foreign_account() -> Result<()> { let to_vpk = Secp256k1Point::from_scalar(to_npk.0); let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: None, + to_label: None, to_npk: Some(to_npk_string), to_vpk: Some(hex::encode(to_vpk.0)), amount: 100, @@ -87,7 +90,7 @@ async fn private_transfer_to_foreign_account() -> Result<()> { assert_eq!(tx.message.new_commitments[0], new_commitment1); assert_eq!(tx.message.new_commitments.len(), 2); - for commitment in tx.message.new_commitments { + for commitment in tx.message.new_commitments.into_iter() { assert!(verify_commitment_is_in_state(commitment, ctx.sequencer_client()).await); } @@ -111,8 +114,10 @@ async fn deshielded_transfer_to_public_account() -> Result<()> { assert_eq!(from_acc.balance, 10000); let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: Some(format_public_account_id(to)), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -136,7 +141,7 @@ async fn deshielded_transfer_to_public_account() -> Result<()> { let acc_2_balance = ctx.sequencer_client().get_account_balance(to).await?; assert_eq!(from_acc.balance, 9900); - assert_eq!(acc_2_balance, 20100); + assert_eq!(acc_2_balance.balance, 20100); info!("Successfully deshielded transfer to public account"); @@ -174,8 +179,10 @@ async fn private_transfer_to_owned_account_using_claiming_path() -> Result<()> { // Send to this account using claiming path (using npk and vpk instead of account ID) let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: None, + to_label: None, to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)), to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)), amount: 100, @@ -199,7 +206,7 @@ async fn private_transfer_to_owned_account_using_claiming_path() -> Result<()> { assert_eq!(tx.message.new_commitments[0], new_commitment1); assert_eq!(tx.message.new_commitments.len(), 2); - for commitment in tx.message.new_commitments { + for commitment in tx.message.new_commitments.into_iter() { assert!(verify_commitment_is_in_state(commitment, ctx.sequencer_client()).await); } @@ -222,8 +229,10 @@ async fn shielded_transfer_to_owned_private_account() -> Result<()> { let to: AccountId = ctx.existing_private_accounts()[1]; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(from), + from: Some(format_public_account_id(from)), + from_label: None, to: Some(format_private_account_id(to)), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -246,7 +255,7 @@ async fn shielded_transfer_to_owned_private_account() -> Result<()> { let acc_from_balance = ctx.sequencer_client().get_account_balance(from).await?; - assert_eq!(acc_from_balance, 9900); + assert_eq!(acc_from_balance.balance, 9900); assert_eq!(acc_to.balance, 20100); info!("Successfully shielded transfer to owned private account"); @@ -264,8 +273,10 @@ async fn shielded_transfer_to_foreign_account() -> Result<()> { let from: AccountId = ctx.existing_public_accounts()[0]; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(from), + from: Some(format_public_account_id(from)), + from_label: None, to: None, + to_label: None, to_npk: Some(to_npk_string), to_vpk: Some(hex::encode(to_vpk.0)), amount: 100, @@ -291,7 +302,7 @@ async fn shielded_transfer_to_foreign_account() -> Result<()> { .await ); - assert_eq!(acc_1_balance, 9900); + assert_eq!(acc_1_balance.balance, 9900); info!("Successfully shielded transfer to foreign account"); @@ -334,8 +345,10 @@ async fn private_transfer_to_owned_account_continuous_run_path() -> Result<()> { // Send transfer using nullifier and viewing public keys let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: None, + to_label: None, to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)), to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)), amount: 100, @@ -354,7 +367,7 @@ async fn private_transfer_to_owned_account_continuous_run_path() -> Result<()> { // Verify commitments are in state assert_eq!(tx.message.new_commitments.len(), 2); - for commitment in tx.message.new_commitments { + for commitment in tx.message.new_commitments.into_iter() { assert!(verify_commitment_is_in_state(commitment, ctx.sequencer_client()).await); } @@ -383,7 +396,8 @@ async fn initialize_private_account() -> Result<()> { }; let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account_id: format_private_account_id(account_id), + account_id: Some(format_private_account_id(account_id)), + account_label: None, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; diff --git a/integration_tests/tests/auth_transfer/public.rs b/integration_tests/tests/auth_transfer/public.rs index 7f8c3836..80f9d4e4 100644 --- a/integration_tests/tests/auth_transfer/public.rs +++ b/integration_tests/tests/auth_transfer/public.rs @@ -17,8 +17,10 @@ async fn successful_transfer_to_existing_account() -> Result<()> { let mut ctx = TestContext::new().await?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ctx.existing_public_accounts()[0]), + from: Some(format_public_account_id(ctx.existing_public_accounts()[0])), + from_label: None, to: Some(format_public_account_id(ctx.existing_public_accounts()[1])), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -73,8 +75,10 @@ pub async fn successful_transfer_to_new_account() -> Result<()> { .expect("Failed to find newly created account in the wallet storage"); let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ctx.existing_public_accounts()[0]), + from: Some(format_public_account_id(ctx.existing_public_accounts()[0])), + from_label: None, to: Some(format_public_account_id(new_persistent_account_id)), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -109,8 +113,10 @@ async fn failed_transfer_with_insufficient_balance() -> Result<()> { let mut ctx = TestContext::new().await?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ctx.existing_public_accounts()[0]), + from: Some(format_public_account_id(ctx.existing_public_accounts()[0])), + from_label: None, to: Some(format_public_account_id(ctx.existing_public_accounts()[1])), + to_label: None, to_npk: None, to_vpk: None, amount: 1_000_000, @@ -147,8 +153,10 @@ async fn two_consecutive_successful_transfers() -> Result<()> { // First transfer let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ctx.existing_public_accounts()[0]), + from: Some(format_public_account_id(ctx.existing_public_accounts()[0])), + from_label: None, to: Some(format_public_account_id(ctx.existing_public_accounts()[1])), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -179,8 +187,10 @@ async fn two_consecutive_successful_transfers() -> Result<()> { // Second transfer let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ctx.existing_public_accounts()[0]), + from: Some(format_public_account_id(ctx.existing_public_accounts()[0])), + from_label: None, to: Some(format_public_account_id(ctx.existing_public_accounts()[1])), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -226,7 +236,8 @@ async fn initialize_public_account() -> Result<()> { }; let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account_id: format_public_account_id(account_id), + account_id: Some(format_public_account_id(account_id)), + account_label: None, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; diff --git a/integration_tests/tests/indexer.rs b/integration_tests/tests/indexer.rs index cb8cf0e9..4c9c5ee6 100644 --- a/integration_tests/tests/indexer.rs +++ b/integration_tests/tests/indexer.rs @@ -83,8 +83,10 @@ async fn indexer_state_consistency() -> Result<()> { let mut ctx = TestContext::new().await?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(ctx.existing_public_accounts()[0]), + from: Some(format_public_account_id(ctx.existing_public_accounts()[0])), + from_label: None, to: Some(format_public_account_id(ctx.existing_public_accounts()[1])), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -113,6 +115,38 @@ async fn indexer_state_consistency() -> Result<()> { assert_eq!(acc_1_balance, 9900); assert_eq!(acc_2_balance, 20100); + let from: AccountId = ctx.existing_private_accounts()[0]; + let to: AccountId = ctx.existing_private_accounts()[1]; + + let command = Command::AuthTransfer(AuthTransferSubcommand::Send { + from: Some(format_private_account_id(from)), + from_label: None, + to: Some(format_private_account_id(to)), + to_label: None, + to_npk: None, + to_vpk: None, + amount: 100, + }); + + wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; + + info!("Waiting for next block creation"); + tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await; + + let new_commitment1 = ctx + .wallet() + .get_private_account_commitment(from) + .context("Failed to get private account commitment for sender")?; + assert!(verify_commitment_is_in_state(new_commitment1, ctx.sequencer_client()).await); + + let new_commitment2 = ctx + .wallet() + .get_private_account_commitment(to) + .context("Failed to get private account commitment for receiver")?; + assert!(verify_commitment_is_in_state(new_commitment2, ctx.sequencer_client()).await); + + info!("Successfully transferred privately to owned account"); + // WAIT info!("Waiting for indexer to parse blocks"); tokio::time::sleep(std::time::Duration::from_millis(L2_TO_L1_TIMEOUT_MILLIS)).await; diff --git a/integration_tests/tests/keys_restoration.rs b/integration_tests/tests/keys_restoration.rs index cdbe2e6b..4e8d9bf9 100644 --- a/integration_tests/tests/keys_restoration.rs +++ b/integration_tests/tests/keys_restoration.rs @@ -1,12 +1,6 @@ -#![expect( - clippy::shadow_unrelated, - clippy::tests_outside_test_module, - reason = "We don't care about these in tests" -)] +use std::{str::FromStr, time::Duration}; -use std::{str::FromStr as _, time::Duration}; - -use anyhow::{Context as _, Result}; +use anyhow::{Context, Result}; use integration_tests::{ TIME_TO_WAIT_FOR_BLOCK_SECONDS, TestContext, fetch_privacy_preserving_tx, format_private_account_id, format_public_account_id, verify_commitment_is_in_state, @@ -14,7 +8,6 @@ use integration_tests::{ use key_protocol::key_management::key_tree::chain_index::ChainIndex; use log::info; use nssa::{AccountId, program::Program}; -use sequencer_service_rpc::RpcClient as _; use tokio::test; use wallet::cli::{ Command, SubcommandReturnValue, @@ -69,8 +62,10 @@ async fn sync_private_account_with_non_zero_chain_index() -> Result<()> { // Send to this account using claiming path (using npk and vpk instead of account ID) let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: None, + to_label: None, to_npk: Some(hex::encode(to_keys.nullifier_public_key.0)), to_vpk: Some(hex::encode(to_keys.viewing_public_key.0)), amount: 100, @@ -94,7 +89,7 @@ async fn sync_private_account_with_non_zero_chain_index() -> Result<()> { assert_eq!(tx.message.new_commitments[0], new_commitment1); assert_eq!(tx.message.new_commitments.len(), 2); - for commitment in tx.message.new_commitments { + for commitment in tx.message.new_commitments.into_iter() { assert!(verify_commitment_is_in_state(commitment, ctx.sequencer_client()).await); } @@ -143,8 +138,10 @@ async fn restore_keys_from_seed() -> Result<()> { // Send to first private account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: Some(format_private_account_id(to_account_id1)), + to_label: None, to_npk: None, to_vpk: None, amount: 100, @@ -153,8 +150,10 @@ async fn restore_keys_from_seed() -> Result<()> { // Send to second private account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(from), + from: Some(format_private_account_id(from)), + from_label: None, to: Some(format_private_account_id(to_account_id2)), + to_label: None, to_npk: None, to_vpk: None, amount: 101, @@ -191,8 +190,10 @@ async fn restore_keys_from_seed() -> Result<()> { // Send to first public account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(from), + from: Some(format_public_account_id(from)), + from_label: None, to: Some(format_public_account_id(to_account_id3)), + to_label: None, to_npk: None, to_vpk: None, amount: 102, @@ -201,8 +202,10 @@ async fn restore_keys_from_seed() -> Result<()> { // Send to second public account let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(from), + from: Some(format_public_account_id(from)), + from_label: None, to: Some(format_public_account_id(to_account_id4)), + to_label: None, to_npk: None, to_vpk: None, amount: 103, @@ -264,8 +267,10 @@ async fn restore_keys_from_seed() -> Result<()> { // Test that restored accounts can send transactions let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_private_account_id(to_account_id1), + from: Some(format_private_account_id(to_account_id1)), + from_label: None, to: Some(format_private_account_id(to_account_id2)), + to_label: None, to_npk: None, to_vpk: None, amount: 10, @@ -273,8 +278,10 @@ async fn restore_keys_from_seed() -> Result<()> { wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; let command = Command::AuthTransfer(AuthTransferSubcommand::Send { - from: format_public_account_id(to_account_id3), + from: Some(format_public_account_id(to_account_id3)), + from_label: None, to: Some(format_public_account_id(to_account_id4)), + to_label: None, to_npk: None, to_vpk: None, amount: 11, @@ -306,8 +313,8 @@ async fn restore_keys_from_seed() -> Result<()> { .get_account_balance(to_account_id4) .await?; - assert_eq!(acc3, 91); // 102 - 11 - assert_eq!(acc4, 114); // 103 + 11 + assert_eq!(acc3.balance, 91); // 102 - 11 + assert_eq!(acc4.balance, 114); // 103 + 11 info!("Successfully restored keys and verified transactions"); diff --git a/integration_tests/tests/pinata.rs b/integration_tests/tests/pinata.rs index 3285c216..77c4a646 100644 --- a/integration_tests/tests/pinata.rs +++ b/integration_tests/tests/pinata.rs @@ -52,7 +52,8 @@ async fn claim_pinata_to_uninitialized_public_account_fails_fast() -> Result<()> let claim_result = wallet::cli::execute_subcommand( ctx.wallet_mut(), Command::Pinata(PinataProgramAgnosticSubcommand::Claim { - to: winner_account_id_formatted, + to: Some(winner_account_id_formatted), + to_label: None, }), ) .await; @@ -106,7 +107,8 @@ async fn claim_pinata_to_uninitialized_private_account_fails_fast() -> Result<() let claim_result = wallet::cli::execute_subcommand( ctx.wallet_mut(), Command::Pinata(PinataProgramAgnosticSubcommand::Claim { - to: winner_account_id_formatted, + to: Some(winner_account_id_formatted), + to_label: None, }), ) .await; @@ -137,7 +139,8 @@ async fn claim_pinata_to_existing_public_account() -> Result<()> { let pinata_prize = 150; let command = Command::Pinata(PinataProgramAgnosticSubcommand::Claim { - to: format_public_account_id(ctx.existing_public_accounts()[0]), + to: Some(format_public_account_id(ctx.existing_public_accounts()[0])), + to_label: None, }); let pinata_balance_pre = ctx @@ -175,7 +178,10 @@ async fn claim_pinata_to_existing_private_account() -> Result<()> { let pinata_prize = 150; let command = Command::Pinata(PinataProgramAgnosticSubcommand::Claim { - to: format_private_account_id(ctx.existing_private_accounts()[0]), + to: Some(format_private_account_id( + ctx.existing_private_accounts()[0], + )), + to_label: None, }); let pinata_balance_pre = ctx @@ -239,7 +245,8 @@ async fn claim_pinata_to_new_private_account() -> Result<()> { // Initialize account under auth transfer program let command = Command::AuthTransfer(AuthTransferSubcommand::Init { - account_id: winner_account_id_formatted.clone(), + account_id: Some(winner_account_id_formatted.clone()), + account_label: None, }); wallet::cli::execute_subcommand(ctx.wallet_mut(), command).await?; @@ -254,7 +261,8 @@ async fn claim_pinata_to_new_private_account() -> Result<()> { // Claim pinata to the new private account let command = Command::Pinata(PinataProgramAgnosticSubcommand::Claim { - to: winner_account_id_formatted, + to: Some(winner_account_id_formatted), + to_label: None, }); let pinata_balance_pre = ctx diff --git a/integration_tests/tests/token.rs b/integration_tests/tests/token.rs index b638b6c9..43b47ee0 100644 --- a/integration_tests/tests/token.rs +++ b/integration_tests/tests/token.rs @@ -1,9 +1,3 @@ -#![expect( - clippy::shadow_unrelated, - clippy::tests_outside_test_module, - reason = "We don't care about these in tests" -)] - use std::time::Duration; use anyhow::{Context as _, Result}; @@ -14,7 +8,6 @@ use integration_tests::{ use key_protocol::key_management::key_tree::chain_index::ChainIndex; use log::info; use nssa::program::Program; -use sequencer_service_rpc::RpcClient as _; use token_core::{TokenDefinition, TokenHolding}; use tokio::test; use wallet::cli::{ @@ -76,11 +69,13 @@ async fn create_and_transfer_public_token() -> Result<()> { }; // Create new token - let name = "A NAME".to_owned(); + let name = "A NAME".to_string(); let total_supply = 37; let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(definition_account_id), - supply_account_id: format_public_account_id(supply_account_id), + definition_account_id: Some(format_public_account_id(definition_account_id)), + definition_account_label: None, + supply_account_id: Some(format_public_account_id(supply_account_id)), + supply_account_label: None, name: name.clone(), total_supply, }; @@ -93,7 +88,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let definition_acc = ctx .sequencer_client() .get_account(definition_account_id) - .await?; + .await? + .account; let token_definition = TokenDefinition::try_from(&definition_acc.data)?; assert_eq!(definition_acc.program_owner, Program::token().id()); @@ -110,7 +106,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let supply_acc = ctx .sequencer_client() .get_account(supply_account_id) - .await?; + .await? + .account; // The account must be owned by the token program assert_eq!(supply_acc.program_owner, Program::token().id()); @@ -126,8 +123,10 @@ async fn create_and_transfer_public_token() -> Result<()> { // Transfer 7 tokens from supply_acc to recipient_account_id let transfer_amount = 7; let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(supply_account_id), + from: Some(format_public_account_id(supply_account_id)), + from_label: None, to: Some(format_public_account_id(recipient_account_id)), + to_label: None, to_npk: None, to_vpk: None, amount: transfer_amount, @@ -142,7 +141,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let supply_acc = ctx .sequencer_client() .get_account(supply_account_id) - .await?; + .await? + .account; assert_eq!(supply_acc.program_owner, Program::token().id()); let token_holding = TokenHolding::try_from(&supply_acc.data)?; assert_eq!( @@ -157,7 +157,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let recipient_acc = ctx .sequencer_client() .get_account(recipient_account_id) - .await?; + .await? + .account; assert_eq!(recipient_acc.program_owner, Program::token().id()); let token_holding = TokenHolding::try_from(&recipient_acc.data)?; assert_eq!( @@ -171,8 +172,10 @@ async fn create_and_transfer_public_token() -> Result<()> { // Burn 3 tokens from recipient_acc let burn_amount = 3; let subcommand = TokenProgramAgnosticSubcommand::Burn { - definition: format_public_account_id(definition_account_id), - holder: format_public_account_id(recipient_account_id), + definition: Some(format_public_account_id(definition_account_id)), + definition_label: None, + holder: Some(format_public_account_id(recipient_account_id)), + holder_label: None, amount: burn_amount, }; @@ -185,7 +188,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let definition_acc = ctx .sequencer_client() .get_account(definition_account_id) - .await?; + .await? + .account; let token_definition = TokenDefinition::try_from(&definition_acc.data)?; assert_eq!( @@ -201,7 +205,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let recipient_acc = ctx .sequencer_client() .get_account(recipient_account_id) - .await?; + .await? + .account; let token_holding = TokenHolding::try_from(&recipient_acc.data)?; assert_eq!( @@ -215,8 +220,10 @@ async fn create_and_transfer_public_token() -> Result<()> { // Mint 10 tokens at recipient_acc let mint_amount = 10; let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_public_account_id(definition_account_id), + definition: Some(format_public_account_id(definition_account_id)), + definition_label: None, holder: Some(format_public_account_id(recipient_account_id)), + holder_label: None, holder_npk: None, holder_vpk: None, amount: mint_amount, @@ -231,7 +238,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let definition_acc = ctx .sequencer_client() .get_account(definition_account_id) - .await?; + .await? + .account; let token_definition = TokenDefinition::try_from(&definition_acc.data)?; assert_eq!( @@ -247,7 +255,8 @@ async fn create_and_transfer_public_token() -> Result<()> { let recipient_acc = ctx .sequencer_client() .get_account(recipient_account_id) - .await?; + .await? + .account; let token_holding = TokenHolding::try_from(&recipient_acc.data)?; assert_eq!( @@ -316,11 +325,13 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { }; // Create new token - let name = "A NAME".to_owned(); + let name = "A NAME".to_string(); let total_supply = 37; let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(definition_account_id), - supply_account_id: format_private_account_id(supply_account_id), + definition_account_id: Some(format_public_account_id(definition_account_id)), + definition_account_label: None, + supply_account_id: Some(format_private_account_id(supply_account_id)), + supply_account_label: None, name: name.clone(), total_supply, }; @@ -334,7 +345,8 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { let definition_acc = ctx .sequencer_client() .get_account(definition_account_id) - .await?; + .await? + .account; let token_definition = TokenDefinition::try_from(&definition_acc.data)?; assert_eq!(definition_acc.program_owner, Program::token().id()); @@ -356,8 +368,10 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { // Transfer 7 tokens from supply_acc to recipient_account_id let transfer_amount = 7; let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_private_account_id(supply_account_id), + from: Some(format_private_account_id(supply_account_id)), + from_label: None, to: Some(format_private_account_id(recipient_account_id)), + to_label: None, to_npk: None, to_vpk: None, amount: transfer_amount, @@ -383,8 +397,10 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { // Burn 3 tokens from recipient_acc let burn_amount = 3; let subcommand = TokenProgramAgnosticSubcommand::Burn { - definition: format_public_account_id(definition_account_id), - holder: format_private_account_id(recipient_account_id), + definition: Some(format_public_account_id(definition_account_id)), + definition_label: None, + holder: Some(format_private_account_id(recipient_account_id)), + holder_label: None, amount: burn_amount, }; @@ -397,7 +413,8 @@ async fn create_and_transfer_token_with_private_supply() -> Result<()> { let definition_acc = ctx .sequencer_client() .get_account(definition_account_id) - .await?; + .await? + .account; let token_definition = TokenDefinition::try_from(&definition_acc.data)?; assert_eq!( @@ -472,11 +489,13 @@ async fn create_token_with_private_definition() -> Result<()> { }; // Create token with private definition - let name = "A NAME".to_owned(); + let name = "A NAME".to_string(); let total_supply = 37; let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_private_account_id(definition_account_id), - supply_account_id: format_public_account_id(supply_account_id), + definition_account_id: Some(format_private_account_id(definition_account_id)), + definition_account_label: None, + supply_account_id: Some(format_public_account_id(supply_account_id)), + supply_account_label: None, name: name.clone(), total_supply, }; @@ -497,7 +516,8 @@ async fn create_token_with_private_definition() -> Result<()> { let supply_acc = ctx .sequencer_client() .get_account(supply_account_id) - .await?; + .await? + .account; assert_eq!(supply_acc.program_owner, Program::token().id()); let token_holding = TokenHolding::try_from(&supply_acc.data)?; @@ -544,8 +564,10 @@ async fn create_token_with_private_definition() -> Result<()> { // Mint to public account let mint_amount_public = 10; let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_private_account_id(definition_account_id), + definition: Some(format_private_account_id(definition_account_id)), + definition_label: None, holder: Some(format_public_account_id(recipient_account_id_public)), + holder_label: None, holder_npk: None, holder_vpk: None, amount: mint_amount_public, @@ -576,7 +598,8 @@ async fn create_token_with_private_definition() -> Result<()> { let recipient_acc = ctx .sequencer_client() .get_account(recipient_account_id_public) - .await?; + .await? + .account; let token_holding = TokenHolding::try_from(&recipient_acc.data)?; assert_eq!( @@ -590,8 +613,10 @@ async fn create_token_with_private_definition() -> Result<()> { // Mint to private account let mint_amount_private = 5; let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_private_account_id(definition_account_id), + definition: Some(format_private_account_id(definition_account_id)), + definition_label: None, holder: Some(format_private_account_id(recipient_account_id_private)), + holder_label: None, holder_npk: None, holder_vpk: None, amount: mint_amount_private, @@ -666,11 +691,13 @@ async fn create_token_with_private_definition_and_supply() -> Result<()> { }; // Create token with both private definition and supply - let name = "A NAME".to_owned(); + let name = "A NAME".to_string(); let total_supply = 37; let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_private_account_id(definition_account_id), - supply_account_id: format_private_account_id(supply_account_id), + definition_account_id: Some(format_private_account_id(definition_account_id)), + definition_account_label: None, + supply_account_id: Some(format_private_account_id(supply_account_id)), + supply_account_label: None, name, total_supply, }; @@ -728,8 +755,10 @@ async fn create_token_with_private_definition_and_supply() -> Result<()> { // Transfer tokens let transfer_amount = 7; let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_private_account_id(supply_account_id), + from: Some(format_private_account_id(supply_account_id)), + from_label: None, to: Some(format_private_account_id(recipient_account_id)), + to_label: None, to_npk: None, to_vpk: None, amount: transfer_amount, @@ -838,11 +867,13 @@ async fn shielded_token_transfer() -> Result<()> { }; // Create token - let name = "A NAME".to_owned(); + let name = "A NAME".to_string(); let total_supply = 37; let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(definition_account_id), - supply_account_id: format_public_account_id(supply_account_id), + definition_account_id: Some(format_public_account_id(definition_account_id)), + definition_account_label: None, + supply_account_id: Some(format_public_account_id(supply_account_id)), + supply_account_label: None, name, total_supply, }; @@ -855,8 +886,10 @@ async fn shielded_token_transfer() -> Result<()> { // Perform shielded transfer: public supply -> private recipient let transfer_amount = 7; let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_public_account_id(supply_account_id), + from: Some(format_public_account_id(supply_account_id)), + from_label: None, to: Some(format_private_account_id(recipient_account_id)), + to_label: None, to_npk: None, to_vpk: None, amount: transfer_amount, @@ -871,7 +904,8 @@ async fn shielded_token_transfer() -> Result<()> { let supply_acc = ctx .sequencer_client() .get_account(supply_account_id) - .await?; + .await? + .account; let token_holding = TokenHolding::try_from(&supply_acc.data)?; assert_eq!( token_holding, @@ -960,11 +994,13 @@ async fn deshielded_token_transfer() -> Result<()> { }; // Create token with private supply - let name = "A NAME".to_owned(); + let name = "A NAME".to_string(); let total_supply = 37; let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_public_account_id(definition_account_id), - supply_account_id: format_private_account_id(supply_account_id), + definition_account_id: Some(format_public_account_id(definition_account_id)), + definition_account_label: None, + supply_account_id: Some(format_private_account_id(supply_account_id)), + supply_account_label: None, name, total_supply, }; @@ -977,8 +1013,10 @@ async fn deshielded_token_transfer() -> Result<()> { // Perform deshielded transfer: private supply -> public recipient let transfer_amount = 7; let subcommand = TokenProgramAgnosticSubcommand::Send { - from: format_private_account_id(supply_account_id), + from: Some(format_private_account_id(supply_account_id)), + from_label: None, to: Some(format_public_account_id(recipient_account_id)), + to_label: None, to_npk: None, to_vpk: None, amount: transfer_amount, @@ -1014,7 +1052,8 @@ async fn deshielded_token_transfer() -> Result<()> { let recipient_acc = ctx .sequencer_client() .get_account(recipient_account_id) - .await?; + .await? + .account; let token_holding = TokenHolding::try_from(&recipient_acc.data)?; assert_eq!( token_holding, @@ -1066,11 +1105,13 @@ async fn token_claiming_path_with_private_accounts() -> Result<()> { }; // Create token - let name = "A NAME".to_owned(); + let name = "A NAME".to_string(); let total_supply = 37; let subcommand = TokenProgramAgnosticSubcommand::New { - definition_account_id: format_private_account_id(definition_account_id), - supply_account_id: format_private_account_id(supply_account_id), + definition_account_id: Some(format_private_account_id(definition_account_id)), + definition_account_label: None, + supply_account_id: Some(format_private_account_id(supply_account_id)), + supply_account_label: None, name, total_supply, }; @@ -1108,8 +1149,10 @@ async fn token_claiming_path_with_private_accounts() -> Result<()> { // Mint using claiming path (foreign account) let mint_amount = 9; let subcommand = TokenProgramAgnosticSubcommand::Mint { - definition: format_private_account_id(definition_account_id), + definition: Some(format_private_account_id(definition_account_id)), + definition_label: None, holder: None, + holder_label: None, holder_npk: Some(hex::encode(holder_keys.nullifier_public_key.0)), holder_vpk: Some(hex::encode(holder_keys.viewing_public_key.0)), amount: mint_amount,