Skip to content

Commit

Permalink
Fixes integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
grarco committed Aug 30, 2024
1 parent 816c51c commit 44a02e3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 5 deletions.
2 changes: 1 addition & 1 deletion crates/node/src/shell/testing/node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ impl MockNode {
let mut tx_results = resp
.events
.into_iter()
.map(|e| e.read_attribute::<BatchAttr<'_>>().unwrap())
.filter_map(|e| e.read_attribute_opt::<BatchAttr<'_>>().unwrap())
.collect::<Vec<_>>();
self.tx_result_codes
.lock()
Expand Down
29 changes: 25 additions & 4 deletions crates/tests/src/integration/ledger_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use namada_core::hash::Hash;
use namada_core::storage::{DbColFam, Key};
use namada_core::token::NATIVE_MAX_DECIMAL_PLACES;
use namada_node::shell::testing::client::run;
use namada_node::shell::testing::node::NodeResults;
use namada_node::shell::testing::utils::{Bin, CapturedOutput};
use namada_node::shell::SnapshotSync;
use namada_node::storage::DbSnapshot;
Expand Down Expand Up @@ -1670,8 +1671,28 @@ fn enforce_fee_payment() -> Result<()> {
node.clear_results();
node.submit_txs(txs);
// If empty than failed in process proposal
assert!(!node.tx_result_codes.lock().unwrap().is_empty());
node.assert_success();
let codes = node.tx_result_codes.lock().unwrap();
assert!(!codes.is_empty());

for code in codes.iter() {
assert!(matches!(code, NodeResults::Ok));
}

let results = node.tx_results.lock().unwrap();
// We submitted two batches
assert_eq!(results.len(), 2);
let first_result = &results[0];
let second_result = &results[1];

// The batches should contain a single inner tx each
assert_eq!(first_result.0.len(), 1);
assert_eq!(second_result.0.len(), 1);

// First transaction pay fees but then fails on the token transfer because
// of a lack of funds
assert!(first_result.are_any_err());
// Second transaction is correctly applied
assert!(second_result.are_results_successfull());

// Assert balances
let captured = CapturedOutput::of(|| {
Expand All @@ -1690,7 +1711,7 @@ fn enforce_fee_payment() -> Result<()> {
)
});
assert!(captured.result.is_ok());
// This is the result of the two fee payemnts and the successful transfer to
// This is the result of the two fee payments and the successful transfer to
// Christel
assert!(captured.contains("nam: 1799950"));

Expand All @@ -1712,7 +1733,7 @@ fn enforce_fee_payment() -> Result<()> {
assert!(captured.result.is_ok());
// Bertha must not receive anything because the transaction fails. This is
// because we evaluate fee payments before the inner transactions, so by the
// time we execute the transfer, Albert doesn't have enough funds anynmore
// time we execute the transfer, Albert doesn't have enough funds anymore
assert!(captured.contains("nam: 2000000"));

let captured = CapturedOutput::of(|| {
Expand Down

0 comments on commit 44a02e3

Please sign in to comment.