mirror of
https://github.com/logos-blockchain/lssa.git
synced 2026-01-04 06:13:10 +00:00
test: add unit test for private multi chain calls
This commit is contained in:
parent
aabd39b00a
commit
5c965deb56
34
Cargo.lock
generated
34
Cargo.lock
generated
@ -2670,6 +2670,7 @@ dependencies = [
|
|||||||
"secp256k1",
|
"secp256k1",
|
||||||
"serde",
|
"serde",
|
||||||
"sha2",
|
"sha2",
|
||||||
|
"test-case",
|
||||||
"test_program_methods",
|
"test_program_methods",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
]
|
]
|
||||||
@ -4310,6 +4311,39 @@ dependencies = [
|
|||||||
"winapi-util",
|
"winapi-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-case"
|
||||||
|
version = "3.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "eb2550dd13afcd286853192af8601920d959b14c401fcece38071d53bf0768a8"
|
||||||
|
dependencies = [
|
||||||
|
"test-case-macros",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-case-core"
|
||||||
|
version = "3.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "adcb7fd841cd518e279be3d5a3eb0636409487998a4aff22f3de87b81e88384f"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.111",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "test-case-macros"
|
||||||
|
version = "3.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "5c89e72a01ed4c579669add59014b9a524d609c0c88c6a585ce37485879f6ffb"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.111",
|
||||||
|
"test-case-core",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "test_program_methods"
|
name = "test_program_methods"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
|
|||||||
@ -24,8 +24,9 @@ risc0-binfmt = "3.0.2"
|
|||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
test_program_methods.workspace = true
|
test_program_methods.workspace = true
|
||||||
hex-literal = "1.0.0"
|
|
||||||
env_logger.workspace = true
|
env_logger.workspace = true
|
||||||
|
hex-literal = "1.0.0"
|
||||||
|
test-case = "3.3.1"
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
default = []
|
default = []
|
||||||
|
|||||||
@ -3941,8 +3941,9 @@ pub mod tests {
|
|||||||
assert_eq!(to_post, expected_to_post);
|
assert_eq!(to_post, expected_to_post);
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test_case::test_case(1; "single call")]
|
||||||
fn test_private_chained_call() {
|
#[test_case::test_case(2; "two calls")]
|
||||||
|
fn test_private_chained_call(number_of_calls: u32) {
|
||||||
// Arrange
|
// Arrange
|
||||||
let chain_caller = Program::chain_caller();
|
let chain_caller = Program::chain_caller();
|
||||||
let auth_transfers = Program::authenticated_transfer_program();
|
let auth_transfers = Program::authenticated_transfer_program();
|
||||||
@ -3978,7 +3979,7 @@ pub mod tests {
|
|||||||
let instruction: (u128, ProgramId, u32, Option<PdaSeed>) = (
|
let instruction: (u128, ProgramId, u32, Option<PdaSeed>) = (
|
||||||
amount,
|
amount,
|
||||||
Program::authenticated_transfer_program().id(),
|
Program::authenticated_transfer_program().id(),
|
||||||
1,
|
number_of_calls,
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -3999,14 +4000,14 @@ pub mod tests {
|
|||||||
let to_new_nonce = 0xdeadbeef2;
|
let to_new_nonce = 0xdeadbeef2;
|
||||||
|
|
||||||
let from_expected_post = Account {
|
let from_expected_post = Account {
|
||||||
balance: initial_balance - amount,
|
balance: initial_balance - number_of_calls as u128 * amount,
|
||||||
nonce: from_new_nonce,
|
nonce: from_new_nonce,
|
||||||
..from_account.account.clone()
|
..from_account.account.clone()
|
||||||
};
|
};
|
||||||
let from_expected_commitment = Commitment::new(&from_keys.npk(), &from_expected_post);
|
let from_expected_commitment = Commitment::new(&from_keys.npk(), &from_expected_post);
|
||||||
|
|
||||||
let to_expected_post = Account {
|
let to_expected_post = Account {
|
||||||
balance: amount,
|
balance: number_of_calls as u128 * amount,
|
||||||
nonce: to_new_nonce,
|
nonce: to_new_nonce,
|
||||||
..to_account.account.clone()
|
..to_account.account.clone()
|
||||||
};
|
};
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user