mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-08 21:48:02 +00:00
Merge branch 'master' into staking
This commit is contained in:
@@ -142,19 +142,17 @@ mod tests {
|
||||
});
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_state_total_issuance() {
|
||||
env_logger::try_init().ok();
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
let total_issuance = client.total_issuance(None).await.unwrap();
|
||||
assert_ne!(total_issuance, 0);
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_state_read_free_balance() {
|
||||
env_logger::try_init().ok();
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
let account = AccountKeyring::Alice.to_account_id();
|
||||
let info = client.account(&account, None).await.unwrap();
|
||||
assert_ne!(info.data.free, 0);
|
||||
|
||||
+37
-19
@@ -41,6 +41,9 @@
|
||||
#[macro_use]
|
||||
extern crate substrate_subxt_proc_macro;
|
||||
|
||||
#[cfg(feature = "client")]
|
||||
pub use substrate_subxt_client as client;
|
||||
|
||||
pub use sp_core;
|
||||
pub use sp_runtime;
|
||||
|
||||
@@ -436,6 +439,7 @@ impl codec::Encode for Encoded {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use sp_core::{
|
||||
storage::{
|
||||
well_known_keys,
|
||||
@@ -447,24 +451,44 @@ mod tests {
|
||||
AccountKeyring,
|
||||
Ed25519Keyring,
|
||||
};
|
||||
use substrate_subxt_client::{
|
||||
DatabaseConfig,
|
||||
Role,
|
||||
SubxtClient,
|
||||
SubxtClientConfig,
|
||||
};
|
||||
use tempdir::TempDir;
|
||||
|
||||
use super::*;
|
||||
|
||||
pub(crate) async fn test_client() -> Client<crate::DefaultNodeRuntime> {
|
||||
ClientBuilder::new()
|
||||
pub(crate) async fn test_client() -> (Client<crate::NodeTemplateRuntime>, TempDir) {
|
||||
let tmp = TempDir::new("subxt-").expect("failed to create tempdir");
|
||||
let config = SubxtClientConfig {
|
||||
impl_name: "substrate-subxt-full-client",
|
||||
impl_version: "0.0.1",
|
||||
author: "substrate subxt",
|
||||
copyright_start_year: 2020,
|
||||
db: DatabaseConfig::RocksDb {
|
||||
path: tmp.path().into(),
|
||||
cache_size: 128,
|
||||
},
|
||||
builder: node_template::service::new_full,
|
||||
chain_spec: node_template::chain_spec::development_config(),
|
||||
role: Role::Authority(AccountKeyring::Alice),
|
||||
};
|
||||
let client = ClientBuilder::new()
|
||||
.set_client(SubxtClient::new(config).expect("Error creating subxt client"))
|
||||
.build()
|
||||
.await
|
||||
.expect("Error creating client")
|
||||
.expect("Error creating client");
|
||||
(client, tmp)
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_tx_transfer_balance() {
|
||||
env_logger::try_init().ok();
|
||||
let mut signer = PairSigner::new(AccountKeyring::Alice.pair());
|
||||
let dest = AccountKeyring::Bob.to_account_id().into();
|
||||
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
let nonce = client
|
||||
.account(&AccountKeyring::Alice.to_account_id(), None)
|
||||
.await
|
||||
@@ -497,24 +521,21 @@ mod tests {
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_getting_hash() {
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
client.block_hash(None).await.unwrap();
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_getting_block() {
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
let block_hash = client.block_hash(None).await.unwrap();
|
||||
client.block(block_hash).await.unwrap();
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_getting_read_proof() {
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
let block_hash = client.block_hash(None).await.unwrap();
|
||||
client
|
||||
.read_proof(
|
||||
@@ -529,29 +550,26 @@ mod tests {
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_chain_subscribe_blocks() {
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
let mut blocks = client.subscribe_blocks().await.unwrap();
|
||||
blocks.next().await;
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_chain_subscribe_finalized_blocks() {
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
let mut blocks = client.subscribe_finalized_blocks().await.unwrap();
|
||||
blocks.next().await;
|
||||
}
|
||||
|
||||
#[async_std::test]
|
||||
#[ignore] // requires locally running substrate node
|
||||
async fn test_create_raw_payload() {
|
||||
let signer_pair = Ed25519Keyring::Alice.pair();
|
||||
let signer_account_id = Ed25519Keyring::Alice.to_account_id();
|
||||
let dest = AccountKeyring::Bob.to_account_id().into();
|
||||
|
||||
let client = test_client().await;
|
||||
let (client, _) = test_client().await;
|
||||
|
||||
// create raw payload with AccoundId and sign it
|
||||
let raw_payload = client
|
||||
|
||||
@@ -157,6 +157,31 @@ impl Session for DefaultNodeRuntime {
|
||||
|
||||
impl Contracts for DefaultNodeRuntime {}
|
||||
|
||||
/// Concrete type definitions compatible with the node template.
|
||||
///
|
||||
/// # Note
|
||||
///
|
||||
/// Main difference is `type Address = AccountId`.
|
||||
/// Also the contracts module is not part of the node template runtime.
|
||||
#[derive(Debug, Clone, Eq, PartialEq)]
|
||||
pub struct NodeTemplateRuntime;
|
||||
|
||||
impl System for NodeTemplateRuntime {
|
||||
type Index = u32;
|
||||
type BlockNumber = u32;
|
||||
type Hash = sp_core::H256;
|
||||
type Hashing = BlakeTwo256;
|
||||
type AccountId = <<MultiSignature as Verify>::Signer as IdentifyAccount>::AccountId;
|
||||
type Address = Self::AccountId;
|
||||
type Header = Header<Self::BlockNumber, BlakeTwo256>;
|
||||
type Extrinsic = OpaqueExtrinsic;
|
||||
type AccountData = AccountData<<Self as Balances>::Balance>;
|
||||
}
|
||||
|
||||
impl Balances for NodeTemplateRuntime {
|
||||
type Balance = u128;
|
||||
}
|
||||
|
||||
/// Concrete type definitions compatible with those for kusama, v0.7
|
||||
///
|
||||
/// # Note
|
||||
|
||||
Reference in New Issue
Block a user