mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-02 13:23:10 +00:00
fix: tests run 1
This commit is contained in:
parent
21e68b6b4a
commit
0e5087ca8f
@ -8,4 +8,7 @@ RISC0_DEV_MODE=1 cargo test --release
|
||||
cd integration_tests
|
||||
export NSSA_WALLET_HOME_DIR=$(pwd)/configs/debug/wallet/
|
||||
export RUST_LOG=info
|
||||
RISC0_DEV_MODE=1 cargo run $(pwd)/configs/debug test_success_private_transfer_to_another_owned_account
|
||||
echo "Try test valid proof at least once"
|
||||
cargo run $(pwd)/configs/debug test_success_private_transfer_to_another_owned_account
|
||||
echo "Continuing in dev mode"
|
||||
RISC0_DEV_MODE=1 cargo run $(pwd)/configs/debug all
|
||||
|
||||
@ -54,14 +54,14 @@
|
||||
],
|
||||
"account": {
|
||||
"program_owner": [
|
||||
2357946808,
|
||||
1250390931,
|
||||
1946783766,
|
||||
2395930623,
|
||||
2256469211,
|
||||
3226409911,
|
||||
3251831113,
|
||||
2343238083
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"balance": 10000,
|
||||
"data": [],
|
||||
@ -105,14 +105,14 @@
|
||||
],
|
||||
"account": {
|
||||
"program_owner": [
|
||||
2357946808,
|
||||
1250390931,
|
||||
1946783766,
|
||||
2395930623,
|
||||
2256469211,
|
||||
3226409911,
|
||||
3251831113,
|
||||
2343238083
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"balance": 20000,
|
||||
"data": [],
|
||||
|
||||
@ -90,14 +90,14 @@
|
||||
"address": "6ffe0893c4b2c956fdb769b11fe4e3b2dd36ac4bd0ad90c810844051747c8c04",
|
||||
"account": {
|
||||
"program_owner": [
|
||||
2357946808,
|
||||
1250390931,
|
||||
1946783766,
|
||||
2395930623,
|
||||
2256469211,
|
||||
3226409911,
|
||||
3251831113,
|
||||
2343238083
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"balance": 10000,
|
||||
"data": [],
|
||||
@ -319,14 +319,14 @@
|
||||
"address": "4ee9de60e33da96fd72929f1485fb365bcc9c1634dd44e4ba55b1ab96692674b",
|
||||
"account": {
|
||||
"program_owner": [
|
||||
2357946808,
|
||||
1250390931,
|
||||
1946783766,
|
||||
2395930623,
|
||||
2256469211,
|
||||
3226409911,
|
||||
3251831113,
|
||||
2343238083
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0
|
||||
],
|
||||
"balance": 20000,
|
||||
"data": [],
|
||||
|
||||
@ -407,6 +407,7 @@ pub async fn test_success_private_transfer_to_another_foreign_account() {
|
||||
.get_private_account_mut(&from)
|
||||
.unwrap();
|
||||
|
||||
from_acc.1.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||
from_acc.1.balance -= 100;
|
||||
from_acc.1.nonce += 1;
|
||||
|
||||
@ -415,10 +416,7 @@ pub async fn test_success_private_transfer_to_another_foreign_account() {
|
||||
|
||||
let new_commitment2 = {
|
||||
let to_acc = nssa_core::account::Account {
|
||||
program_owner: [
|
||||
1793544791, 852173979, 3315478100, 4158236927, 146723505, 3793635251, 999304864,
|
||||
2535706995,
|
||||
],
|
||||
program_owner: nssa::program::Program::authenticated_transfer_program().id(),
|
||||
balance: 100,
|
||||
data: vec![],
|
||||
nonce: 1,
|
||||
@ -471,6 +469,7 @@ pub async fn test_success_deshielded_transfer_to_another_account() {
|
||||
.get_private_account_mut(&from)
|
||||
.unwrap();
|
||||
|
||||
from_acc.1.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||
from_acc.1.balance -= 100;
|
||||
from_acc.1.nonce += 1;
|
||||
|
||||
@ -521,6 +520,7 @@ pub async fn test_success_shielded_transfer_to_another_owned_account() {
|
||||
.get_private_account_mut(&to)
|
||||
.unwrap();
|
||||
|
||||
to_acc.1.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||
to_acc.1.balance += 100;
|
||||
to_acc.1.nonce += 1;
|
||||
|
||||
@ -568,10 +568,7 @@ pub async fn test_success_shielded_transfer_to_another_foreign_account() {
|
||||
|
||||
let new_commitment2 = {
|
||||
let to_acc = nssa_core::account::Account {
|
||||
program_owner: [
|
||||
1793544791, 852173979, 3315478100, 4158236927, 146723505, 3793635251, 999304864,
|
||||
2535706995,
|
||||
],
|
||||
program_owner: nssa::program::Program::authenticated_transfer_program().id(),
|
||||
balance: 100,
|
||||
data: vec![],
|
||||
nonce: 1,
|
||||
@ -687,6 +684,10 @@ pub async fn main_tests_runner() -> Result<()> {
|
||||
home_dir,
|
||||
test_success_shielded_transfer_to_another_owned_account
|
||||
);
|
||||
test_cleanup_wrap!(
|
||||
home_dir,
|
||||
test_success_shielded_transfer_to_another_foreign_account
|
||||
);
|
||||
}
|
||||
_ => {
|
||||
anyhow::bail!("Unknown test name");
|
||||
|
||||
@ -53,30 +53,22 @@ pub fn validate_execution(
|
||||
return false;
|
||||
}
|
||||
|
||||
println!("HELLO 1");
|
||||
|
||||
for (pre, post) in pre_states.iter().zip(post_states) {
|
||||
// 2. Nonce must remain unchanged
|
||||
if pre.account.nonce != post.nonce {
|
||||
return false;
|
||||
}
|
||||
|
||||
println!("HELLO 2");
|
||||
|
||||
// 3. Ownership change only allowed from default accounts
|
||||
if pre.account.program_owner != post.program_owner && pre.account != Account::default() {
|
||||
return false;
|
||||
}
|
||||
|
||||
println!("HELLO 3");
|
||||
|
||||
// 4. Decreasing balance only allowed if owned by executing program
|
||||
if post.balance < pre.account.balance && pre.account.program_owner != executing_program_id {
|
||||
return false;
|
||||
}
|
||||
|
||||
println!("HELLO 4");
|
||||
|
||||
// 5. Data changes only allowed if owned by executing program
|
||||
if pre.account.data != post.data
|
||||
&& (executing_program_id != pre.account.program_owner
|
||||
@ -84,8 +76,6 @@ pub fn validate_execution(
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
println!("HELLO 5");
|
||||
}
|
||||
|
||||
// 6. Total balance is preserved
|
||||
|
||||
@ -12,10 +12,10 @@ impl WalletCore {
|
||||
to: Address,
|
||||
balance_to_move: u128,
|
||||
) -> Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
||||
let from_data = self.storage.user_data.get_private_account(&from);
|
||||
let from_data = self.storage.user_data.get_private_account(&from).cloned();
|
||||
let to_data = self.get_account(to).await;
|
||||
|
||||
let Some((from_keys, from_acc)) = from_data else {
|
||||
let Some((from_keys, mut from_acc)) = from_data else {
|
||||
return Err(ExecutionFailureKind::KeyNotFoundError);
|
||||
};
|
||||
|
||||
@ -25,8 +25,11 @@ impl WalletCore {
|
||||
|
||||
if from_acc.balance >= balance_to_move {
|
||||
let program = nssa::program::Program::authenticated_transfer_program();
|
||||
|
||||
from_acc.program_owner = program.id();
|
||||
|
||||
let sender_commitment =
|
||||
nssa_core::Commitment::new(&from_keys.nullifer_public_key, from_acc);
|
||||
nssa_core::Commitment::new(&from_keys.nullifer_public_key, &from_acc);
|
||||
|
||||
let sender_pre = nssa_core::account::AccountWithMetadata {
|
||||
account: from_acc.clone(),
|
||||
|
||||
@ -12,9 +12,9 @@ impl WalletCore {
|
||||
to_ipk: nssa_core::encryption::IncomingViewingPublicKey,
|
||||
balance_to_move: u128,
|
||||
) -> Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
||||
let from_data = self.storage.user_data.get_private_account(&from);
|
||||
let from_data = self.storage.user_data.get_private_account(&from).cloned();
|
||||
|
||||
let Some((from_keys, from_acc)) = from_data else {
|
||||
let Some((from_keys, mut from_acc)) = from_data else {
|
||||
return Err(ExecutionFailureKind::KeyNotFoundError);
|
||||
};
|
||||
|
||||
@ -22,8 +22,11 @@ impl WalletCore {
|
||||
|
||||
if from_acc.balance >= balance_to_move {
|
||||
let program = nssa::program::Program::authenticated_transfer_program();
|
||||
|
||||
from_acc.program_owner = program.id();
|
||||
|
||||
let sender_commitment =
|
||||
nssa_core::Commitment::new(&from_keys.nullifer_public_key, from_acc);
|
||||
nssa_core::Commitment::new(&from_keys.nullifer_public_key, &from_acc);
|
||||
|
||||
let sender_pre = nssa_core::account::AccountWithMetadata {
|
||||
account: from_acc.clone(),
|
||||
@ -127,11 +130,8 @@ impl WalletCore {
|
||||
if from_acc.balance >= balance_to_move {
|
||||
let program = nssa::program::Program::authenticated_transfer_program();
|
||||
|
||||
//Kind of hacky solution
|
||||
//The issue is that we don't have deterministic builds
|
||||
//and native_token_transfer at different machine may be different
|
||||
from_acc.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||
to_acc.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||
from_acc.program_owner = program.id();
|
||||
to_acc.program_owner = program.id();
|
||||
|
||||
let sender_commitment =
|
||||
nssa_core::Commitment::new(&from_keys.nullifer_public_key, &from_acc);
|
||||
|
||||
@ -13,13 +13,13 @@ impl WalletCore {
|
||||
balance_to_move: u128,
|
||||
) -> Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
||||
let from_data = self.get_account(from).await;
|
||||
let to_data = self.storage.user_data.get_private_account(&to);
|
||||
let to_data = self.storage.user_data.get_private_account(&to).cloned();
|
||||
|
||||
let Ok(from_acc) = from_data else {
|
||||
return Err(ExecutionFailureKind::KeyNotFoundError);
|
||||
};
|
||||
|
||||
let Some((to_keys, to_acc)) = to_data else {
|
||||
let Some((to_keys, mut to_acc)) = to_data else {
|
||||
return Err(ExecutionFailureKind::KeyNotFoundError);
|
||||
};
|
||||
|
||||
@ -29,8 +29,10 @@ impl WalletCore {
|
||||
if from_acc.balance >= balance_to_move {
|
||||
let program = nssa::program::Program::authenticated_transfer_program();
|
||||
|
||||
to_acc.program_owner = program.id();
|
||||
|
||||
let receiver_commitment =
|
||||
nssa_core::Commitment::new(&to_keys.nullifer_public_key, to_acc);
|
||||
nssa_core::Commitment::new(&to_keys.nullifer_public_key, &to_acc);
|
||||
|
||||
let sender_pre = nssa_core::account::AccountWithMetadata {
|
||||
account: from_acc.clone(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user