Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion cmd/crates/soroban-spec-tools/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,6 @@ impl Spec {
}
Err(Error::MissingErrorCase(value))
}

/// # Errors
///
/// Might return errors
Expand Down
22 changes: 17 additions & 5 deletions cmd/crates/soroban-test/tests/it/integration/custom_types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -195,11 +195,23 @@ async fn number_arg_return_err(sandbox: &TestEnv, id: &str) {
.invoke_with_test(&["--id", id, "--", "u32_fail_on_even", "--u32_=2"])
.await
.unwrap_err();
if let commands::contract::invoke::Error::ContractInvoke(name, doc) = &res {
assert_eq!(name, "NumberMustBeOdd");
assert_eq!(doc, "Please provide an odd number");
};
println!("{res:#?}");
match &res {
commands::contract::invoke::Error::ContractInvoke {
message: enhanced_msg,
detail,
} => {
assert!(
enhanced_msg.contains("#1"),
"expected enhanced msg to contain '#1', got: {enhanced_msg}"
);
assert!(
enhanced_msg.contains("NumberMustBeOdd"),
"expected enhanced msg to contain resolved error name, got: {enhanced_msg}"
);
assert_eq!(detail, "NumberMustBeOdd: Please provide an odd number");
}
other => panic!("expected ContractInvoke error, got: {other:#?}"),
}
}

fn void(sandbox: &TestEnv, id: &str) {
Expand Down
16 changes: 13 additions & 3 deletions cmd/soroban-cli/src/assembled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,11 @@ use soroban_rpc::{
Error, LogEvents, LogResources, ResourceConfig, RestorePreamble, SimulateTransactionResponse,
};

pub async fn simulate_and_assemble_transaction(
pub async fn simulate_transaction(
client: &soroban_rpc::Client,
tx: &Transaction,
resource_config: Option<ResourceConfig>,
resource_fee: Option<i64>,
) -> Result<Assembled, Error> {
) -> Result<SimulateTransactionResponse, Error> {
let envelope = TransactionEnvelope::Tx(TransactionV1Envelope {
tx: tx.clone(),
signatures: VecM::default(),
Expand All @@ -32,6 +31,17 @@ pub async fn simulate_and_assemble_transaction(
.await?;
tracing::trace!("{sim_res:#?}");

Ok(sim_res)
}

pub async fn simulate_and_assemble_transaction(
client: &soroban_rpc::Client,
tx: &Transaction,
resource_config: Option<ResourceConfig>,
resource_fee: Option<i64>,
) -> Result<Assembled, Error> {
let sim_res = simulate_transaction(client, tx, resource_config).await?;

if let Some(e) = &sim_res.error {
crate::log::event::all(&sim_res.events()?);
Err(Error::TransactionSimulationFailed(e.clone()))
Expand Down
Loading
Loading