Skip to content

Commit

Permalink
Merge pull request #2011 from radixdlt/test/cover-clone-proof-and-dro…
Browse files Browse the repository at this point in the history
…p-named-proofs

Add test for clone_proof and drop_named_proofs
  • Loading branch information
iamyulong authored Nov 22, 2024
2 parents 6547430 + b084dec commit 5ce7672
Show file tree
Hide file tree
Showing 2 changed files with 77 additions and 0 deletions.
1 change: 1 addition & 0 deletions radix-engine-tests/tests/system/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ mod module;
mod nullification;
mod package;
mod package_schema;
mod proof;
mod proxy;
mod recallable;
mod reference;
Expand Down
76 changes: 76 additions & 0 deletions radix-engine-tests/tests/system/proof.rs
Original file line number Diff line number Diff line change
@@ -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();
}

0 comments on commit 5ce7672

Please sign in to comment.