From b084dec3634cc6da125c2524703c4b082217e5fa Mon Sep 17 00:00:00 2001 From: Yulong Wu Date: Fri, 22 Nov 2024 11:59:10 +0000 Subject: [PATCH] Add test for clone_proof and drop_named_proof --- radix-engine-tests/tests/system/mod.rs | 1 + radix-engine-tests/tests/system/proof.rs | 76 ++++++++++++++++++++++++ 2 files changed, 77 insertions(+) create mode 100644 radix-engine-tests/tests/system/proof.rs diff --git a/radix-engine-tests/tests/system/mod.rs b/radix-engine-tests/tests/system/mod.rs index 473cce19aa..793a320257 100644 --- a/radix-engine-tests/tests/system/mod.rs +++ b/radix-engine-tests/tests/system/mod.rs @@ -47,6 +47,7 @@ mod module; mod nullification; mod package; mod package_schema; +mod proof; mod proxy; mod recallable; mod reference; diff --git a/radix-engine-tests/tests/system/proof.rs b/radix-engine-tests/tests/system/proof.rs new file mode 100644 index 0000000000..6305af5ff2 --- /dev/null +++ b/radix-engine-tests/tests/system/proof.rs @@ -0,0 +1,76 @@ +use radix_common::prelude::*; +use radix_engine_interface::types::FromPublicKey; +use scrypto_test::prelude::*; + +#[test] +fn test_clone_fungible_proof() { + // Arrange + let mut ledger = LedgerSimulatorBuilder::new().build(); + let (public_key, _, account) = ledger.new_allocated_account(); + + // Act + let manifest = ManifestBuilder::new() + .lock_fee_from_faucet() + .create_proof_from_account_of_amount(account, XRD, 1) + .create_proof_from_auth_zone_of_all(XRD, "proof1") + .clone_proof("proof1", "proof2") + .build(); + let receipt = ledger.execute_manifest( + manifest, + vec![NonFungibleGlobalId::from_public_key(&public_key)], + ); + + // Assert + receipt.expect_commit_success(); +} + +#[test] +fn test_clone_non_fungible_proof() { + // Arrange + let mut ledger = LedgerSimulatorBuilder::new().build(); + let (public_key, _, account) = ledger.new_allocated_account(); + let nf_resource = ledger.create_non_fungible_resource(account); + + // Act + let manifest = ManifestBuilder::new() + .lock_fee_from_faucet() + .create_proof_from_account_of_non_fungible( + account, + NonFungibleGlobalId::new(nf_resource, NonFungibleLocalId::integer(1)), + ) + .create_proof_from_auth_zone_of_all(nf_resource, "proof1") + .clone_proof("proof1", "proof2") + .build(); + let receipt = ledger.execute_manifest( + manifest, + vec![NonFungibleGlobalId::from_public_key(&public_key)], + ); + + // Assert + receipt.expect_commit_success(); +} + +#[test] +fn test_drop_named_proofs() { + // Arrange + let mut ledger = LedgerSimulatorBuilder::new().build(); + let (public_key, _, account) = ledger.new_allocated_account(); + let nf_resource = ledger.create_non_fungible_resource(account); + + // Act + let manifest = ManifestBuilder::new() + .lock_fee_from_faucet() + .withdraw_from_account(account, nf_resource, 1) + .take_all_from_worktop(nf_resource, "bucket1") + .create_proof_from_bucket_of_all("bucket1", "proof1") + .drop_named_proofs() + .deposit(account, "bucket1") + .build(); + let receipt = ledger.execute_manifest( + manifest, + vec![NonFungibleGlobalId::from_public_key(&public_key)], + ); + + // Assert + receipt.expect_commit_success(); +}