Skip to content

Commit

Permalink
fixup! Merge branch 'bat/feat/migrate-e2e-to-int' (#2933)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzemanovic committed Apr 4, 2024
1 parent fbc2d5b commit 6f178ac
Show file tree
Hide file tree
Showing 6 changed files with 124 additions and 106 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 0 additions & 32 deletions crates/apps/src/lib/node/ledger/shell/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -585,38 +585,6 @@ where
response
}

fn load_proposals(&mut self) {
use std::str::FromStr;

use namada::governance::storage::keys as governance_storage;

let proposals_key = governance_storage::get_commiting_proposals_prefix(
self.state.in_mem().last_epoch.0,
);

let (proposal_iter, _) = self.state.db_iter_prefix(&proposals_key);
for (key, _, _) in proposal_iter {
let key =
Key::from_str(key.as_str()).expect("Key should be parsable");
if governance_storage::get_commit_proposal_epoch(&key).unwrap()
!= self.state.in_mem().last_epoch.0
{
// NOTE: `iter_prefix` iterate over the matching prefix. In this
// case a proposal with grace_epoch 110 will be
// matched by prefixes 1, 11 and 110. Thus we
// have to skip to the next iteration of
// the cycle for all the prefixes that don't actually match
// the desired epoch.
continue;
}

let proposal_id = governance_storage::get_commit_proposal_id(&key);
if let Some(id) = proposal_id {
self.proposal_data.insert(id);
}
}
}

/// Read the value for a storage key dropping any error
pub fn read_storage_key<T>(&self, key: &Key) -> Option<T>
where
Expand Down
22 changes: 16 additions & 6 deletions crates/apps/src/lib/node/ledger/shell/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,6 +655,14 @@ impl MockNode {
.all(|r| *r == NodeResults::Ok)
}

/// Return a tx result if the tx failed in mempool
pub fn is_broadcast_err(&self) -> Option<TxResult> {
self.results.lock().unwrap().iter().find_map(|r| match r {
NodeResults::Ok | NodeResults::Failed(_) => None,
NodeResults::Rejected(tx_result) => Some(tx_result.clone()),
})
}

Check warning on line 664 in crates/apps/src/lib/node/ledger/shell/testing/node.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/node/ledger/shell/testing/node.rs#L659-L664

Added lines #L659 - L664 were not covered by tests

pub fn clear_results(&self) {
self.results.lock().unwrap().clear();
}
Expand Down Expand Up @@ -778,13 +786,15 @@ impl<'a> Client for &'a MockNode {
};
let tx_bytes: Vec<u8> = tx.into();
self.submit_txs(vec![tx_bytes]);
if !self.success() {
// TODO: submit_txs should return the correct error code + message
resp.code = 1337.into();
return Ok(resp);
} else {
self.clear_results();

// If the error happened during broadcasting, attach its result to
// response
if let Some(TxResult { code, info }) = self.is_broadcast_err() {
resp.code = code.into();
resp.log = info;

Check warning on line 794 in crates/apps/src/lib/node/ledger/shell/testing/node.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/node/ledger/shell/testing/node.rs#L792-L794

Added lines #L792 - L794 were not covered by tests
}

self.clear_results();

Check warning on line 797 in crates/apps/src/lib/node/ledger/shell/testing/node.rs

View check run for this annotation

Codecov / codecov/patch

crates/apps/src/lib/node/ledger/shell/testing/node.rs#L797

Added line #L797 was not covered by tests
Ok(resp)
}

Expand Down
2 changes: 2 additions & 0 deletions crates/tests/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ tracing.workspace = true
namada_apps = {path = "../apps", features = ["testing"]}
namada_vm_env = {path = "../vm_env"}
assert_cmd.workspace = true
assert_matches.workspace = true
borsh.workspace = true
borsh-ext.workspace = true
color-eyre.workspace = true
Expand All @@ -79,6 +80,7 @@ pretty_assertions.workspace = true
proptest.workspace = true
proptest-state-machine.workspace = true
rand.workspace = true
test-log.workspace = true
toml.workspace = true

# This is used to enable logging from tests
Expand Down
1 change: 0 additions & 1 deletion crates/tests/src/e2e/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ use namada_apps::config::ethereum_bridge;
use namada_apps::config::utils::convert_tm_addr_to_socket_addr;
use namada_apps::facade::tendermint_config::net::Address as TendermintAddress;
use namada_core::chain::ChainId;
use namada_core::collections::HashMap;
use namada_core::token::NATIVE_MAX_DECIMAL_PLACES;
use namada_sdk::masp::fs::FsShieldedUtils;
use namada_test_utils::TestWasms;
Expand Down
Loading

0 comments on commit 6f178ac

Please sign in to comment.