mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-04 06:13: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
|
cd integration_tests
|
||||||
export NSSA_WALLET_HOME_DIR=$(pwd)/configs/debug/wallet/
|
export NSSA_WALLET_HOME_DIR=$(pwd)/configs/debug/wallet/
|
||||||
export RUST_LOG=info
|
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": {
|
"account": {
|
||||||
"program_owner": [
|
"program_owner": [
|
||||||
2357946808,
|
0,
|
||||||
1250390931,
|
0,
|
||||||
1946783766,
|
0,
|
||||||
2395930623,
|
0,
|
||||||
2256469211,
|
0,
|
||||||
3226409911,
|
0,
|
||||||
3251831113,
|
0,
|
||||||
2343238083
|
0
|
||||||
],
|
],
|
||||||
"balance": 10000,
|
"balance": 10000,
|
||||||
"data": [],
|
"data": [],
|
||||||
@ -105,14 +105,14 @@
|
|||||||
],
|
],
|
||||||
"account": {
|
"account": {
|
||||||
"program_owner": [
|
"program_owner": [
|
||||||
2357946808,
|
0,
|
||||||
1250390931,
|
0,
|
||||||
1946783766,
|
0,
|
||||||
2395930623,
|
0,
|
||||||
2256469211,
|
0,
|
||||||
3226409911,
|
0,
|
||||||
3251831113,
|
0,
|
||||||
2343238083
|
0
|
||||||
],
|
],
|
||||||
"balance": 20000,
|
"balance": 20000,
|
||||||
"data": [],
|
"data": [],
|
||||||
|
|||||||
@ -90,14 +90,14 @@
|
|||||||
"address": "6ffe0893c4b2c956fdb769b11fe4e3b2dd36ac4bd0ad90c810844051747c8c04",
|
"address": "6ffe0893c4b2c956fdb769b11fe4e3b2dd36ac4bd0ad90c810844051747c8c04",
|
||||||
"account": {
|
"account": {
|
||||||
"program_owner": [
|
"program_owner": [
|
||||||
2357946808,
|
0,
|
||||||
1250390931,
|
0,
|
||||||
1946783766,
|
0,
|
||||||
2395930623,
|
0,
|
||||||
2256469211,
|
0,
|
||||||
3226409911,
|
0,
|
||||||
3251831113,
|
0,
|
||||||
2343238083
|
0
|
||||||
],
|
],
|
||||||
"balance": 10000,
|
"balance": 10000,
|
||||||
"data": [],
|
"data": [],
|
||||||
@ -319,14 +319,14 @@
|
|||||||
"address": "4ee9de60e33da96fd72929f1485fb365bcc9c1634dd44e4ba55b1ab96692674b",
|
"address": "4ee9de60e33da96fd72929f1485fb365bcc9c1634dd44e4ba55b1ab96692674b",
|
||||||
"account": {
|
"account": {
|
||||||
"program_owner": [
|
"program_owner": [
|
||||||
2357946808,
|
0,
|
||||||
1250390931,
|
0,
|
||||||
1946783766,
|
0,
|
||||||
2395930623,
|
0,
|
||||||
2256469211,
|
0,
|
||||||
3226409911,
|
0,
|
||||||
3251831113,
|
0,
|
||||||
2343238083
|
0
|
||||||
],
|
],
|
||||||
"balance": 20000,
|
"balance": 20000,
|
||||||
"data": [],
|
"data": [],
|
||||||
|
|||||||
@ -407,6 +407,7 @@ pub async fn test_success_private_transfer_to_another_foreign_account() {
|
|||||||
.get_private_account_mut(&from)
|
.get_private_account_mut(&from)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
from_acc.1.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||||
from_acc.1.balance -= 100;
|
from_acc.1.balance -= 100;
|
||||||
from_acc.1.nonce += 1;
|
from_acc.1.nonce += 1;
|
||||||
|
|
||||||
@ -415,10 +416,7 @@ pub async fn test_success_private_transfer_to_another_foreign_account() {
|
|||||||
|
|
||||||
let new_commitment2 = {
|
let new_commitment2 = {
|
||||||
let to_acc = nssa_core::account::Account {
|
let to_acc = nssa_core::account::Account {
|
||||||
program_owner: [
|
program_owner: nssa::program::Program::authenticated_transfer_program().id(),
|
||||||
1793544791, 852173979, 3315478100, 4158236927, 146723505, 3793635251, 999304864,
|
|
||||||
2535706995,
|
|
||||||
],
|
|
||||||
balance: 100,
|
balance: 100,
|
||||||
data: vec![],
|
data: vec![],
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
@ -471,6 +469,7 @@ pub async fn test_success_deshielded_transfer_to_another_account() {
|
|||||||
.get_private_account_mut(&from)
|
.get_private_account_mut(&from)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
from_acc.1.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||||
from_acc.1.balance -= 100;
|
from_acc.1.balance -= 100;
|
||||||
from_acc.1.nonce += 1;
|
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)
|
.get_private_account_mut(&to)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
|
to_acc.1.program_owner = nssa::program::Program::authenticated_transfer_program().id();
|
||||||
to_acc.1.balance += 100;
|
to_acc.1.balance += 100;
|
||||||
to_acc.1.nonce += 1;
|
to_acc.1.nonce += 1;
|
||||||
|
|
||||||
@ -568,10 +568,7 @@ pub async fn test_success_shielded_transfer_to_another_foreign_account() {
|
|||||||
|
|
||||||
let new_commitment2 = {
|
let new_commitment2 = {
|
||||||
let to_acc = nssa_core::account::Account {
|
let to_acc = nssa_core::account::Account {
|
||||||
program_owner: [
|
program_owner: nssa::program::Program::authenticated_transfer_program().id(),
|
||||||
1793544791, 852173979, 3315478100, 4158236927, 146723505, 3793635251, 999304864,
|
|
||||||
2535706995,
|
|
||||||
],
|
|
||||||
balance: 100,
|
balance: 100,
|
||||||
data: vec![],
|
data: vec![],
|
||||||
nonce: 1,
|
nonce: 1,
|
||||||
@ -687,6 +684,10 @@ pub async fn main_tests_runner() -> Result<()> {
|
|||||||
home_dir,
|
home_dir,
|
||||||
test_success_shielded_transfer_to_another_owned_account
|
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");
|
anyhow::bail!("Unknown test name");
|
||||||
|
|||||||
@ -53,30 +53,22 @@ pub fn validate_execution(
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("HELLO 1");
|
|
||||||
|
|
||||||
for (pre, post) in pre_states.iter().zip(post_states) {
|
for (pre, post) in pre_states.iter().zip(post_states) {
|
||||||
// 2. Nonce must remain unchanged
|
// 2. Nonce must remain unchanged
|
||||||
if pre.account.nonce != post.nonce {
|
if pre.account.nonce != post.nonce {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("HELLO 2");
|
|
||||||
|
|
||||||
// 3. Ownership change only allowed from default accounts
|
// 3. Ownership change only allowed from default accounts
|
||||||
if pre.account.program_owner != post.program_owner && pre.account != Account::default() {
|
if pre.account.program_owner != post.program_owner && pre.account != Account::default() {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("HELLO 3");
|
|
||||||
|
|
||||||
// 4. Decreasing balance only allowed if owned by executing program
|
// 4. Decreasing balance only allowed if owned by executing program
|
||||||
if post.balance < pre.account.balance && pre.account.program_owner != executing_program_id {
|
if post.balance < pre.account.balance && pre.account.program_owner != executing_program_id {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("HELLO 4");
|
|
||||||
|
|
||||||
// 5. Data changes only allowed if owned by executing program
|
// 5. Data changes only allowed if owned by executing program
|
||||||
if pre.account.data != post.data
|
if pre.account.data != post.data
|
||||||
&& (executing_program_id != pre.account.program_owner
|
&& (executing_program_id != pre.account.program_owner
|
||||||
@ -84,8 +76,6 @@ pub fn validate_execution(
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
println!("HELLO 5");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 6. Total balance is preserved
|
// 6. Total balance is preserved
|
||||||
|
|||||||
@ -12,10 +12,10 @@ impl WalletCore {
|
|||||||
to: Address,
|
to: Address,
|
||||||
balance_to_move: u128,
|
balance_to_move: u128,
|
||||||
) -> Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
) -> 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 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);
|
return Err(ExecutionFailureKind::KeyNotFoundError);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -25,8 +25,11 @@ impl WalletCore {
|
|||||||
|
|
||||||
if from_acc.balance >= balance_to_move {
|
if from_acc.balance >= balance_to_move {
|
||||||
let program = nssa::program::Program::authenticated_transfer_program();
|
let program = nssa::program::Program::authenticated_transfer_program();
|
||||||
|
|
||||||
|
from_acc.program_owner = program.id();
|
||||||
|
|
||||||
let sender_commitment =
|
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 {
|
let sender_pre = nssa_core::account::AccountWithMetadata {
|
||||||
account: from_acc.clone(),
|
account: from_acc.clone(),
|
||||||
|
|||||||
@ -12,9 +12,9 @@ impl WalletCore {
|
|||||||
to_ipk: nssa_core::encryption::IncomingViewingPublicKey,
|
to_ipk: nssa_core::encryption::IncomingViewingPublicKey,
|
||||||
balance_to_move: u128,
|
balance_to_move: u128,
|
||||||
) -> Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
) -> 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);
|
return Err(ExecutionFailureKind::KeyNotFoundError);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -22,8 +22,11 @@ impl WalletCore {
|
|||||||
|
|
||||||
if from_acc.balance >= balance_to_move {
|
if from_acc.balance >= balance_to_move {
|
||||||
let program = nssa::program::Program::authenticated_transfer_program();
|
let program = nssa::program::Program::authenticated_transfer_program();
|
||||||
|
|
||||||
|
from_acc.program_owner = program.id();
|
||||||
|
|
||||||
let sender_commitment =
|
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 {
|
let sender_pre = nssa_core::account::AccountWithMetadata {
|
||||||
account: from_acc.clone(),
|
account: from_acc.clone(),
|
||||||
@ -127,11 +130,8 @@ impl WalletCore {
|
|||||||
if from_acc.balance >= balance_to_move {
|
if from_acc.balance >= balance_to_move {
|
||||||
let program = nssa::program::Program::authenticated_transfer_program();
|
let program = nssa::program::Program::authenticated_transfer_program();
|
||||||
|
|
||||||
//Kind of hacky solution
|
from_acc.program_owner = program.id();
|
||||||
//The issue is that we don't have deterministic builds
|
to_acc.program_owner = program.id();
|
||||||
//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();
|
|
||||||
|
|
||||||
let sender_commitment =
|
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);
|
||||||
|
|||||||
@ -13,13 +13,13 @@ impl WalletCore {
|
|||||||
balance_to_move: u128,
|
balance_to_move: u128,
|
||||||
) -> Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
) -> Result<(SendTxResponse, nssa_core::SharedSecretKey), ExecutionFailureKind> {
|
||||||
let from_data = self.get_account(from).await;
|
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 {
|
let Ok(from_acc) = from_data else {
|
||||||
return Err(ExecutionFailureKind::KeyNotFoundError);
|
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);
|
return Err(ExecutionFailureKind::KeyNotFoundError);
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -29,8 +29,10 @@ impl WalletCore {
|
|||||||
if from_acc.balance >= balance_to_move {
|
if from_acc.balance >= balance_to_move {
|
||||||
let program = nssa::program::Program::authenticated_transfer_program();
|
let program = nssa::program::Program::authenticated_transfer_program();
|
||||||
|
|
||||||
|
to_acc.program_owner = program.id();
|
||||||
|
|
||||||
let receiver_commitment =
|
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 {
|
let sender_pre = nssa_core::account::AccountWithMetadata {
|
||||||
account: from_acc.clone(),
|
account: from_acc.clone(),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user