Skip to content

Commit

Permalink
test: add cairo0 to integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
Yael-Starkware committed Jun 25, 2024
1 parent e26cb96 commit 636d8c4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
14 changes: 10 additions & 4 deletions crates/tests-integration/src/state_reader.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,15 +45,21 @@ type ContractClassesMap =
pub async fn rpc_test_state_reader_factory() -> RpcStateReaderFactory {
const RPC_SPEC_VERION: &str = "V0_7";
const JSON_RPC_VERSION: &str = "2.0";
let cairo_version = CairoVersion::Cairo1;
let block_context = BlockContext::create_for_testing();
let account_contract = FeatureContract::AccountWithoutValidations(cairo_version);
let test_contract = FeatureContract::TestContract(cairo_version);
let account_contract_cairo0 = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo0);
let test_contract_cairo0 = FeatureContract::TestContract(CairoVersion::Cairo0);
let account_contract_cairo1 = FeatureContract::AccountWithoutValidations(CairoVersion::Cairo1);
let test_contract_cairo1 = FeatureContract::TestContract(CairoVersion::Cairo1);

let storage_reader = initialize_papyrus_test_state(
block_context.chain_info(),
BALANCE,
&[(account_contract, 1), (test_contract, 1)],
&[
(account_contract_cairo0, 1),
(test_contract_cairo0, 1),
(account_contract_cairo1, 1),
(test_contract_cairo1, 1),
],
);
let addr = run_papyrus_rpc_server(storage_reader).await;

Expand Down
19 changes: 14 additions & 5 deletions crates/tests-integration/tests/end_to_end_test.rs
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
use blockifier::test_utils::CairoVersion;
use starknet_api::transaction::TransactionHash;
use starknet_gateway::starknet_api_test_utils::invoke_tx;
use starknet_mempool_integration_tests::integration_test_setup::IntegrationTestSetup;

#[tokio::test]
async fn test_end_to_end() {
let mut mock_running_system = IntegrationTestSetup::new().await;

let expected_tx_hash =
mock_running_system.assert_add_tx_success(&invoke_tx(CairoVersion::Cairo1)).await;
let mut expected_tx_hashs = Vec::new();
expected_tx_hashs
.push(mock_running_system.assert_add_tx_success(&invoke_tx(CairoVersion::Cairo0)).await);
expected_tx_hashs
.push(mock_running_system.assert_add_tx_success(&invoke_tx(CairoVersion::Cairo1)).await);

let mempool_txs = mock_running_system.get_txs(2).await;
assert_eq!(mempool_txs.len(), 1);
assert_eq!(mempool_txs[0].tx_hash, expected_tx_hash);
let mempool_txs = mock_running_system.get_txs(3).await;

assert_eq!(mempool_txs.len(), 2);
let mut actual_tx_hashes: Vec<TransactionHash> =
mempool_txs.iter().map(|tx| tx.tx_hash).collect();
actual_tx_hashes.sort();
expected_tx_hashs.sort();
assert_eq!(expected_tx_hashs, actual_tx_hashes);
}

0 comments on commit 636d8c4

Please sign in to comment.