Skip to content

Commit

Permalink
fix(tests-integration): reenable e2e test
Browse files Browse the repository at this point in the history
  • Loading branch information
Gilad Chase committed Sep 27, 2024
1 parent 90c145e commit 4f32e78
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 16 deletions.
6 changes: 4 additions & 2 deletions crates/batcher/src/batcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use std::sync::Arc;
use async_trait::async_trait;
#[cfg(test)]
use mockall::automock;
use papyrus_storage::test_utils::get_test_storage;
use starknet_mempool_infra::component_runner::ComponentStarter;
use starknet_mempool_types::communication::SharedMempoolClient;

Expand All @@ -26,8 +27,9 @@ impl Batcher {
}

pub fn create_batcher(config: BatcherConfig, mempool_client: SharedMempoolClient) -> Batcher {
let (storage_reader, _storage_writer) = papyrus_storage::open_storage(config.storage.clone())
.expect("Failed to open batcher's storage");
// let (storage_reader, _storage_writer) = papyrus_storage::open_storage(config.storage.clone())
// .expect("Failed to open batcher's storage");
let (storage_reader, _storage_writer) = get_test_storage().0;
Batcher::new(config, mempool_client, Arc::new(storage_reader))
}

Expand Down
27 changes: 13 additions & 14 deletions crates/tests-integration/tests/end_to_end_test.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use blockifier::test_utils::contracts::FeatureContract;
use blockifier::test_utils::CairoVersion;
use mempool_test_utils::starknet_api_test_utils::MultiAccountTransactionGenerator;
use pretty_assertions::assert_eq;
use rstest::{fixture, rstest};
use starknet_api::transaction::TransactionHash;
use starknet_mempool_integration_tests::integration_test_setup::IntegrationTestSetup;
Expand All @@ -11,8 +12,6 @@ fn tx_generator() -> MultiAccountTransactionGenerator {
}

#[rstest]
#[ignore = "Gilad: There are structural issues with funding new accounts and this need surgery.
Will fix soon. Once fixed, the test logic also need work, it's stale by now."]
#[tokio::test]
async fn test_end_to_end(mut tx_generator: MultiAccountTransactionGenerator) {
// Setup.
Expand All @@ -27,30 +26,30 @@ async fn test_end_to_end(mut tx_generator: MultiAccountTransactionGenerator) {
let mock_running_system = IntegrationTestSetup::new_for_accounts(accounts).await;

let account0_invoke_nonce1 = tx_generator.account_with_id(0).generate_default_invoke();
let account1_invoke_nonce0 = tx_generator.account_with_id(1).generate_default_invoke();
let account1_invoke_nonce1 = tx_generator.account_with_id(1).generate_default_invoke();
let account0_invoke_nonce2 = tx_generator.account_with_id(0).generate_default_invoke();

// Test.

mock_running_system.assert_add_tx_success(&account0_invoke_nonce1).await;
let account0_invoke_nonce1_tx_hash =
mock_running_system.assert_add_tx_success(&account0_invoke_nonce1).await;

// FIXME: invoke with nonce0 shouldn't be possible, fix it, make this FAIL.
let account1_invoke_nonce0_tx_hash =
mock_running_system.assert_add_tx_success(&account1_invoke_nonce0).await;
let account1_invoke_nonce1_tx_hash =
mock_running_system.assert_add_tx_success(&account1_invoke_nonce1).await;

mock_running_system.assert_add_tx_success(&account0_invoke_nonce2).await;
let account0_invoke_nonce2_tx_hash =
mock_running_system.assert_add_tx_success(&account0_invoke_nonce2).await;

let mempool_txs = mock_running_system.get_txs(4).await;

// Assert.

// Only the transactions with nonce 0 should be returned from the mempool,
// because we haven't merged queue-replenishment yet.
let expected_tx_hashes_from_get_txs = [account1_invoke_nonce0_tx_hash];
let expected_tx_hashes_from_get_txs = [
account1_invoke_nonce1_tx_hash,
account0_invoke_nonce1_tx_hash,
account0_invoke_nonce2_tx_hash,
];

// This assert should be replaced with 4 once queue-replenishment is merged, also add a tx hole
// at that point, and ensure the assert doesn't change due to that.
assert_eq!(mempool_txs.len(), 2);
let actual_tx_hashes: Vec<TransactionHash> =
mempool_txs.iter().map(|tx| tx.tx_hash()).collect();
assert_eq!(expected_tx_hashes_from_get_txs, *actual_tx_hashes);
Expand Down

0 comments on commit 4f32e78

Please sign in to comment.