diff --git a/contracts/examples/adder/interact/src/basic_interact.rs b/contracts/examples/adder/interact/src/basic_interact.rs index f83ca84a26..b700a63665 100644 --- a/contracts/examples/adder/interact/src/basic_interact.rs +++ b/contracts/examples/adder/interact/src/basic_interact.rs @@ -276,13 +276,12 @@ impl AdderInteract { } } -#[cfg(feature = "chain_simulator")] #[tokio::test] async fn simulator_upgrade_test() { let mut basic_interact = AdderInteract::init().await; - // let wallet_address = basic_interact.wallet_address.clone(); + let wallet_address = basic_interact.wallet_address.clone(); let adder_owner_address = basic_interact.adder_owner_address.clone(); - // let error_not_owner = (4, "upgrade is allowed only for owner"); + let error_not_owner = (4, "upgrade is allowed only for owner"); basic_interact.deploy().await; basic_interact.add(1u32).await; @@ -297,10 +296,10 @@ async fn simulator_upgrade_test() { // Sum will be the updated value of 7 basic_interact.print_sum().await; - // basic_interact - // .upgrade(10u32, &wallet_address, Some(error_not_owner)) - // .await; + basic_interact + .upgrade(10u32, &wallet_address, Some(error_not_owner)) + .await; - // // Sum will remain 7 - // basic_interact.print_sum().await; + // Sum will remain 7 + basic_interact.print_sum().await; } diff --git a/framework/scenario/src/scenario/model/transaction/tx_expect.rs b/framework/scenario/src/scenario/model/transaction/tx_expect.rs index d487a10db5..fe8f0f5eaa 100644 --- a/framework/scenario/src/scenario/model/transaction/tx_expect.rs +++ b/framework/scenario/src/scenario/model/transaction/tx_expect.rs @@ -120,7 +120,7 @@ impl TxExpect { self.message.check(tx_response.tx_error.message.as_str()), "{}result message mismatch. Want: {}. Have: {}.", &self.additional_error_message, - &self.status, + &self.message, &tx_response.tx_error.message, ); } diff --git a/sdk/core/src/retrieve_tx_on_network.rs b/sdk/core/src/retrieve_tx_on_network.rs index c68a649d9c..4d68f64d5d 100644 --- a/sdk/core/src/retrieve_tx_on_network.rs +++ b/sdk/core/src/retrieve_tx_on_network.rs @@ -45,17 +45,14 @@ pub async fn retrieve_tx_on_network( } let result = parse_reason(&reason); + let transaction_info_with_results = proxy + .request(GetTxInfo::new(&tx_hash).with_results()) + .await + .unwrap(); - match result { - Ok((code, err)) => { - info!("Transaction failed. Code: {code}, message: {err}"); - panic!("Transaction failed. Code: {code}, message: {err}") - }, - Err(err) => { - info!("Reason parsing error for failed transaction: {err}"); - panic!("Reason parsing error for failed transaction: {err}") - }, - } + println!("Transaction failed: {}", result); + + return transaction_info_with_results; }, _ => { continue; @@ -85,22 +82,18 @@ pub async fn retrieve_tx_on_network( TransactionOnNetwork::default() } -pub fn parse_reason(reason: &str) -> Result<(u64, String), String> { - let parts: Vec<&str> = reason.split('@').collect(); - - if parts.len() < 2 { - return Err("Invalid reason format".to_string()); +pub fn parse_reason(reason: &str) -> String { + let parts: Vec<&str> = reason.split('@').filter(|part| !part.is_empty()).collect(); + let mut responses: Vec = Vec::new(); + for part in &parts { + match u64::from_str_radix(part, 16) { + Ok(error_code) => responses.push(error_code.to_string()), + Err(_) => responses.push( + String::from_utf8(hex::decode(part).expect("Failed to decode error message")) + .expect("Failed to decode error message as UTF-8"), + ), + } } - let error_code_hex = parts[1]; - let error_message_hex = parts[2]; - - let error_code = - u64::from_str_radix(error_code_hex, 16).expect("Failed to decode error code as u64"); - - let error_message = - String::from_utf8(hex::decode(error_message_hex).expect("Failed to decode error message")) - .expect("Failed to decode error message as UTF-8"); - - Ok((error_code, error_message)) + responses.join(" ") }