Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

speed up ui tests. #944

Merged
merged 27 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
02db651
speed up ui tests by reducing number of pallets
tadeohepperle May 2, 2023
7c5e091
Merge branch 'master' into tadeo-hepperle-speed-up-tests
tadeohepperle May 2, 2023
2f4fc25
add small and tiny versions of polkadot metadata
tadeohepperle May 3, 2023
7b0c416
Merge branch 'master' into tadeo-hepperle-speed-up-tests
tadeohepperle May 3, 2023
9414fd8
change drop implementation fix test
tadeohepperle May 3, 2023
8a514ee
rust yml add nextest and merge tests
tadeohepperle May 3, 2023
ed667dc
2
tadeohepperle May 3, 2023
7119c69
3
tadeohepperle May 3, 2023
b7f98ec
4
tadeohepperle May 3, 2023
779f628
5
tadeohepperle May 4, 2023
a466d4d
6
tadeohepperle May 4, 2023
b937398
add script for generating files
tadeohepperle May 4, 2023
2d83019
Upgrade to `syn 2.0` (#875)
ascjones May 3, 2023
5f4610e
Metadata V15: Generate Runtime APIs (#918)
lexnv May 3, 2023
605ed70
add small and tiny versions of polkadot metadata
tadeohepperle May 3, 2023
342030c
add script for generating files
tadeohepperle May 4, 2023
29d7e40
merged
tadeohepperle May 4, 2023
2990f3f
new metadata
tadeohepperle May 4, 2023
7bd4bfd
Runtime APIs; don't ask for validation hash anywhere except new_stati…
jsdw May 4, 2023
9e17507
Subxt Guide (#890)
jsdw May 4, 2023
fcf88b6
merge conflict
tadeohepperle May 4, 2023
b07f015
use new metadata files in book
tadeohepperle May 4, 2023
82a5a21
use mtadata full in docs
tadeohepperle May 5, 2023
0b7616a
Merge branch 'master' into tadeo-hepperle-speed-up-tests
tadeohepperle May 11, 2023
a6f2a17
regenerate polkadot.rs
tadeohepperle May 11, 2023
ae211fb
use small metadata in a couple of places
tadeohepperle May 11, 2023
0076855
Update scripts/artifacts.sh
tadeohepperle May 11, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
504 changes: 207 additions & 297 deletions .github/workflows/rust.yml

Large diffs are not rendered by default.

Binary file not shown.
Binary file added artifacts/polkadot_metadata_small.scale
Binary file not shown.
Binary file added artifacts/polkadot_metadata_tiny.scale
Binary file not shown.
2 changes: 1 addition & 1 deletion codegen/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
//! use frame_metadata::RuntimeMetadataPrefixed;
//! use subxt_codegen::{CratePath, DerivesRegistry, TypeSubstitutes};
//!
//! let encoded = fs::read("../artifacts/polkadot_metadata.scale").unwrap();
//! let encoded = fs::read("../artifacts/polkadot_metadata_full.scale").unwrap();
//!
//! // Runtime metadata obtained from a node.
//! let metadata = <RuntimeMetadataPrefixed as Decode>::decode(&mut &*encoded).unwrap();
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/blocks_subscribing.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use futures::StreamExt;
use subxt::{OnlineClient, PolkadotConfig};

#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/constants_static.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use subxt::{OnlineClient, PolkadotConfig};

#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/events.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use subxt::{OnlineClient, PolkadotConfig};

#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/runtime_apis_dynamic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use sp_keyring::AccountKeyring;
use subxt::dynamic::Value;
use subxt::{config::PolkadotConfig, OnlineClient};

#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/runtime_apis_raw.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use subxt::ext::codec::Compact;
use subxt::ext::frame_metadata::RuntimeMetadataPrefixed;
use subxt::{OnlineClient, PolkadotConfig};

#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/runtime_apis_static.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use sp_keyring::AccountKeyring;
use subxt::{config::PolkadotConfig, OnlineClient};

#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/setup_client_offline.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
// 3. Metadata (I'll load it from the downloaded metadata, but you can use
// `subxt metadata > file.scale` to download it):
let metadata = {
let bytes = std::fs::read("./artifacts/polkadot_metadata.scale").unwrap();
let bytes = std::fs::read("./artifacts/polkadot_metadata_small.scale").unwrap();
let metadata = RuntimeMetadataPrefixed::decode(&mut &*bytes).unwrap();
Metadata::try_from(metadata).unwrap()
};
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/storage_fetch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use sp_keyring::AccountKeyring;
use subxt::{OnlineClient, PolkadotConfig};

// Generate an interface that we can use from the node's metadata.
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
3 changes: 1 addition & 2 deletions examples/examples/storage_iterating.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
use subxt::{OnlineClient, PolkadotConfig};

// Generate an interface that we can use from the node's metadata.
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/tx_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use sp_keyring::AccountKeyring;
use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig};

// Generate an interface that we can use from the node's metadata.
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/tx_status_stream.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use subxt::{
};

// Generate an interface that we can use from the node's metadata.
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/tx_with_params.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use sp_keyring::AccountKeyring;
use subxt::config::polkadot::{Era, PlainTip, PolkadotExtrinsicParamsBuilder as Params};
use subxt::{tx::PairSigner, OnlineClient, PolkadotConfig};

#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
#[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
pub mod polkadot {}

#[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion metadata/benches/bench.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use subxt_metadata::{
};

fn load_metadata() -> RuntimeMetadataV15 {
let bytes = fs::read(Path::new("../artifacts/polkadot_metadata.scale"))
let bytes = fs::read(Path::new("../artifacts/polkadot_metadata_full.scale"))
.expect("Cannot read metadata blob");
let meta: RuntimeMetadataPrefixed =
Decode::decode(&mut &*bytes).expect("Cannot decode scale metadata");
Expand Down
2 changes: 1 addition & 1 deletion metadata/src/retain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ mod tests {
use std::{fs, path::Path};

fn load_metadata() -> RuntimeMetadataV15 {
let bytes = fs::read(Path::new("../artifacts/polkadot_metadata.scale"))
let bytes = fs::read(Path::new("../artifacts/polkadot_metadata_full.scale"))
.expect("Cannot read metadata blob");
let meta: RuntimeMetadataPrefixed =
Decode::decode(&mut &*bytes).expect("Cannot decode scale metadata");
Expand Down
21 changes: 21 additions & 0 deletions scripts/artifacts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
# # Generates the 3 metadata files in `/artifacts` and the polkadot.rs file for integration tests
#
# This script is to be run from the root of the repository: `scripts/artifacts.sh`
#
# It expects a local polkadot node to be running a JSON-RPC HTTP server at 127.0.0.1:9933
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The server running on port 9933 is removed

Suggested change
# It expects a local polkadot node to be running a JSON-RPC HTTP server at 127.0.0.1:9933
# It expects a local polkadot node to be running a JSON-RPC server at 127.0.0.1:9944

# A local polkadot node can be run via:
# ```
# git clone https://github.com/paritytech/polkadot.git
# cd polkadot
# cargo build --release
# ./target/release/polkadot --dev --tmp
# ```

# get the full metadata
cargo run --bin subxt metadata --version unstable > artifacts/polkadot_metadata_full.scale
# use it to generate polkadot.rs
cargo run --bin subxt codegen --file artifacts/polkadot_metadata_full.scale | rustfmt > testing/integration-tests/src/codegen/polkadot.rs
# generate a metadata file that only contains the pallets Balances, Staking, System and Multisig
cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets "Balances,Staking,System,Multisig" > artifacts/polkadot_metadata_small.scale
# generate a metadata file that only contains no pallets
cargo run --bin subxt metadata --file artifacts/polkadot_metadata_full.scale --pallets "" > artifacts/polkadot_metadata_tiny.scale
2 changes: 1 addition & 1 deletion subxt/src/book/setup/codegen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
//! Using this macro looks something like:
//!
//! ```rust,no_run
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_tiny.scale")]
//! pub mod polkadot {}
//! ```
//!
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/book/usage/constants.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! ```rust,no_run
//! use sp_keyring::AccountKeyring;
//!
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit: could use the small metadata here?

//! pub mod polkadot {}
//!
//! let constant_query = polkadot::constants().system().block_length();
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/book/usage/runtime_apis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
//! ```rust,no_run
//! use sp_keyring::AccountKeyring;
//!
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
//! pub mod polkadot {}
//!
//! let runtime_call = polkadot::apis().metadata().metadata_versions();
Expand Down
4 changes: 2 additions & 2 deletions subxt/src/book/usage/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
//! ```rust,no_run
//! use sp_keyring::AccountKeyring;
//!
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
//! pub mod polkadot {}
//!
//! let account = AccountKeyring::Alice.to_account_id().into();
Expand All @@ -45,7 +45,7 @@
//! ```rust,no_run
//! use sp_keyring::AccountKeyring;
//!
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
//! pub mod polkadot {}
//!
//! // A static query capable of iterating over accounts:
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/book/usage/transactions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
//! We can use the statically generated interface to build transaction payloads:
//!
//! ```rust,no_run
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_small.scale")]
//! pub mod polkadot {}
//!
//! let remark = "Hello there".as_bytes().to_vec();
Expand Down
18 changes: 9 additions & 9 deletions subxt/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ pub mod ext {
///
/// ```rust,no_run
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// )]
/// mod polkadot {}
/// ```
Expand All @@ -130,7 +130,7 @@ pub mod ext {
/// # pub mod path { pub mod to { pub use subxt; } }
/// # fn main() {}
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// crate = "crate::path::to::subxt"
/// )]
/// mod polkadot {}
Expand All @@ -146,7 +146,7 @@ pub mod ext {
///
/// ```rust
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// substitute_type(path = "sp_arithmetic::per_things::Perbill", with = "crate::Foo")
/// )]
/// mod polkadot {}
Expand Down Expand Up @@ -184,7 +184,7 @@ pub mod ext {
///
/// ```rust,no_run
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// substitute_type(
/// path = "sp_runtime::multiaddress::MultiAddress<A, B>",
/// with = "::subxt::utils::Static<::sp_runtime::MultiAddress<A, B>>"
Expand All @@ -204,7 +204,7 @@ pub mod ext {
///
/// ```rust,no_run
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// derive_for_all_types = "Eq, PartialEq"
/// )]
/// mod polkadot {}
Expand All @@ -220,7 +220,7 @@ pub mod ext {
///
/// ```rust,no_run
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// derive_for_all_types = "Eq, PartialEq",
/// derive_for_type(path = "frame_support::PalletId", derive = "Ord, PartialOrd"),
/// derive_for_type(path = "sp_runtime::ModuleError", derive = "Hash"),
Expand Down Expand Up @@ -248,7 +248,7 @@ pub mod ext {
///
/// ```rust,no_run
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// generate_docs
/// )]
/// mod polkadot {}
Expand All @@ -261,7 +261,7 @@ pub mod ext {
///
/// ```rust,no_run
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// runtime_types_only
/// )]
/// mod polkadot {}
Expand All @@ -273,7 +273,7 @@ pub mod ext {
///
/// ```rust,no_run
/// #[subxt::subxt(
/// runtime_metadata_path = "../artifacts/polkadot_metadata.scale",
/// runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale",
/// runtime_types_only,
/// no_default_derives,
/// derive_for_all_types="codec::Encode, codec::Decode"
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
//! # async fn main() {
//! use subxt::{ PolkadotConfig, OnlineClient, storage::StorageKey };
//!
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
//! pub mod polkadot {}
//!
//! let api = OnlineClient::<PolkadotConfig>::new().await.unwrap();
Expand Down
2 changes: 1 addition & 1 deletion subxt/src/rpc/rpc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
//! # async fn main() {
//! use subxt::{ PolkadotConfig, OnlineClient, storage::StorageKey };
//!
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
//! #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
//! pub mod polkadot {}
//!
//! let api = OnlineClient::<PolkadotConfig>::new().await.unwrap();
Expand Down
4 changes: 2 additions & 2 deletions subxt/src/storage/storage_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ where
/// ```no_run
/// use subxt::{ PolkadotConfig, OnlineClient };
///
/// #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
/// #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
/// pub mod polkadot {}
///
/// # #[tokio::main]
Expand Down Expand Up @@ -172,7 +172,7 @@ where
/// ```no_run
/// use subxt::{ PolkadotConfig, OnlineClient };
///
/// #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata.scale")]
/// #[subxt::subxt(runtime_metadata_path = "../artifacts/polkadot_metadata_full.scale")]
/// pub mod polkadot {}
///
/// # #[tokio::main]
Expand Down
2 changes: 1 addition & 1 deletion testing/integration-tests/src/codegen/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
/// Generate by running this at the root of the repository:
///
/// ```
/// cargo run --bin subxt -- codegen --file artifacts/polkadot_metadata.scale | rustfmt > testing/integration-tests/src/codegen/polkadot.rs
/// cargo run --bin subxt -- codegen --file artifacts/polkadot_metadata_full.scale | rustfmt > testing/integration-tests/src/codegen/polkadot.rs
/// ```
#[rustfmt::skip]
#[allow(clippy::all)]
Expand Down
Loading