diff --git a/stackslib/src/chainstate/stacks/db/transactions.rs b/stackslib/src/chainstate/stacks/db/transactions.rs index d4b688f1788..b0419f5b8d0 100644 --- a/stackslib/src/chainstate/stacks/db/transactions.rs +++ b/stackslib/src/chainstate/stacks/db/transactions.rs @@ -9548,10 +9548,17 @@ pub mod test { .unwrap_err(); if let Error::ClarityError(clarity_error::Interpreter(InterpreterError::Unchecked( _check_error, - ))) = err + ))) = &err { } else { - panic!("Did not get unchecked interpreter error"); + if !cfg!(feature = "clarity-wasm") { + panic!("Did not get unchecked interpreter error"); + } else if !matches!( + &err, + Error::ClarityError(clarity_error::Wasm(WasmError::WasmGeneratorError(_))) + ) { + panic!("Did not get WASM generator error"); + } } let acct = StacksChainState::get_account(&mut conn, &addr.clone().into()); assert_eq!(acct.nonce, 3); @@ -9651,10 +9658,17 @@ pub mod test { .unwrap_err(); if let Error::ClarityError(clarity_error::Interpreter(InterpreterError::Unchecked( _check_error, - ))) = err + ))) = &err { } else { - panic!("Did not get unchecked interpreter error"); + if !cfg!(feature = "clarity-wasm") { + panic!("Did not get unchecked interpreter error"); + } else if !matches!( + &err, + Error::ClarityError(clarity_error::Wasm(WasmError::WasmGeneratorError(_))) + ) { + panic!("Did not get WASM generator error"); + } } let acct = StacksChainState::get_account(&mut conn, &addr.clone().into()); assert_eq!(acct.nonce, 3); @@ -9721,32 +9735,43 @@ pub mod test { assert!(tx_receipt.vm_error.is_some()); let err_str = tx_receipt.vm_error.unwrap(); - assert!(err_str - .find("TypeValueError(OptionalType(CallableType(Trait(TraitIdentifier ") - .is_some()); + let expected_err = if !cfg!(feature = "clarity-wasm") { + "TypeValueError(OptionalType(CallableType(Trait(TraitIdentifier" + } else { + "TypeError(CallableType(Trait(TraitIdentifier" + }; + assert!(err_str.contains(expected_err)); - let (fee, tx_receipt) = validate_transactions_static_epoch_and_process_transaction( - &mut conn, - &signed_runtime_checkerror_cc_contract_tx_clar1, - false, - ) - .unwrap(); - assert_eq!(fee, 1); + // we ignore this in wasm as the contract call is failing in wasm due to a type_checker error + #[cfg(not(feature = "clarity-wasm"))] + { + let (fee, tx_receipt) = validate_transactions_static_epoch_and_process_transaction( + &mut conn, + &signed_runtime_checkerror_cc_contract_tx_clar1, + false, + ) + .unwrap(); + assert_eq!(fee, 1); + } // nonce keeps advancing despite error let acct = StacksChainState::get_account(&mut conn, &addr.clone().into()); - assert_eq!(acct.nonce, 5); + assert_eq!( + acct.nonce, + if cfg!(feature = "clarity-wasm") { 4 } else { 5 } + ); // no state change materialized let executed_var = StacksChainState::get_data_var(&mut conn, &contract_id, "executed").unwrap(); assert_eq!(executed_var, Some(Value::Bool(false))); - assert!(tx_receipt.vm_error.is_some()); - let err_str = tx_receipt.vm_error.unwrap(); - assert!(err_str - .find("TypeValueError(OptionalType(CallableType(Trait(TraitIdentifier ") - .is_some()); + #[cfg(not(feature = "clarity-wasm"))] + { + assert!(tx_receipt.vm_error.is_some()); + let err_str = tx_receipt.vm_error.unwrap(); + assert!(err_str.contains(expected_err)); + } conn.commit_block(); @@ -9798,9 +9823,19 @@ pub mod test { // state change materialized let executed_var = StacksChainState::get_data_var(&mut conn, &contract_id, "executed").unwrap(); - assert_eq!(executed_var, Some(Value::Bool(true))); - - assert!(tx_receipt.vm_error.is_none()); + // in wasm, the contract call is failing in wasm due to a type_checker error so it is not executed + assert_eq!( + executed_var, + Some(Value::Bool(if cfg!(feature = "clarity-wasm") { + false + } else { + true + })) + ); + #[cfg(not(feature = "clarity-wasm"))] + { + assert!(tx_receipt.vm_error.is_none()); + } let (fee, tx_receipt) = validate_transactions_static_epoch_and_process_transaction( &mut conn,