Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(starknet_gateway): make expect_add_tx configurable with custom results #3345

Merged
merged 1 commit into from
Jan 16, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions crates/starknet_gateway/src/gateway_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,11 @@ use starknet_api::core::{ChainId, CompiledClassHash, ContractAddress};
use starknet_api::executable_transaction::{AccountTransaction, InvokeTransaction};
use starknet_api::rpc_transaction::{RpcDeclareTransaction, RpcTransaction};
use starknet_gateway_types::errors::GatewaySpecError;
use starknet_mempool_types::communication::{AddTransactionArgsWrapper, MockMempoolClient};
use starknet_mempool_types::communication::{
AddTransactionArgsWrapper,
MempoolClientResult,
MockMempoolClient,
};
use starknet_mempool_types::mempool_types::{AccountState, AddTransactionArgs};
use starknet_sierra_compile::config::SierraCompilationConfig;

Expand Down Expand Up @@ -71,8 +75,8 @@ impl MockDependencies {
)
}

fn expect_add_tx(&mut self, args: AddTransactionArgsWrapper) {
self.mock_mempool_client.expect_add_tx().once().with(eq(args)).return_once(|_| Ok(()));
fn expect_add_tx(&mut self, args: AddTransactionArgsWrapper, result: MempoolClientResult<()>) {
self.mock_mempool_client.expect_add_tx().once().with(eq(args)).return_once(|_| result);
}
}

Expand Down Expand Up @@ -107,10 +111,13 @@ async fn test_add_tx(mut mock_dependencies: MockDependencies) {
tx: executable_tx,
account_state: AccountState { address, nonce: *rpc_tx.nonce() },
};
mock_dependencies.expect_add_tx(AddTransactionArgsWrapper {
args: add_tx_args,
p2p_message_metadata: p2p_message_metadata.clone(),
});
mock_dependencies.expect_add_tx(
AddTransactionArgsWrapper {
args: add_tx_args,
p2p_message_metadata: p2p_message_metadata.clone(),
},
Ok(()),
);

let gateway = mock_dependencies.gateway();

Expand Down
Loading