Skip to main content

assert_contract_err

Macro assert_contract_err 

Source
macro_rules! assert_contract_err {
    ($given:expr, $expected:expr) => { ... };
}
Expand description

Assert that a Result from a contract call is Err and matches an error variant

given corresponds to the return type from try_* functions in Soroban. For the assert to succeed, the function needs to fail and successfully pass down the intended error type. So, the parameters would be in the form:

given: Err(Ok(ContractError)) expected: ContractError

Putting it together in a function call:

assert_contract_err(client.try_fun(...), ContractError);