mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 13:31:10 +00:00
Put integration tests behind feature flag (#515)
* subxt: Add integration-tests feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Guard integration tests under feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * test-runtime: Place build.rs under feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Pass `integration-tests` feature to `test-runtime` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * CI: Use `integration-tests` feature to run all tests Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Rely on `#[cfg(feature = "integration-tests")]` for integration Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt/metadata: Manually construct test metadata Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * artifacts: Move scale binary blob to dedicated folder Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Update path to metadata blob Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Rely on artifact metadata blob for benches Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * metadata: Remove `test-runtime` dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * examples: Modify runtime path for `custom_type_derives` Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Remove tests folder Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * test-runtime: Remove `integration-tests` feature flag Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * integration-tests: Add an integration test crate for subxt Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Remove `test-runtime` dependency Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Add comment for feature flags Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * integration-tests: Trim dependencies Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * integration-tests: Move dependencies under dev Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * Revert "CI: Use `integration-tests` feature to run all tests" This reverts commit 8e5f38ba8c633ac40420fadf58700ac402f762d4. * integration-tests: Remove integration folder Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Fix feature flag and test comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * subxt: Extra feature flag comment Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io> * integration-tests: Move tests content under src Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
+1
-1
@@ -88,7 +88,7 @@ impl ClientBuilder {
|
||||
/// Set the metadata.
|
||||
///
|
||||
/// *Note:* Metadata will no longer be downloaded from the runtime node.
|
||||
#[cfg(integration_tests)]
|
||||
#[cfg(feature = "integration-tests")]
|
||||
pub fn set_metadata(mut self, metadata: Metadata) -> Self {
|
||||
self.metadata = Some(metadata);
|
||||
self
|
||||
|
||||
@@ -478,13 +478,64 @@ impl TryFrom<RuntimeMetadataPrefixed> for Metadata {
|
||||
mod tests {
|
||||
use super::*;
|
||||
use crate::StorageEntryKey;
|
||||
use frame_metadata::{
|
||||
ExtrinsicMetadata,
|
||||
PalletStorageMetadata,
|
||||
StorageEntryModifier,
|
||||
StorageEntryType,
|
||||
};
|
||||
use scale_info::{
|
||||
meta_type,
|
||||
TypeInfo,
|
||||
};
|
||||
|
||||
fn load_metadata() -> Metadata {
|
||||
let bytes = test_runtime::METADATA;
|
||||
let meta: RuntimeMetadataPrefixed =
|
||||
codec::Decode::decode(&mut &*bytes).expect("Cannot decode scale metadata");
|
||||
#[allow(dead_code)]
|
||||
#[allow(non_camel_case_types)]
|
||||
#[derive(TypeInfo)]
|
||||
enum Call {
|
||||
fill_block { param: u128 },
|
||||
}
|
||||
let storage = PalletStorageMetadata {
|
||||
prefix: "System",
|
||||
entries: vec![StorageEntryMetadata {
|
||||
name: "Account",
|
||||
modifier: StorageEntryModifier::Optional,
|
||||
ty: StorageEntryType::Plain(meta_type::<u32>()),
|
||||
default: vec![0],
|
||||
docs: vec![],
|
||||
}],
|
||||
};
|
||||
let constant = PalletConstantMetadata {
|
||||
name: "BlockWeights",
|
||||
ty: meta_type::<u32>(),
|
||||
value: vec![1, 2, 3],
|
||||
docs: vec![],
|
||||
};
|
||||
let pallet = frame_metadata::PalletMetadata {
|
||||
index: 0,
|
||||
name: "System",
|
||||
calls: Some(frame_metadata::PalletCallMetadata {
|
||||
ty: meta_type::<Call>(),
|
||||
}),
|
||||
storage: Some(storage),
|
||||
constants: vec![constant],
|
||||
event: None,
|
||||
error: None,
|
||||
};
|
||||
|
||||
Metadata::try_from(meta)
|
||||
let metadata = RuntimeMetadataV14::new(
|
||||
vec![pallet],
|
||||
ExtrinsicMetadata {
|
||||
ty: meta_type::<()>(),
|
||||
version: 0,
|
||||
signed_extensions: vec![],
|
||||
},
|
||||
meta_type::<()>(),
|
||||
);
|
||||
let prefixed = RuntimeMetadataPrefixed::from(metadata);
|
||||
|
||||
Metadata::try_from(prefixed)
|
||||
.expect("Cannot translate runtime metadata to internal Metadata")
|
||||
}
|
||||
|
||||
@@ -501,10 +552,10 @@ mod tests {
|
||||
hash
|
||||
);
|
||||
|
||||
// Currently the caching does not take into account different pallets
|
||||
// as the intended behavior is to use this method only once.
|
||||
// Enforce this behavior into testing.
|
||||
let hash_old = metadata.metadata_hash(&["Balances"]);
|
||||
// The cache `metadata.inner.cached_metadata_hash` is already populated from
|
||||
// the previous call. Therefore, changing the pallets argument must not
|
||||
// change the methods behavior.
|
||||
let hash_old = metadata.metadata_hash(&["no-pallet"]);
|
||||
assert_eq!(hash_old, hash);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user