From 0e285c9c7172a4ab74c089d5f397d8d779263885 Mon Sep 17 00:00:00 2001 From: SIDANWhatever Date: Sun, 26 Nov 2023 21:49:35 +0800 Subject: [PATCH] feat: adding burn test suites for ref tokens --- validators/content_registry_ref_token.ak | 56 ++++++++++++++++++++++ validators/ownership_registry_ref_token.ak | 56 ++++++++++++++++++++++ 2 files changed, 112 insertions(+) diff --git a/validators/content_registry_ref_token.ak b/validators/content_registry_ref_token.ak index 85b5a11..6295f7a 100644 --- a/validators/content_registry_ref_token.ak +++ b/validators/content_registry_ref_token.ak @@ -208,3 +208,59 @@ test fail_mint_with_unclean_registry_value() { let ctx = ScriptContext { purpose: Mint(mock_policy_id()), transaction: tx } !content_registry_ref_token(mock_policy_id(), redeemer, ctx) } + +test success_burn() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value(from_asset(policy_id, "", -1)), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + content_registry_ref_token(mock_policy_id(), redeemer, ctx) +} + +test success_burn_with_other_minting() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value( + from_asset(policy_id, "", -1) |> add(mock_policy_id_2(), "", 1), + ), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + content_registry_ref_token(mock_policy_id(), redeemer, ctx) +} + +test fail_burn_with_mint() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value(from_asset(policy_id, "", 1)), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + !content_registry_ref_token(mock_policy_id(), redeemer, ctx) +} + +test fail_burn_with_mix() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value( + from_asset(policy_id, "", -1) |> add(policy_id, "1", 1), + ), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + !content_registry_ref_token(mock_policy_id(), redeemer, ctx) +} diff --git a/validators/ownership_registry_ref_token.ak b/validators/ownership_registry_ref_token.ak index 0b8e8bf..498d1d5 100644 --- a/validators/ownership_registry_ref_token.ak +++ b/validators/ownership_registry_ref_token.ak @@ -208,3 +208,59 @@ test fail_mint_with_unclean_registry_value() { let ctx = ScriptContext { purpose: Mint(mock_policy_id()), transaction: tx } !ownership_registry_ref_token(mock_policy_id(), redeemer, ctx) } + +test success_burn() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value(from_asset(policy_id, "", -1)), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + ownership_registry_ref_token(mock_policy_id(), redeemer, ctx) +} + +test success_burn_with_other_minting() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value( + from_asset(policy_id, "", -1) |> add(mock_policy_id_2(), "", 1), + ), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + ownership_registry_ref_token(mock_policy_id(), redeemer, ctx) +} + +test fail_burn_with_mint() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value(from_asset(policy_id, "", 1)), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + !ownership_registry_ref_token(mock_policy_id(), redeemer, ctx) +} + +test fail_burn_with_mix() { + let redeemer = RBurn + let policy_id = mock_policy_id() + + let tx = + Transaction { + ..placeholder(), + mint: to_minted_value( + from_asset(policy_id, "", -1) |> add(policy_id, "1", 1), + ), + } + let ctx = ScriptContext { purpose: Mint(policy_id), transaction: tx } + !ownership_registry_ref_token(mock_policy_id(), redeemer, ctx) +}