MCPcopy Create free account
hub / github.com/base/base / assert_batch_matches_sequential

Function assert_batch_matches_sequential

crates/execution/txpool/src/pool.rs:3108–3137  ·  view source on GitHub ↗

Adds `batch` one transaction at a time to one fresh pool and as one batch to another, both funding `funded`, and asserts the same outcome per transaction and the same pool size. Returns the batched outcomes and pool.

(
        batch: Vec<(TransactionOrigin, BasePooledTransaction)>,
        funded: &[Address],
    )

Source from the content-addressed store, hash-verified

3106 /// per transaction and the same pool size. Returns the batched outcomes
3107 /// and pool.
3108 async fn assert_batch_matches_sequential(
3109 batch: Vec<(TransactionOrigin, BasePooledTransaction)>,
3110 funded: &[Address],
3111 ) -> (Vec<PoolResult<AddedTransactionOutcome>>, IntegrationPool) {
3112 // `PoolErrorKind` is not `PartialEq`; compare errors by hash and message.
3113 let comparable = |results: &[PoolResult<AddedTransactionOutcome>]| {
3114 results
3115 .iter()
3116 .map(|result| match result {
3117 Ok(outcome) => Ok(outcome.clone()),
3118 Err(error) => Err((error.hash, error.kind.to_string())),
3119 })
3120 .collect::<Vec<_>>()
3121 };
3122 let (sequential_pool, client) = build_integration_pool();
3123 funded.iter().for_each(|account| fund(&client, *account));
3124 let mut sequential = Vec::new();
3125 for (origin, transaction) in batch.clone() {
3126 sequential.push(sequential_pool.add_transaction(origin, transaction).await);
3127 }
3128
3129 let (batch_pool, client) = build_integration_pool();
3130 funded.iter().for_each(|account| fund(&client, *account));
3131 let batched = batch_pool.add_transactions_with_origins(batch).await;
3132
3133 assert_eq!(comparable(&batched), comparable(&sequential));
3134 let size = |pool: &IntegrationPool| (pool.pool_size().pending, pool.pool_size().queued);
3135 assert_eq!(size(&batch_pool), size(&sequential_pool));
3136 (batched, batch_pool)
3137 }
3138
3139 #[tokio::test]
3140 async fn rpc_batch_insert_matches_single_inserts() {

Calls 9

build_integration_poolFunction · 0.85
add_transactionMethod · 0.80
fundFunction · 0.70
newFunction · 0.50
iterMethod · 0.45
cloneMethod · 0.45
pushMethod · 0.45
pool_sizeMethod · 0.45

Tested by

no test coverage detected