Skip to content

Commit

Permalink
rotator: all tests updated (static size used)
Browse files Browse the repository at this point in the history
  • Loading branch information
michalkucharczyk committed Jan 9, 2025
1 parent e4490ca commit 38e7618
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 14 deletions.
12 changes: 10 additions & 2 deletions substrate/client/transaction-pool/benches/basics.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,14 +197,22 @@ fn benchmark_main(c: &mut Criterion) {
c.bench_function("sequential 50 tx", |b| {
b.iter(|| {
let api = Arc::from(TestApi::new_dependant());
bench_configured(Pool::new(Default::default(), true.into(), api.clone()), 50, api);
bench_configured(
Pool::new_with_staticly_sized_rotator(Default::default(), true.into(), api.clone()),
50,
api,
);
});
});

c.bench_function("random 100 tx", |b| {
b.iter(|| {
let api = Arc::from(TestApi::default());
bench_configured(Pool::new(Default::default(), true.into(), api.clone()), 100, api);
bench_configured(
Pool::new_with_staticly_sized_rotator(Default::default(), true.into(), api.clone()),
100,
api,
);
});
});
}
Expand Down
2 changes: 1 addition & 1 deletion substrate/client/transaction-pool/src/common/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,5 +222,5 @@ pub(crate) fn uxt(transfer: Transfer) -> Extrinsic {

pub(crate) fn pool() -> (Pool<TestApi>, Arc<TestApi>) {
let api = Arc::new(TestApi::default());
(Pool::new(Default::default(), true.into(), api.clone()), api)
(Pool::new_with_staticly_sized_rotator(Default::default(), true.into(), api.clone()), api)
}
18 changes: 11 additions & 7 deletions substrate/client/transaction-pool/src/graph/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -602,7 +602,7 @@ mod tests {
fn should_reject_unactionable_transactions() {
// given
let api = Arc::new(TestApi::default());
let pool = Pool::new(
let pool = Pool::new_with_staticly_sized_rotator(
Default::default(),
// the node does not author blocks
false.into(),
Expand Down Expand Up @@ -789,7 +789,7 @@ mod tests {
let options = Options { ready: limit.clone(), future: limit.clone(), ..Default::default() };

let api = Arc::new(TestApi::default());
let pool = Pool::new(options, true.into(), api.clone());
let pool = Pool::new_with_staticly_sized_rotator(options, true.into(), api.clone());

let hash1 =
block_on(pool.submit_one(&api.expect_hash_and_number(0), SOURCE, xt.into())).unwrap();
Expand Down Expand Up @@ -825,7 +825,7 @@ mod tests {
let options = Options { ready: limit.clone(), future: limit.clone(), ..Default::default() };

let api = Arc::new(TestApi::default());
let pool = Pool::new(options, true.into(), api.clone());
let pool = Pool::new_with_staticly_sized_rotator(options, true.into(), api.clone());

// when
block_on(
Expand Down Expand Up @@ -1058,7 +1058,7 @@ mod tests {
Options { ready: limit.clone(), future: limit.clone(), ..Default::default() };

let api = Arc::new(TestApi::default());
let pool = Pool::new(options, true.into(), api.clone());
let pool = Pool::new_with_staticly_sized_rotator(options, true.into(), api.clone());

let xt = uxt(Transfer {
from: Alice.into(),
Expand Down Expand Up @@ -1096,7 +1096,7 @@ mod tests {
Options { ready: limit.clone(), future: limit.clone(), ..Default::default() };

let api = Arc::new(TestApi::default());
let pool = Pool::new(options, true.into(), api.clone());
let pool = Pool::new_with_staticly_sized_rotator(options, true.into(), api.clone());

// after validation `IncludeData` will have priority set to 9001
// (validate_transaction mock)
Expand Down Expand Up @@ -1128,7 +1128,7 @@ mod tests {
Options { ready: limit.clone(), future: limit.clone(), ..Default::default() };

let api = Arc::new(TestApi::default());
let pool = Pool::new(options, true.into(), api.clone());
let pool = Pool::new_with_staticly_sized_rotator(options, true.into(), api.clone());

let han_of_block0 = api.expect_hash_and_number(0);

Expand Down Expand Up @@ -1173,7 +1173,11 @@ mod tests {
let mut api = TestApi::default();
api.delay = Arc::new(Mutex::new(rx.into()));
let api = Arc::new(api);
let pool = Arc::new(Pool::new(Default::default(), true.into(), api.clone()));
let pool = Arc::new(Pool::new_with_staticly_sized_rotator(
Default::default(),
true.into(),
api.clone(),
));

let han_of_block0 = api.expect_hash_and_number(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,11 @@ mod tests {
#[test]
fn revalidation_queue_works() {
let api = Arc::new(TestApi::default());
let pool = Arc::new(Pool::new(Default::default(), true.into(), api.clone()));
let pool = Arc::new(Pool::new_with_staticly_sized_rotator(
Default::default(),
true.into(),
api.clone(),
));
let queue = Arc::new(RevalidationQueue::new(api.clone(), pool.clone()));

let uxt = uxt(Transfer {
Expand Down Expand Up @@ -414,7 +418,11 @@ mod tests {
#[test]
fn revalidation_queue_skips_revalidation_for_unknown_block_hash() {
let api = Arc::new(TestApi::default());
let pool = Arc::new(Pool::new(Default::default(), true.into(), api.clone()));
let pool = Arc::new(Pool::new_with_staticly_sized_rotator(
Default::default(),
true.into(),
api.clone(),
));
let queue = Arc::new(RevalidationQueue::new(api.clone(), pool.clone()));

let uxt0 = uxt(Transfer {
Expand Down
4 changes: 2 additions & 2 deletions substrate/client/transaction-pool/tests/pool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ const LOG_TARGET: &str = "txpool";

fn pool() -> (Pool<TestApi>, Arc<TestApi>) {
let api = Arc::new(TestApi::with_alice_nonce(209));
(Pool::new(Default::default(), true.into(), api.clone()), api)
(Pool::new_with_staticly_sized_rotator(Default::default(), true.into(), api.clone()), api)
}

fn maintained_pool() -> (BasicPool<TestApi, Block>, Arc<TestApi>, futures::executor::ThreadPool) {
Expand Down Expand Up @@ -224,7 +224,7 @@ fn should_correctly_prune_transactions_providing_more_than_one_tag() {
api.set_valid_modifier(Box::new(|v: &mut ValidTransaction| {
v.provides.push(vec![155]);
}));
let pool = Pool::new(Default::default(), true.into(), api.clone());
let pool = Pool::new_with_staticly_sized_rotator(Default::default(), true.into(), api.clone());
let xt0 = Arc::from(uxt(Alice, 209));
block_on(pool.submit_one(&api.expect_hash_and_number(0), TSOURCE, xt0.clone()))
.expect("1. Imported");
Expand Down

0 comments on commit 38e7618

Please sign in to comment.