Skip to content

Commit

Permalink
Merge of #4039
Browse files Browse the repository at this point in the history
  • Loading branch information
mergify[bot] authored Nov 20, 2024
2 parents d2a863f + 91bd7f3 commit 47ad0c2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 27 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Improved the display of transactions' results.
([\#4039](https://github.com/anoma/namada/pull/4039))
6 changes: 3 additions & 3 deletions crates/sdk/src/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -658,8 +658,8 @@ pub enum InnerTxResult<'a> {
Success(&'a BatchedTxResult),
/// Some VPs rejected the tx
VpsRejected(&'a BatchedTxResult),
/// Transaction failed in some other way
OtherFailure,
/// Transaction failed in some other way specified in the associated message
OtherFailure(String),
}

impl TryFrom<Event> for TxResponse {
Expand Down Expand Up @@ -720,7 +720,7 @@ impl TxResponse {
InnerTxResult::VpsRejected(res)
}
}
Err(_) => InnerTxResult::OtherFailure,
Err(msg) => InnerTxResult::OtherFailure(msg.to_owned()),
};
result.insert(inner_hash.to_owned(), value);
}
Expand Down
26 changes: 19 additions & 7 deletions crates/sdk/src/tx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -432,16 +432,28 @@ pub async fn submit_tx(

/// Display a result of a tx batch.
pub fn display_batch_resp(context: &impl Namada, resp: &TxResponse) {
for (inner_hash, result) in resp.batch_result() {
// Wrapper-level logs
display_line!(
context.io(),
"Transaction batch {} was applied at height {}, consuming {} gas \
units.",
resp.hash,
resp.height,
resp.gas_used
);
let batch_results = resp.batch_result();
if !batch_results.is_empty() {
display_line!(context.io(), "Batch results:");
}

// Batch-level logs
for (inner_hash, result) in batch_results {
match result {
InnerTxResult::Success(_) => {
display_line!(
context.io(),
"Transaction {} was successfully applied at height {}, \
consuming {} gas units.",
"Transaction {} was successfully applied.",
inner_hash,
resp.height,
resp.gas_used
);
}
InnerTxResult::VpsRejected(inner) => {
Expand All @@ -464,12 +476,12 @@ pub fn display_batch_resp(context: &impl Namada, resp: &TxResponse) {
serde_json::to_string_pretty(&changed_keys).unwrap(),
);
}
InnerTxResult::OtherFailure => {
InnerTxResult::OtherFailure(msg) => {
edisplay_line!(
context.io(),
"Transaction {} failed.\nDetails: {}",
inner_hash,
serde_json::to_string_pretty(&resp).unwrap()
msg
);
}
}
Expand Down
20 changes: 3 additions & 17 deletions crates/tests/src/e2e/ibc_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,6 @@ fn ibc_transfers() -> Result<()> {
None,
None,
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;

Expand Down Expand Up @@ -182,7 +181,6 @@ fn ibc_transfers() -> Result<()> {
None,
None,
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;

Expand Down Expand Up @@ -252,7 +250,6 @@ fn ibc_transfers() -> Result<()> {
None,
None,
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;
check_balance(&test, AB_VIEWING_KEY, &ibc_denom_on_namada, 40)?;
Expand Down Expand Up @@ -299,7 +296,6 @@ fn ibc_transfers() -> Result<()> {
None,
None,
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;
// The balance should not be changed
Expand All @@ -322,7 +318,6 @@ fn ibc_transfers() -> Result<()> {
Some(Duration::new(10, 0)),
None,
None,
false,
)?;
// wait for the timeout
sleep(10);
Expand All @@ -349,7 +344,6 @@ fn ibc_transfers() -> Result<()> {
None,
None,
None,
false,
)?;
wait_for_packet_relay(&port_id_namada, &channel_id_namada, &test)?;
// Check the token has been refunded to the refund target
Expand All @@ -374,7 +368,6 @@ fn ibc_transfers() -> Result<()> {
Some(Duration::new(10, 0)),
None,
None,
false,
)?;
// wait for the timeout
sleep(10);
Expand Down Expand Up @@ -834,7 +827,6 @@ fn ibc_rate_limit() -> Result<()> {
None,
None,
None,
false,
)?;

// Transfer 1 NAM from Namada to Gaia again will fail
Expand All @@ -853,7 +845,6 @@ fn ibc_rate_limit() -> Result<()> {
Some(
"Transfer exceeding the per-epoch throughput limit is not allowed",
),
false,
)?;

// wait for the next epoch
Expand All @@ -876,7 +867,6 @@ fn ibc_rate_limit() -> Result<()> {
None,
None,
None,
false,
)?;

// wait for the next epoch
Expand Down Expand Up @@ -1116,7 +1106,6 @@ fn try_invalid_transfers(
None,
// the IBC denom can't be parsed when using an invalid port
Some(&format!("Invalid IBC denom: {nam_addr}")),
false,
)?;

// invalid channel
Expand All @@ -1132,7 +1121,6 @@ fn try_invalid_transfers(
None,
None,
Some("IBC token transfer error: context error: `ICS04 Channel error"),
false,
)?;

Ok(())
Expand Down Expand Up @@ -1187,7 +1175,6 @@ fn transfer(
timeout_sec: Option<Duration>,
shielding_data_path: Option<PathBuf>,
expected_err: Option<&str>,
wait_reveal_pk: bool,
) -> Result<u32> {
let rpc = get_actor_rpc(test, Who::Validator(0));

Expand Down Expand Up @@ -1260,11 +1247,10 @@ fn transfer(
Ok(0)
}
None => {
let height = check_tx_height(test, &mut client)?;
client.exp_string(TX_APPLIED_SUCCESS)?;
if wait_reveal_pk {
client.exp_string(TX_APPLIED_SUCCESS)?;
}
check_tx_height(test, &mut client)

Ok(height)
}
}
}
Expand Down

0 comments on commit 47ad0c2

Please sign in to comment.