@@ -51,10 +51,28 @@ fn execute_create_transaction(world: &mut MinotariWorld, recipients: Vec<String>
5151 . args ( & args)
5252 . output ( )
5353 . expect ( "Failed to execute create-unsigned-transaction command" ) ;
54-
5554 world. last_command_exit_code = output. status . code ( ) ;
5655 world. last_command_output = Some ( String :: from_utf8_lossy ( & output. stdout ) . to_string ( ) ) ;
5756 world. last_command_error = Some ( String :: from_utf8_lossy ( & output. stderr ) . to_string ( ) ) ;
57+
58+ // Only assert and parse the output file if the command succeeded
59+ if output. status . success ( ) {
60+ let output_file = world. output_file . as_ref ( ) . expect ( "Output file path not set" ) ;
61+
62+ assert ! (
63+ output_file. exists( ) ,
64+ "Transaction file should exist at {:?}" ,
65+ output_file
66+ ) ;
67+
68+ // Parse the JSON file
69+ let content = std:: fs:: read_to_string ( output_file) . expect ( "Failed to read transaction file" ) ;
70+ let transaction_json: serde_json:: Value =
71+ serde_json:: from_str ( & content) . expect ( "Failed to parse transaction JSON" ) ;
72+
73+ // Store for later verification
74+ world. transaction_data . insert ( "current" . to_string ( ) , transaction_json) ;
75+ }
5876}
5977
6078/// Generate a test Tari address (simplified for testing)
@@ -96,7 +114,6 @@ async fn wallet_has_balance(world: &mut MinotariWorld) {
96114 world. base_nodes . insert ( "BalanceMiner" . to_string ( ) , node) ;
97115 world. seed_nodes . push ( "BalanceMiner" . to_string ( ) ) ;
98116 }
99-
100117 // 2. Mine blocks so the wallet receives coinbase rewards
101118 let spend_key = world. wallet . get_public_spend_key ( ) ;
102119 let view_key = world. wallet . get_public_view_key ( ) ;
@@ -139,7 +156,6 @@ async fn wallet_has_balance(world: &mut MinotariWorld) {
139156 . args ( & args)
140157 . output ( )
141158 . expect ( "Failed to execute scan command" ) ;
142-
143159 assert ! (
144160 output. status. success( ) ,
145161 "Scan failed during balance setup: {}" ,
@@ -245,31 +261,14 @@ async fn create_transaction_with_lock_duration(world: &mut MinotariWorld, second
245261// Verification Steps
246262// =============================
247263
248- #[ then( "the transaction file should be created" ) ]
249- async fn transaction_file_created ( world : & mut MinotariWorld ) {
250- let output_file = world. output_file . as_ref ( ) . expect ( "Output file path not set" ) ;
251-
252- assert ! (
253- output_file. exists( ) ,
254- "Transaction file should exist at {:?}" ,
255- output_file
256- ) ;
257-
258- // Parse the JSON file
259- let content = std:: fs:: read_to_string ( output_file) . expect ( "Failed to read transaction file" ) ;
260-
261- let transaction_json: serde_json:: Value = serde_json:: from_str ( & content) . expect ( "Failed to parse transaction JSON" ) ;
262-
263- // Store for later verification
264- world. transaction_data . insert ( "current" . to_string ( ) , transaction_json) ;
265- }
266-
267264#[ then( "the transaction should include the recipient" ) ]
268265async fn transaction_has_recipient ( world : & mut MinotariWorld ) {
269266 let transaction = world
270267 . transaction_data
271268 . get ( "current" )
272- . expect ( "Transaction data not found" ) ;
269+ . expect ( "Transaction data not found" )
270+ . get ( "info" )
271+ . expect ( "Transaction info not found" ) ;
273272
274273 // Check that the transaction has outputs/recipients
275274 assert ! (
@@ -283,7 +282,9 @@ async fn inputs_are_locked(world: &mut MinotariWorld) {
283282 let transaction = world
284283 . transaction_data
285284 . get ( "current" )
286- . expect ( "Transaction data not found" ) ;
285+ . expect ( "Transaction data not found" )
286+ . get ( "info" )
287+ . expect ( "Transaction info not found" ) ;
287288
288289 // Check that the transaction has inputs
289290 assert ! (
@@ -299,11 +300,11 @@ async fn transaction_has_all_recipients(world: &mut MinotariWorld) {
299300 . get ( "current" )
300301 . expect ( "Transaction data not found" ) ;
301302
302- // Get recipients or outputs array
303- let recipients = transaction
303+ // Recipients are nested inside the "info" object
304+ let info = transaction. get ( "info" ) . expect ( "Transaction should have 'info' field" ) ;
305+ let recipients = info
304306 . get ( "recipients" )
305- . or_else ( || transaction. get ( "outputs" ) )
306- . expect ( "Transaction should have recipients or outputs" ) ;
307+ . expect ( "Transaction info should have 'recipients' field" ) ;
307308
308309 let recipients_array = recipients. as_array ( ) . expect ( "Recipients should be an array" ) ;
309310
@@ -317,16 +318,12 @@ async fn total_amount_correct(world: &mut MinotariWorld) {
317318 . get ( "current" )
318319 . expect ( "Transaction data not found" ) ;
319320
320- // Check that total amount or value field exists
321+ // Fee information is in the "info" object
322+ let info = transaction. get ( "info" ) . expect ( "Transaction should have 'info' field" ) ;
321323 assert ! (
322- transaction. get( "total_amount" ) . is_some( )
323- || transaction. get( "total_value" ) . is_some( )
324- || transaction. get( "amount" ) . is_some( ) ,
325- "Transaction should have a total amount field"
324+ info. get( "fee" ) . is_some( ) || info. get( "fee_per_gram" ) . is_some( ) ,
325+ "Transaction info should contain fee information"
326326 ) ;
327-
328- // The total should be 50000 + 30000 + 20000 = 100000 microTari (plus fees)
329- // We just verify the field exists and is positive
330327}
331328
332329#[ then( "the transaction should include the payment ID" ) ]
@@ -336,8 +333,10 @@ async fn transaction_has_payment_id(world: &mut MinotariWorld) {
336333 . get ( "current" )
337334 . expect ( "Transaction data not found" ) ;
338335
339- // Check for payment ID in various possible locations
340- let has_payment_id = transaction. get ( "payment_id" ) . is_some ( )
336+ // Check for payment ID in the transaction info object and at the root level
337+ let info = transaction. get ( "info" ) ;
338+ let has_payment_id = info. and_then ( |i| i. get ( "payment_id" ) ) . is_some ( )
339+ || transaction. get ( "payment_id" ) . is_some ( )
341340 || transaction. get ( "memo" ) . is_some ( )
342341 || transaction. get ( "message" ) . is_some ( ) ;
343342
@@ -376,7 +375,9 @@ async fn inputs_locked_for_duration(world: &mut MinotariWorld, seconds: String)
376375 let transaction = world
377376 . transaction_data
378377 . get ( "current" )
379- . expect ( "Transaction data not found" ) ;
378+ . expect ( "Transaction data not found" )
379+ . get ( "info" )
380+ . expect ( "No info found for transaction" ) ;
380381
381382 // Check that lock duration or expiry information is present
382383 let has_lock_info = transaction. get ( "lock_duration" ) . is_some ( )
0 commit comments