From 567fc607d70bfc23a751012d4f6f56d68cea1e2d Mon Sep 17 00:00:00 2001 From: haerdib Date: Tue, 19 Dec 2023 11:01:04 +0100 Subject: [PATCH] move test to cargo test --- Cargo.lock | 1 + Cargo.toml | 1 + examples/examples/check_extrinsic_events.rs | 2 +- src/lib.rs | 16 ++++++++++++++++ testing/examples/chain_tests.rs | 6 ++---- 5 files changed, 21 insertions(+), 5 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 5b1622ae8..247785058 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -6386,6 +6386,7 @@ dependencies = [ "serde", "serde_json", "sp-core", + "sp-keyring", "sp-runtime", "sp-runtime-interface", "sp-storage", diff --git a/Cargo.toml b/Cargo.toml index a1530d1a4..d9c8d7f28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -66,6 +66,7 @@ ac-node-api = { path = "node-api", features = ["mocks"] } kitchensink-runtime = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" } scale-info = { version = "2.1.1", features = ["derive"] } test-case = "3.1.0" +sp-keyring = { git = "https://github.com/paritytech/polkadot-sdk.git", branch = "master" } [features] default = ["std", "jsonrpsee-client", "sync-api"] diff --git a/examples/examples/check_extrinsic_events.rs b/examples/examples/check_extrinsic_events.rs index 43ac6c3cd..3a4bdfcb7 100644 --- a/examples/examples/check_extrinsic_events.rs +++ b/examples/examples/check_extrinsic_events.rs @@ -16,7 +16,7 @@ use sp_keyring::AccountKeyring; use substrate_api_client::{ ac_node_api::EventDetails, - ac_primitives::{AssetRuntimeConfig, Config, ExtrinsicSigner}, + ac_primitives::{AssetRuntimeConfig, Config}, extrinsic::BalancesExtrinsics, rpc::JsonrpseeClient, Api, GetAccountInformation, SubmitAndWatch, TransactionStatus, XtStatus, diff --git a/src/lib.rs b/src/lib.rs index c9d52a5f6..1974790ba 100755 --- a/src/lib.rs +++ b/src/lib.rs @@ -38,3 +38,19 @@ pub fn storage_key(module: &str, storage_key_name: &str) -> StorageKey { key.extend(twox_128(storage_key_name.as_bytes())); StorageKey(key) } + +#[cfg(test)] +mod tests { + use super::*; + use ac_primitives::{DefaultRuntimeConfig, ExtrinsicSigner}; + use rpc::TungsteniteRpcClient; + use sp_keyring::AccountKeyring; + + #[test] + fn test_extrinsic_signer_conversion() { + let client = TungsteniteRpcClient::with_default_url(1); + let mut api = Api::::new(client).unwrap(); + let signer = AccountKeyring::Alice.pair(); + api.set_signer(ExtrinsicSigner::::new(signer)); + } +} diff --git a/testing/examples/chain_tests.rs b/testing/examples/chain_tests.rs index 973a725ba..ca10828ff 100644 --- a/testing/examples/chain_tests.rs +++ b/testing/examples/chain_tests.rs @@ -17,7 +17,7 @@ use sp_keyring::AccountKeyring; use substrate_api_client::{ - ac_primitives::{DefaultRuntimeConfig, ExtrinsicSigner}, + ac_primitives::AssetRuntimeConfig, rpc::{HandleSubscription, JsonrpseeClient}, Api, GetChainInfo, SubscribeChain, }; @@ -26,9 +26,7 @@ use substrate_api_client::{ async fn main() { // Setup let client = JsonrpseeClient::with_default_url().unwrap(); - let mut api = Api::::new(client).unwrap(); - let signer = AccountKeyring::Alice.pair(); - api.set_signer(ExtrinsicSigner::::new(signer)); + let mut api = Api::::new(client).unwrap(); // GetChainInfo let finalized_header_hash = api.get_finalized_head().unwrap().unwrap();