@@ -1943,28 +1943,23 @@ def test_transaction_witness_set_no_redeemers(chain_context):
1943
1943
assert witness_set .redeemer is None
1944
1944
1945
1945
1946
- def test_minting_and_burning_zero_quantity_assets (chain_context ):
1946
+ def test_burning_all_assets_under_single_policy (chain_context ):
1947
1947
"""
1948
- Test the minting and burning of multiple assets using the TransactionBuilder.
1948
+ Test burning all assets under a single policy with TransactionBuilder.
1949
1949
1950
- This test ensures that assets are correctly minted and burned under the same policy ID.
1951
- Specifically, it verifies that after burning certain assets (AssetName1, AssetName2, and AssetName3),
1952
- they are removed from the multi-asset map, and the correct amount of the minted asset (AssetName4) remains.
1950
+ This test ensures that burning multiple assets (AssetName1, AssetName2, AssetName3, AssetName4)
1951
+ under policy_id_1 removes them from the multi-asset map.
1953
1952
1954
1953
Steps:
1955
- 1. Define a policy ID and several assets (AssetName1, AssetName2, AssetName3, and AssetName4) using the AssetName class.
1956
- 2. Simulate minting of 2 units of AssetName4 and burning 1 unit each of AssetName1, AssetName2, and AssetName3.
1957
- 3. Add corresponding UTXOs for each asset as inputs.
1958
- 4. Add minting instructions to the TransactionBuilder.
1959
- 5. Build the transaction and verify that the burnt assets are removed from the multi-asset map.
1960
- 6. Check that the correct quantity of AssetName4 is minted and included in the transaction outputs.
1954
+ 1. Define assets under policy_id_1 and simulate burning 1 unit of each.
1955
+ 2. Add UTXOs for the assets and burning instructions.
1956
+ 3. Build the transaction and verify that all burned assets are removed.
1961
1957
1962
1958
Args:
1963
- chain_context: The blockchain context used for constructing and verifying the transaction .
1959
+ chain_context: The blockchain context.
1964
1960
1965
1961
Assertions:
1966
- - AssetName1, AssetName2, and AssetName3 are not present in the multi-asset map after burning.
1967
- - AssetName4 has exactly 2 units minted.
1962
+ - AssetName1, AssetName2, AssetName3, and AssetName4 are removed after burning.
1968
1963
"""
1969
1964
tx_builder = TransactionBuilder (chain_context )
1970
1965
@@ -1986,43 +1981,48 @@ def test_minting_and_burning_zero_quantity_assets(chain_context):
1986
1981
["d6cbe6cadecd3f89b60e08e68e5e6c7d72d730aaa1ad21431590f7e6643438ef" , 3 ]
1987
1982
)
1988
1983
# Define a policy ID and asset names
1989
- policy_id = plutus_script_hash (PlutusV1Script (b"dummy script" ))
1990
- multi_asset1 = MultiAsset .from_primitive ({policy_id .payload : {b"AssetName1" : 1 }})
1991
- multi_asset2 = MultiAsset .from_primitive ({policy_id .payload : {b"AssetName2" : 2 }})
1992
- multi_asset3 = MultiAsset .from_primitive ({policy_id .payload : {b"AssetName3" : 1 }})
1993
- multi_asset4 = MultiAsset .from_primitive ({policy_id .payload : {b"AssetName4" : 3 }})
1984
+ policy_id_1 = plutus_script_hash (PlutusV1Script (b"dummy script1" ))
1985
+ multi_asset1 = MultiAsset .from_primitive ({policy_id_1 .payload : {b"AssetName1" : 1 }})
1986
+ multi_asset2 = MultiAsset .from_primitive ({policy_id_1 .payload : {b"AssetName2" : 1 }})
1987
+ multi_asset3 = MultiAsset .from_primitive (
1988
+ {
1989
+ policy_id_1 .payload : {b"AssetName3" : 1 },
1990
+ }
1991
+ )
1992
+ multi_asset4 = MultiAsset .from_primitive (
1993
+ {
1994
+ policy_id_1 .payload : {b"AssetName4" : 1 },
1995
+ }
1996
+ )
1994
1997
1995
1998
# Simulate minting and burning of assets
1996
1999
mint = MultiAsset .from_primitive (
1997
2000
{
1998
- policy_id .payload : {
2001
+ policy_id_1 .payload : {
1999
2002
b"AssetName1" : - 1 ,
2000
- b"AssetName2" : - 2 ,
2003
+ b"AssetName2" : - 1 ,
2001
2004
b"AssetName3" : - 1 ,
2002
- b"AssetName4" : 2 ,
2005
+ b"AssetName4" : - 1 ,
2003
2006
}
2004
2007
}
2005
2008
)
2006
2009
2007
2010
# Set UTXO for the inputs
2008
2011
utxo1 = UTxO (
2009
- tx_in1 , TransactionOutput (Address (policy_id ), Value (10000000 , multi_asset1 ))
2012
+ tx_in1 , TransactionOutput (Address (policy_id_1 ), Value (10000000 , multi_asset1 ))
2010
2013
)
2011
2014
utxo2 = UTxO (
2012
- tx_in2 , TransactionOutput (Address (policy_id ), Value (10000000 , multi_asset2 ))
2015
+ tx_in2 , TransactionOutput (Address (policy_id_1 ), Value (10000000 , multi_asset2 ))
2013
2016
)
2014
2017
utxo3 = UTxO (
2015
- tx_in3 , TransactionOutput (Address (policy_id ), Value (10000000 , multi_asset3 ))
2018
+ tx_in3 , TransactionOutput (Address (policy_id_1 ), Value (10000000 , multi_asset3 ))
2016
2019
)
2017
2020
utxo4 = UTxO (
2018
- tx_in4 , TransactionOutput (Address (policy_id ), Value (10000000 , multi_asset4 ))
2021
+ tx_in4 , TransactionOutput (Address (policy_id_1 ), Value (10000000 , multi_asset4 ))
2019
2022
)
2020
2023
2021
2024
# Add UTXO inputs
2022
- tx_builder .add_input (utxo1 )
2023
- tx_builder .add_input (utxo2 )
2024
- tx_builder .add_input (utxo3 )
2025
- tx_builder .add_input (utxo4 )
2025
+ tx_builder .add_input (utxo1 ).add_input (utxo2 ).add_input (utxo3 ).add_input (utxo4 )
2026
2026
2027
2027
# Add the minting to the builder
2028
2028
tx_builder .mint = mint
@@ -2037,10 +2037,8 @@ def test_minting_and_burning_zero_quantity_assets(chain_context):
2037
2037
for output in tx .outputs :
2038
2038
multi_asset = output .amount .multi_asset
2039
2039
2040
- # Ensure that AssetName1, Node2, and Node3 were burnt (removed)
2041
- assert AssetName (b"AssetName1" ) not in multi_asset .get (policy_id , {})
2042
- assert AssetName (b"AssetName2" ) not in multi_asset .get (policy_id , {})
2043
- assert AssetName (b"AssetName3" ) not in multi_asset .get (policy_id , {})
2044
-
2045
- # Ensure that AssetName4 has 5 units after minting
2046
- assert multi_asset .get (policy_id , {}).get (AssetName (b"AssetName4" ), 0 ) == 5
2040
+ # Ensure that AssetName1, AssetName2, AssetName3 and AssetName4 were burnt (removed)
2041
+ assert AssetName (b"AssetName1" ) not in multi_asset .get (policy_id_1 , {})
2042
+ assert AssetName (b"AssetName2" ) not in multi_asset .get (policy_id_1 , {})
2043
+ assert AssetName (b"AssetName3" ) not in multi_asset .get (policy_id_1 , {})
2044
+ assert AssetName (b"AseetName4" ) not in multi_asset .get (policy_id_1 , {})
0 commit comments