@@ -330,6 +330,45 @@ def test_plutus_v2_ref_script(self):
330330
331331 self .assert_output (taker_address , take_output )
332332
333+ @retry (tries = TEST_RETRIES , backoff = 1.3 , delay = 2 , jitter = (0 , 10 ))
334+ @pytest .mark .post_alonzo
335+ def test_plutus_v2_spend_ref_script (self ):
336+ # ----------- Create a reference script ---------------
337+ with open ("./plutus_scripts/fortytwoV2.plutus" , "r" ) as f :
338+ script_hex = f .read ()
339+ forty_two_script = PlutusV2Script (cbor2 .loads (bytes .fromhex (script_hex )))
340+
341+ giver_address = Address (self .payment_vkey .hash (), network = self .NETWORK )
342+
343+ builder = TransactionBuilder (self .chain_context )
344+ builder .add_input_address (giver_address )
345+ builder .add_output (
346+ TransactionOutput (giver_address , 50000000 , script = forty_two_script )
347+ )
348+
349+ signed_tx = builder .build_and_sign ([self .payment_skey ], giver_address )
350+
351+ print ("############### Transaction created ###############" )
352+ print (signed_tx )
353+ print (signed_tx .to_cbor_hex ())
354+ print ("############### Submitting transaction ###############" )
355+ self .chain_context .submit_tx (signed_tx )
356+ time .sleep (6 )
357+
358+ # ----------- Spend script utxo ---------------
359+ utxo_to_spend = UTxO (
360+ TransactionInput (signed_tx .id , 0 ), signed_tx .transaction_body .outputs [0 ]
361+ )
362+
363+ builder = TransactionBuilder (self .chain_context )
364+ builder .add_input (utxo_to_spend )
365+ signed_tx = builder .build_and_sign ([self .payment_skey ], giver_address )
366+ print ("############### Transaction created ###############" )
367+ print (signed_tx )
368+ print (signed_tx .to_cbor_hex ())
369+ print ("############### Submitting transaction ###############" )
370+ self .chain_context .submit_tx (signed_tx )
371+
333372 @retry (tries = TEST_RETRIES , backoff = 1.3 , delay = 2 , jitter = (0 , 10 ))
334373 @pytest .mark .post_alonzo
335374 def test_transaction_chaining (self ):
0 commit comments