diff --git a/src/commands/test_orchard_zsa.rs b/src/commands/test_orchard_zsa.rs index 14c484f..cb6af0d 100644 --- a/src/commands/test_orchard_zsa.rs +++ b/src/commands/test_orchard_zsa.rs @@ -28,6 +28,7 @@ impl Runnable for TestOrchardZSACmd { let issuer = wallet.address_for_account(0, External); let alice = wallet.address_for_account(1, External); + let asset_description = b"WETH".to_vec(); prepare_test( config.chain.v6_activation_height, &mut wallet, @@ -36,7 +37,8 @@ impl Runnable for TestOrchardZSACmd { // --------------------- Issue asset --------------------- - let issue_tx = create_issue_transaction(issuer, 1000, b"WETH".into(), &mut wallet); + let issue_tx = + create_issue_transaction(issuer, 1000, asset_description.clone(), &mut wallet); let asset = issue_tx .issue_bundle() @@ -117,6 +119,26 @@ impl Runnable for TestOrchardZSACmd { expected_delta, &mut wallet, ); + + // --------------------- Finalization --------------------- + // TODO - uncomment when finalization is implemented + // let finalization_tx = create_finalization_transaction(asset_description.clone(), &mut wallet); + // mine( + // &mut wallet, + // &mut rpc_client, + // Vec::from([finalization_tx]), + // false, + // ); + // + // let invalid_issue_tx = create_issue_transaction(issuer, 2000, asset_description, &mut wallet); + // mine( + // &mut wallet, + // &mut rpc_client, + // Vec::from([invalid_issue_tx]), + // false, + // ); // TODO expect failure + // + // panic!("Invalid issue transaction was accepted"); } } diff --git a/src/components/transactions.rs b/src/components/transactions.rs index 01660d0..535fbeb 100644 --- a/src/components/transactions.rs +++ b/src/components/transactions.rs @@ -284,6 +284,17 @@ pub fn create_issue_transaction( build_tx(tx) } +/// Create a transaction that issues a new asset +pub fn create_finalization_transaction(asset_desc: Vec, wallet: &mut Wallet) -> Transaction { + info!("Finalize asset"); + let mut tx = create_tx(wallet); + tx.init_issuance_bundle::(wallet.issuance_key(), asset_desc.clone(), None) + .unwrap(); + tx.finalize_asset::(asset_desc.as_slice()) + .unwrap(); + build_tx(tx) +} + /// Convert a block template and a list of transactions into a block proposal pub fn template_into_proposal( block_template: BlockTemplate,