Skip to content

Commit

Permalink
move test to cargo test
Browse files Browse the repository at this point in the history
  • Loading branch information
haerdib committed Dec 19, 2023
1 parent f97c588 commit 567fc60
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down
2 changes: 1 addition & 1 deletion examples/examples/check_extrinsic_events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<DefaultRuntimeConfig, _>::new(client).unwrap();
let signer = AccountKeyring::Alice.pair();
api.set_signer(ExtrinsicSigner::<DefaultRuntimeConfig>::new(signer));
}
}
6 changes: 2 additions & 4 deletions testing/examples/chain_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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,
};
Expand All @@ -26,9 +26,7 @@ use substrate_api_client::{
async fn main() {
// Setup
let client = JsonrpseeClient::with_default_url().unwrap();
let mut api = Api::<DefaultRuntimeConfig, _>::new(client).unwrap();
let signer = AccountKeyring::Alice.pair();
api.set_signer(ExtrinsicSigner::<DefaultRuntimeConfig>::new(signer));
let mut api = Api::<AssetRuntimeConfig, _>::new(client).unwrap();

// GetChainInfo
let finalized_header_hash = api.get_finalized_head().unwrap().unwrap();
Expand Down

0 comments on commit 567fc60

Please sign in to comment.