mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-04-30 21:17:56 +00:00
Split RPCs into a separate crate (#1910)
* WIP extract RPCs into separate crate * fmt * Fix test * Remove unused deps * fix import * WIP: Fix up errors and most tests. Start extracintg some tests/code to rpc crate * MockRpcClient sync or async * MockRpcClient only async but better type inference * WIP MockRpcClient FnMuts and some test updates to use it * Get all but one test working with new MockRpcClient * WIP trying to debug failure * WIP, Tests mostly fixed, need to add back oen more * Get mock RPC tests working * fmt * fmt * Clippy and comment tweak * update CI to explicitly check subxt-rpc features * clippy * small tweaks after pass over * feature flag rename * update some docs * Fix some examples * fmt * Fix features flags to work with web/wasm32 * Fix unused dep warning * explicit targets in wasm CI * Add better crate level docs * fmt * Address review comments * Comment out flaky test for now and make more obvious how similar POlkadot and Substrate configs are * Not a doc comment * Remove unused imports
This commit is contained in:
@@ -21,8 +21,6 @@ use subxt::{
|
||||
#[cfg(fullclient)]
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
use subxt_metadata::Metadata;
|
||||
|
||||
#[cfg(fullclient)]
|
||||
#[subxt_test]
|
||||
async fn block_subscriptions_are_consistent_with_eachother() -> Result<(), subxt::Error> {
|
||||
@@ -164,14 +162,17 @@ async fn runtime_api_call() -> Result<(), subxt::Error> {
|
||||
|
||||
// get metadata via state_call.
|
||||
let (_, meta1) = rt
|
||||
.call_raw::<(Compact<u32>, Metadata)>("Metadata_metadata", None)
|
||||
.call_raw::<(Compact<u32>, frame_metadata::RuntimeMetadataPrefixed)>(
|
||||
"Metadata_metadata",
|
||||
None,
|
||||
)
|
||||
.await?;
|
||||
|
||||
// get metadata via `state_getMetadata`.
|
||||
let meta2 = rpc.state_get_metadata(Some(block.hash())).await?;
|
||||
let meta2_bytes = rpc.state_get_metadata(Some(block.hash())).await?.into_raw();
|
||||
|
||||
// They should be the same.
|
||||
assert_eq!(meta1.encode(), meta2.encode());
|
||||
assert_eq!(meta1.encode(), meta2_bytes);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
@@ -2,10 +2,8 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use std::collections::HashSet;
|
||||
|
||||
use crate::{
|
||||
subxt_test, test_context, test_context_reconnecting_rpc_client,
|
||||
subxt_test, test_context,
|
||||
utils::{node_runtime, wait_for_blocks},
|
||||
};
|
||||
use codec::{Decode, Encode};
|
||||
@@ -412,10 +410,20 @@ async fn partial_fee_estimate_correct() {
|
||||
assert_eq!(partial_fee_1, partial_fee_2);
|
||||
}
|
||||
|
||||
// This test runs OK locally but fails sporadically in CI eg:
|
||||
//
|
||||
// https://github.com/paritytech/subxt/actions/runs/13374953009/job/37353887719?pr=1910#step:7:178
|
||||
// https://github.com/paritytech/subxt/actions/runs/13385878645/job/37382498200#step:6:163
|
||||
//
|
||||
// While those errors were timeouts, I also saw errors like "intersections size is 1".
|
||||
/*
|
||||
#[subxt_test(timeout = 300)]
|
||||
async fn chainhead_block_subscription_reconnect() {
|
||||
use std::collections::HashSet;
|
||||
use crate::test_context_reconnecting_rpc_client;
|
||||
|
||||
let ctx = test_context_reconnecting_rpc_client().await;
|
||||
let api = ctx.chainhead_backend().await;
|
||||
let api = ctx.chainhead_backend().await;ccc
|
||||
let chainhead_client_blocks = move |num: usize| {
|
||||
let api = api.clone();
|
||||
async move {
|
||||
@@ -428,7 +436,7 @@ async fn chainhead_block_subscription_reconnect() {
|
||||
let disconnected = match item {
|
||||
Ok(_) => false,
|
||||
Err(e) => {
|
||||
if matches!(e, Error::Rpc(subxt::error::RpcError::DisconnectedWillReconnect(e)) if e.contains("Missed at least one block when the connection was lost")) {
|
||||
if e.is_disconnected_will_reconnect() && e.to_string().contains("Missed at least one block when the connection was lost") {
|
||||
missed_blocks = true;
|
||||
}
|
||||
e.is_disconnected_will_reconnect()
|
||||
@@ -463,3 +471,4 @@ async fn chainhead_block_subscription_reconnect() {
|
||||
assert!(intersection >= 3, "intersections size is {}", intersection);
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
@@ -13,14 +13,14 @@ use assert_matches::assert_matches;
|
||||
use codec::Encode;
|
||||
use futures::Stream;
|
||||
use subxt::{
|
||||
backend::chain_head::rpc_methods::{
|
||||
FollowEvent, Initialized, MethodResponse, RuntimeEvent, RuntimeVersionEvent, StorageQuery,
|
||||
StorageQueryType,
|
||||
},
|
||||
config::Hasher,
|
||||
utils::{AccountId32, MultiAddress},
|
||||
SubstrateConfig,
|
||||
};
|
||||
use subxt_rpcs::methods::chain_head::{
|
||||
FollowEvent, Initialized, MethodResponse, RuntimeEvent, RuntimeVersionEvent, StorageQuery,
|
||||
StorageQueryType,
|
||||
};
|
||||
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
@@ -293,7 +293,8 @@ async fn transactionwatch_v1_submit_and_watch() {
|
||||
/// Ignore block related events and obtain the next event related to an operation.
|
||||
async fn next_operation_event<
|
||||
T: serde::de::DeserializeOwned,
|
||||
S: Unpin + Stream<Item = Result<FollowEvent<T>, subxt::Error>>,
|
||||
S: Unpin + Stream<Item = Result<FollowEvent<T>, E>>,
|
||||
E: core::fmt::Debug,
|
||||
>(
|
||||
sub: &mut S,
|
||||
) -> FollowEvent<T> {
|
||||
|
||||
Reference in New Issue
Block a user