mirror of
https://github.com/logos-blockchain/logos-execution-zone.git
synced 2026-07-25 23:23:11 +00:00
Merge branch 'main' into Pravdyvy/amm-wallet-integration
This commit is contained in:
@@ -347,11 +347,14 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
|
||||
assert_eq!(definition_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) || metadata id (32
|
||||
// bytes)]
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
@@ -434,6 +437,94 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
7
|
||||
);
|
||||
|
||||
// Burn 3 tokens from `recipient_acc`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Burn {
|
||||
definition: make_public_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: make_public_account_input_from_str(&recipient_account_id.to_string()),
|
||||
amount: 3,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = seq_client
|
||||
.get_account(definition_account_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
// Check the status of the account at `recipient_account_id` is the expected after the
|
||||
// execution
|
||||
let recipient_acc = seq_client
|
||||
.get_account(recipient_account_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
4
|
||||
);
|
||||
|
||||
// Mint 10 tokens at `recipient_acc`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Mint {
|
||||
definition: make_public_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: Some(make_public_account_input_from_str(
|
||||
&recipient_account_id.to_string(),
|
||||
)),
|
||||
holder_npk: None,
|
||||
holder_ipk: None,
|
||||
amount: 10,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = seq_client
|
||||
.get_account(definition_account_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
// Check the status of the account at `recipient_account_id` is the expected after the
|
||||
// execution
|
||||
let recipient_acc = seq_client
|
||||
.get_account(recipient_account_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
14
|
||||
);
|
||||
}
|
||||
|
||||
/// This test creates a new private token using the token program. After creating the token, the
|
||||
@@ -506,11 +597,14 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
|
||||
assert_eq!(definition_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) || metadata id (32
|
||||
// bytes)]
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
@@ -590,6 +684,194 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
.get_private_account_commitment(&recipient_account_id)
|
||||
.unwrap();
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, &seq_client).await);
|
||||
|
||||
// Burn 3 tokens from `recipient_acc`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Burn {
|
||||
definition: make_public_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: make_private_account_input_from_str(&recipient_account_id.to_string()),
|
||||
amount: 3,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = seq_client
|
||||
.get_account(definition_account_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 34, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let new_commitment2 = wallet_storage
|
||||
.get_private_account_commitment(&recipient_account_id)
|
||||
.unwrap();
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, &seq_client).await);
|
||||
|
||||
// Check the status of the account at `recipient_account_id` is the expected after the
|
||||
// execution
|
||||
let recipient_acc = wallet_storage
|
||||
.get_account_private(&recipient_account_id)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
11
|
||||
);
|
||||
|
||||
// Mint 10 tokens at `recipient_acc`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Mint {
|
||||
definition: make_public_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: Some(make_private_account_input_from_str(
|
||||
&recipient_account_id.to_string(),
|
||||
)),
|
||||
holder_npk: None,
|
||||
holder_ipk: None,
|
||||
amount: 10,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = seq_client
|
||||
.get_account(definition_account_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 44, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let new_commitment2 = wallet_storage
|
||||
.get_private_account_commitment(&recipient_account_id)
|
||||
.unwrap();
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, &seq_client).await);
|
||||
|
||||
// Check the status of the account at `recipient_account_id` is the expected after the
|
||||
// execution
|
||||
let recipient_acc = wallet_storage
|
||||
.get_account_private(&recipient_account_id)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
21
|
||||
);
|
||||
|
||||
// Now the same mint, but in foreign way
|
||||
|
||||
// Create new account for receiving a mint transaction
|
||||
let SubcommandReturnValue::RegisterAccount {
|
||||
account_id: recipient_account_id2,
|
||||
} = wallet::cli::execute_subcommand(Command::Account(AccountSubcommand::New(
|
||||
NewSubcommand::Private { cci: None },
|
||||
)))
|
||||
.await
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("invalid subcommand return value");
|
||||
};
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let (holder_keys, _) = wallet_storage
|
||||
.storage
|
||||
.user_data
|
||||
.get_private_account(&recipient_account_id2)
|
||||
.unwrap();
|
||||
|
||||
// Mint 9 tokens at `recipient_acc2`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Mint {
|
||||
definition: make_public_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: None,
|
||||
holder_npk: Some(hex::encode(holder_keys.nullifer_public_key.0)),
|
||||
holder_ipk: Some(hex::encode(
|
||||
holder_keys.incoming_viewing_public_key.0.clone(),
|
||||
)),
|
||||
amount: 9,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
// Sync to claim holder
|
||||
let command = Command::Account(AccountSubcommand::SyncPrivate {});
|
||||
|
||||
wallet::cli::execute_subcommand(command).await.unwrap();
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = seq_client
|
||||
.get_account(definition_account_id.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 53, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let new_commitment2 = wallet_storage
|
||||
.get_private_account_commitment(&recipient_account_id2)
|
||||
.unwrap();
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, &seq_client).await);
|
||||
|
||||
// Check the status of the account at `recipient_account_id2` is the expected after the
|
||||
// execution
|
||||
let recipient_acc = wallet_storage
|
||||
.get_account_private(&recipient_account_id2)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
9
|
||||
);
|
||||
}
|
||||
|
||||
/// This test creates a new private token using the token program. All accounts are private
|
||||
@@ -663,8 +945,8 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
.account;
|
||||
|
||||
assert_eq!(supply_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// The data of a token holding account has the following layout:
|
||||
// [ 0x01 || definition id (32 bytes) || balance (little endian 16 bytes) ]
|
||||
assert_eq!(
|
||||
supply_acc.data.as_ref(),
|
||||
&[
|
||||
@@ -673,6 +955,287 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
]
|
||||
);
|
||||
|
||||
// Create new account for receiving a mint transaction
|
||||
let SubcommandReturnValue::RegisterAccount {
|
||||
account_id: recipient_account_id_pr,
|
||||
} = wallet::cli::execute_subcommand(Command::Account(AccountSubcommand::New(
|
||||
NewSubcommand::Private { cci: None },
|
||||
)))
|
||||
.await
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("invalid subcommand return value");
|
||||
};
|
||||
|
||||
// Create new account for receiving a mint transaction
|
||||
let SubcommandReturnValue::RegisterAccount {
|
||||
account_id: recipient_account_id_pub,
|
||||
} = wallet::cli::execute_subcommand(Command::Account(AccountSubcommand::New(
|
||||
NewSubcommand::Public { cci: None },
|
||||
)))
|
||||
.await
|
||||
.unwrap()
|
||||
else {
|
||||
panic!("invalid subcommand return value");
|
||||
};
|
||||
|
||||
// Mint 10 tokens at `recipient_acc_pub`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Mint {
|
||||
definition: make_private_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: Some(make_public_account_input_from_str(
|
||||
&recipient_account_id_pub.to_string(),
|
||||
)),
|
||||
holder_npk: None,
|
||||
holder_ipk: None,
|
||||
amount: 10,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = wallet_storage
|
||||
.get_account_private(&definition_account_id)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
// Check the status of the account at `recipient_account_id_pub` is the expected after the
|
||||
// execution
|
||||
let recipient_acc_pub = seq_client
|
||||
.get_account(recipient_account_id_pub.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc_pub.data[33..].try_into().unwrap()),
|
||||
10
|
||||
);
|
||||
|
||||
let (holder_keys, _) = wallet_storage
|
||||
.storage
|
||||
.user_data
|
||||
.get_private_account(&recipient_account_id_pr)
|
||||
.unwrap();
|
||||
|
||||
// Mint 5 tokens at `recipient_acc_pr`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Mint {
|
||||
definition: make_private_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: None,
|
||||
holder_npk: Some(hex::encode(holder_keys.nullifer_public_key.0)),
|
||||
holder_ipk: Some(hex::encode(
|
||||
holder_keys.incoming_viewing_public_key.0.clone(),
|
||||
)),
|
||||
amount: 5,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
// Sync to claim holder
|
||||
let command = Command::Account(AccountSubcommand::SyncPrivate {});
|
||||
|
||||
wallet::cli::execute_subcommand(command).await.unwrap();
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = wallet_storage
|
||||
.get_account_private(&definition_account_id)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
let new_commitment2 = wallet_storage
|
||||
.get_private_account_commitment(&recipient_account_id_pr)
|
||||
.unwrap();
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, &seq_client).await);
|
||||
|
||||
// Check the status of the account at `recipient_account_id_pr` is the expected after the
|
||||
// execution
|
||||
let recipient_acc_pr = wallet_storage
|
||||
.get_account_private(&recipient_account_id_pr)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc_pr.data[33..].try_into().unwrap()),
|
||||
5
|
||||
);
|
||||
|
||||
// Mint 5 tokens at `recipient_acc_pr`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Mint {
|
||||
definition: make_private_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: Some(make_private_account_input_from_str(
|
||||
&recipient_account_id_pr.to_string(),
|
||||
)),
|
||||
holder_npk: None,
|
||||
holder_ipk: None,
|
||||
amount: 5,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = wallet_storage
|
||||
.get_account_private(&definition_account_id)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 57, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
let new_commitment2 = wallet_storage
|
||||
.get_private_account_commitment(&recipient_account_id_pr)
|
||||
.unwrap();
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, &seq_client).await);
|
||||
|
||||
// Check the status of the account at `recipient_account_id_pr` is the expected after the
|
||||
// execution
|
||||
let recipient_acc = wallet_storage
|
||||
.get_account_private(&recipient_account_id_pr)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
10
|
||||
);
|
||||
|
||||
// Burn 5 tokens at `recipient_acc_pub`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Burn {
|
||||
definition: make_private_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: make_public_account_input_from_str(&recipient_account_id_pub.to_string()),
|
||||
amount: 5,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = wallet_storage
|
||||
.get_account_private(&definition_account_id)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 52, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
// Check the status of the account at `recipient_account_id_pub` is the expected after the
|
||||
// execution
|
||||
let recipient_acc_pub = seq_client
|
||||
.get_account(recipient_account_id_pub.to_string())
|
||||
.await
|
||||
.unwrap()
|
||||
.account;
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc_pub.data[33..].try_into().unwrap()),
|
||||
5
|
||||
);
|
||||
|
||||
// Burn 5 tokens at `recipient_acc_pr`
|
||||
let subcommand = TokenProgramAgnosticSubcommand::Burn {
|
||||
definition: make_private_account_input_from_str(&definition_account_id.to_string()),
|
||||
holder: make_private_account_input_from_str(&recipient_account_id_pr.to_string()),
|
||||
amount: 5,
|
||||
};
|
||||
|
||||
wallet::cli::execute_subcommand(Command::Token(subcommand))
|
||||
.await
|
||||
.unwrap();
|
||||
info!("Waiting for next block creation");
|
||||
tokio::time::sleep(Duration::from_secs(TIME_TO_WAIT_FOR_BLOCK_SECONDS)).await;
|
||||
|
||||
let wallet_config = fetch_config().await.unwrap();
|
||||
let wallet_storage = WalletCore::start_from_config_update_chain(wallet_config)
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
// Check the status of the token definition account is the expected after the execution
|
||||
let definition_acc = wallet_storage
|
||||
.get_account_private(&definition_account_id)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 47, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
let new_commitment2 = wallet_storage
|
||||
.get_private_account_commitment(&recipient_account_id_pr)
|
||||
.unwrap();
|
||||
assert!(verify_commitment_is_in_state(new_commitment2, &seq_client).await);
|
||||
|
||||
// Check the status of the account at `recipient_account_id_pr` is the expected after the
|
||||
// execution
|
||||
let recipient_acc = wallet_storage
|
||||
.get_account_private(&recipient_account_id_pr)
|
||||
.unwrap();
|
||||
|
||||
assert_eq!(
|
||||
u128::from_le_bytes(recipient_acc.data[33..].try_into().unwrap()),
|
||||
5
|
||||
);
|
||||
}
|
||||
|
||||
/// This test creates a new private token using the token program. All accounts are private
|
||||
@@ -754,17 +1317,20 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
|
||||
assert_eq!(definition_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) || metadata id (32
|
||||
// bytes)]
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
assert_eq!(supply_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// The data of a token holding account has the following layout:
|
||||
// [ 0x01 || definition id (32 bytes) || balance (little endian 16 bytes) ]
|
||||
assert_eq!(
|
||||
supply_acc.data.as_ref(),
|
||||
&[
|
||||
@@ -844,11 +1410,14 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
|
||||
assert_eq!(definition_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) || metadata id (32
|
||||
// bytes)]
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
@@ -980,11 +1549,14 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
|
||||
assert_eq!(definition_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) || metadata id (32
|
||||
// bytes)]
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
@@ -1116,11 +1688,14 @@ pub fn prepare_function_map() -> HashMap<String, TestFunction> {
|
||||
|
||||
assert_eq!(definition_acc.program_owner, Program::token().id());
|
||||
// The data of a token definition account has the following layout:
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) ]
|
||||
// [ 0x00 || name (6 bytes) || total supply (little endian 16 bytes) || metadata id (32
|
||||
// bytes)]
|
||||
assert_eq!(
|
||||
definition_acc.data.as_ref(),
|
||||
&[
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
|
||||
0, 65, 32, 78, 65, 77, 69, 37, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
|
||||
0, 0
|
||||
]
|
||||
);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user