mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 00:31:07 +00:00
Build LongestChain with TestClientBuilder (#2792)
* Switch to `TestClientBuilder` and support generating LongestChain * Make sure test-client works without the wasm blob * Use `TestClientBuilder` in more places
This commit is contained in:
@@ -634,12 +634,12 @@ impl<Factory: ServiceFactory> Components for LightComponents<Factory> {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use consensus_common::BlockOrigin;
|
||||
use client::LongestChain;
|
||||
use substrate_test_client::{TestClient, AccountKeyring, runtime::Transfer};
|
||||
use substrate_test_client::{TestClient, AccountKeyring, runtime::Transfer, TestClientBuilder};
|
||||
|
||||
#[test]
|
||||
fn should_remove_transactions_from_the_pool() {
|
||||
let client = Arc::new(substrate_test_client::new());
|
||||
let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain();
|
||||
let client = Arc::new(client);
|
||||
let pool = TransactionPool::new(Default::default(), ::transaction_pool::ChainApi::new(client.clone()));
|
||||
let transaction = Transfer {
|
||||
amount: 5,
|
||||
@@ -647,9 +647,7 @@ mod tests {
|
||||
from: AccountKeyring::Alice.into(),
|
||||
to: Default::default(),
|
||||
}.into_signed_tx();
|
||||
#[allow(deprecated)]
|
||||
let best = LongestChain::new(client.backend().clone(), client.import_lock())
|
||||
.best_chain().unwrap();
|
||||
let best = longest_chain.best_chain().unwrap();
|
||||
|
||||
// store the transaction in the pool
|
||||
pool.submit_one(&BlockId::hash(best.hash()), transaction.clone()).unwrap();
|
||||
|
||||
@@ -749,21 +749,20 @@ macro_rules! construct_service_factory {
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use client::LongestChain;
|
||||
use consensus_common::SelectChain;
|
||||
use runtime_primitives::traits::BlindCheckable;
|
||||
use substrate_test_client::{AccountKeyring, runtime::{Extrinsic, Transfer}};
|
||||
use substrate_test_client::{AccountKeyring, runtime::{Extrinsic, Transfer}, TestClientBuilder};
|
||||
|
||||
#[test]
|
||||
fn should_not_propagate_transactions_that_are_marked_as_such() {
|
||||
// given
|
||||
let client = Arc::new(substrate_test_client::new());
|
||||
let (client, longest_chain) = TestClientBuilder::new().build_with_longest_chain();
|
||||
let client = Arc::new(client);
|
||||
let pool = Arc::new(TransactionPool::new(
|
||||
Default::default(),
|
||||
transaction_pool::ChainApi::new(client.clone())
|
||||
));
|
||||
let best = LongestChain::new(client.backend().clone(), client.import_lock())
|
||||
.best_chain().unwrap();
|
||||
let best = longest_chain.best_chain().unwrap();
|
||||
let transaction = Transfer {
|
||||
amount: 5,
|
||||
nonce: 0,
|
||||
|
||||
Reference in New Issue
Block a user