mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-18 06:01:02 +00:00
polkadot-node-subsystems: ChainApiBackend added + polkadot-debug image version fixed (#2411)
The out-dated version (bad tag) of [polkadot image](https://github.com/paritytech/polkadot-sdk/blob/ede4a362622dfa69eb167eaa876246b1289f4b41/.gitlab/pipeline/zombienet/cumulus.yml#L31) ([docker info](https://hub.docker.com/layers/paritypr/polkadot-debug/master/images/sha256:adb1658052cf671b50c90d5cece5c7a131efa1a95978249bd5cb85a5ad654f7a?context=explore)) was used. This PR fixes this. See also: https://github.com/paritytech/polkadot-sdk/pull/2411#issuecomment-1822632724 Also adds an abstraction that allows asynchronous backends to be passed to `ChainApiSubsystem` --------- Co-authored-by: Sebastian Kunert <skunert49@gmail.com>
This commit is contained in:
committed by
GitHub
parent
0956357b60
commit
49874882cf
@@ -22,7 +22,8 @@ use std::collections::BTreeMap;
|
||||
|
||||
use polkadot_node_primitives::BlockWeight;
|
||||
use polkadot_node_subsystem_test_helpers::{make_subsystem_context, TestSubsystemContextHandle};
|
||||
use polkadot_primitives::{BlockNumber, Hash, Header};
|
||||
use polkadot_node_subsystem_types::ChainApiBackend;
|
||||
use polkadot_primitives::{Block, BlockNumber, Hash, Header};
|
||||
use sp_blockchain::Info as BlockInfo;
|
||||
use sp_core::testing::TaskExecutor;
|
||||
|
||||
@@ -110,7 +111,7 @@ fn last_key_value<K: Clone, V: Clone>(map: &BTreeMap<K, V>) -> (K, V) {
|
||||
map.iter().last().map(|(k, v)| (k.clone(), v.clone())).unwrap()
|
||||
}
|
||||
|
||||
impl HeaderBackend<Block> for TestClient {
|
||||
impl sp_blockchain::HeaderBackend<Block> for TestClient {
|
||||
fn info(&self) -> BlockInfo<Block> {
|
||||
let genesis_hash = self.blocks.iter().next().map(|(h, _)| *h).unwrap();
|
||||
let (best_hash, best_number) = last_key_value(&self.blocks);
|
||||
@@ -191,8 +192,8 @@ fn request_block_number() {
|
||||
async move {
|
||||
let zero = Hash::zero();
|
||||
let test_cases = [
|
||||
(TWO, client.number(TWO).unwrap()),
|
||||
(zero, client.number(zero).unwrap()), // not here
|
||||
(TWO, client.number(TWO).await.unwrap()),
|
||||
(zero, client.number(zero).await.unwrap()), // not here
|
||||
];
|
||||
for (hash, expected) in &test_cases {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -217,8 +218,10 @@ fn request_block_header() {
|
||||
test_harness(|client, mut sender| {
|
||||
async move {
|
||||
const NOT_HERE: Hash = Hash::repeat_byte(0x5);
|
||||
let test_cases =
|
||||
[(TWO, client.header(TWO).unwrap()), (NOT_HERE, client.header(NOT_HERE).unwrap())];
|
||||
let test_cases = [
|
||||
(TWO, client.header(TWO).await.unwrap()),
|
||||
(NOT_HERE, client.header(NOT_HERE).await.unwrap()),
|
||||
];
|
||||
for (hash, expected) in &test_cases {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
@@ -270,8 +273,8 @@ fn request_finalized_hash() {
|
||||
test_harness(|client, mut sender| {
|
||||
async move {
|
||||
let test_cases = [
|
||||
(1, client.hash(1).unwrap()), // not here
|
||||
(2, client.hash(2).unwrap()),
|
||||
(1, client.hash(1).await.unwrap()), // not here
|
||||
(2, client.hash(2).await.unwrap()),
|
||||
];
|
||||
for (number, expected) in &test_cases {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
@@ -297,7 +300,7 @@ fn request_last_finalized_number() {
|
||||
async move {
|
||||
let (tx, rx) = oneshot::channel();
|
||||
|
||||
let expected = client.info().finalized_number;
|
||||
let expected = client.info().await.unwrap().finalized_number;
|
||||
sender
|
||||
.send(FromOrchestra::Communication {
|
||||
msg: ChainApiMessage::FinalizedBlockNumber(tx),
|
||||
|
||||
Reference in New Issue
Block a user