Fix tests

This commit is contained in:
Demi M. Obenour
2020-09-11 15:40:45 -04:00
parent dd15f22f38
commit d3865a613e
5 changed files with 54 additions and 86 deletions
+23 -23
View File
@@ -26,11 +26,11 @@ log = "0.4.11"
thiserror = "1.0.20"
futures = "0.3.5"
jsonrpsee = { version = "0.1.0", features = ["ws"] }
num-traits = { version = "0.2.12" }
num-traits = "0.2.12"
serde = { version = "1.0.115", features = ["derive"] }
serde_json = "1.0.57"
url = "2.1.1"
codec = { package = "parity-scale-codec", version = "1.3.4", features = ["derive", "full"] }
codec = { package = "parity-scale-codec", version = "1.3.5", features = ["derive", "full"] }
frame-metadata = { version = "11.0.0-rc6", package = "frame-metadata" }
frame-support = { version = "2.0.0-rc6", package = "frame-support" }
@@ -40,11 +40,11 @@ pallet-indices = { version = "2.0.0-rc6", package = "pallet-indices" }
hex = "0.4.2"
sp-std = "2.0.0-rc6"
application-crypto = { version = "2.0.0-rc6", package = "sp-application-crypto" }
sp-finality-grandpa = { version = "2.0.0-rc6" }
sp-finality-grandpa = "2.0.0-rc6"
sp-consensus-babe = "0.8.0-rc6"
pallet-im-online = { version = "2.0.0-rc6" }
sp-authority-discovery = { version = "2.0.0-rc6" }
pallet-staking = { version = "2.0.0-rc6" }
pallet-im-online = "2.0.0-rc6"
sp-authority-discovery = "2.0.0-rc6"
pallet-staking = "2.0.0-rc6"
sp-rpc = { version = "2.0.0-rc6", package = "sp-rpc" }
sp-core = { version = "2.0.0-rc6", package = "sp-core" }
@@ -64,20 +64,20 @@ tempdir = "0.3.7"
test-node = { path = "test-node" }
wabt = "0.10.0"
[patch.crates-io]
frame-metadata = { git = "https://github.com/paritytech/substrate" }
frame-support = { git = "https://github.com/paritytech/substrate" }
sp-runtime = { git = "https://github.com/paritytech/substrate" }
sp-version = { git = "https://github.com/paritytech/substrate" }
pallet-indices = { git = "https://github.com/paritytech/substrate" }
sp-rpc = { git = "https://github.com/paritytech/substrate" }
sp-core = { git = "https://github.com/paritytech/substrate" }
sc-rpc-api = { git = "https://github.com/paritytech/substrate" }
sp-transaction-pool = { git = "https://github.com/paritytech/substrate" }
sp-std = { git = "https://github.com/paritytech/substrate" }
application-crypto = { git = "https://github.com/paritytech/substrate", package = "sp-application-crypto", default-features = false }
sp-finality-grandpa = { git = "https://github.com/paritytech/substrate" }
sp-consensus-babe = { git = "https://github.com/paritytech/substrate" }
pallet-im-online = { git = "https://github.com/paritytech/substrate" }
sp-authority-discovery = { git = "https://github.com/paritytech/substrate" }
pallet-staking = { git = "https://github.com/paritytech/substrate" }
# [patch.crates-io]
# frame-metadata = { git = "https://github.com/paritytech/substrate" }
# frame-support = { git = "https://github.com/paritytech/substrate" }
# sp-runtime = { git = "https://github.com/paritytech/substrate" }
# sp-version = { git = "https://github.com/paritytech/substrate" }
# pallet-indices = { git = "https://github.com/paritytech/substrate" }
# sp-rpc = { git = "https://github.com/paritytech/substrate" }
# sp-core = { git = "https://github.com/paritytech/substrate" }
# sc-rpc-api = { git = "https://github.com/paritytech/substrate" }
# sp-transaction-pool = { git = "https://github.com/paritytech/substrate" }
# sp-std = { git = "https://github.com/paritytech/substrate" }
# application-crypto = { git = "https://github.com/paritytech/substrate", package = "sp-application-crypto", default-features = false }
# sp-finality-grandpa = { git = "https://github.com/paritytech/substrate" }
# sp-consensus-babe = { git = "https://github.com/paritytech/substrate" }
# pallet-im-online = { git = "https://github.com/paritytech/substrate" }
# sp-authority-discovery = { git = "https://github.com/paritytech/substrate" }
# pallet-staking = { git = "https://github.com/paritytech/substrate" }
+11 -8
View File
@@ -1,12 +1,12 @@
// Copyright 2019-2020 Parity Technologies (UK) Ltd.
// This file is part of substrate-subxt.
//
// subxt is free software: you can redistribute it and/or modify
// substrate-subxt is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// subxt is distributed in the hope that it will be useful,
// substrate-subxt is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
@@ -32,7 +32,9 @@ use std::{
};
use substrate_subxt_proc_macro::Store;
macro_rules! def {
/// Impls `Default::default` for some types that have a `_runtime` field of type
/// `PhantomData` as their only field.
macro_rules! default_impl {
($name:ident) => {
impl<T: Session> Default for $name<T> {
fn default() -> Self {
@@ -50,7 +52,7 @@ pub trait Session: System {
/// The validator account identifier type for the runtime.
type ValidatorId: Parameter + Debug + Ord + Default + Send + Sync + 'static;
/// The validator account identifier type for the runtime.
/// The session index identifier type for the runtime.
type SessionIndex: Parameter + Debug + Ord + Default + Send + Sync + 'static;
/// The keys.
@@ -65,7 +67,7 @@ pub struct ValidatorsStore<T: Session> {
pub _runtime: PhantomData<T>,
}
def!(ValidatorsStore);
default_impl!(ValidatorsStore);
/// Current index of the session.
#[derive(Encode, Store, Debug)]
@@ -75,7 +77,7 @@ pub struct CurrentIndexStore<T: Session> {
pub _runtime: PhantomData<T>,
}
def!(CurrentIndexStore);
default_impl!(CurrentIndexStore);
/// True if the underlying economic identities or weighting behind the validators
/// has changed in the queued validator set.
@@ -86,9 +88,9 @@ pub struct QueuedChangedStore<T: Session> {
pub _runtime: PhantomData<T>,
}
def!(QueuedChangedStore);
default_impl!(QueuedChangedStore);
/// The current set of validators.
/// Set the session keys for a validator.
#[derive(Encode, Call, Debug)]
pub struct SetKeysCall<T: Session> {
/// The keys
@@ -103,6 +105,7 @@ mod tests {
use crate::tests::test_client;
#[async_std::test]
#[ignore]
async fn test_state_read_free_balance() {
env_logger::try_init().ok();
let (client, _) = test_client().await;
+14 -49
View File
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with substrate-subxt. If not, see <http://www.gnu.org/licenses/>.
//! Implements support for the frame_staking module.
//! Implements support for the pallet_staking module.
use super::balances::{
Balances,
@@ -51,7 +51,7 @@ pub use pallet_staking::{
///
/// This is keyed first by the era index to allow bulk deletion and then the stash account.
///
/// Is it removed after `HISTORY_DEPTH` eras.
/// It is removed after `HISTORY_DEPTH` eras.
#[derive(Encode, Decode, Debug, Store)]
pub struct ErasValidatorPrefsStore<T: Staking> {
#[store(returns = ValidatorPrefs)]
@@ -76,7 +76,7 @@ pub struct ErasRewardPointsStore<T: Staking> {
#[derive(Clone, Encode, Decode, Debug, Call)]
pub struct SetPayeeCall<T: Staking> {
/// The payee
pub payee: RewardDestination<T::AccountId>,
pub payee: RewardDestination,
/// Marker for the runtime
pub _runtime: PhantomData<T>,
}
@@ -111,13 +111,13 @@ pub trait Staking: Balances {
const MAX_NOMINATORS: usize;
}
/// Just a Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked.
/// A Balance/BlockNumber tuple to encode when a chunk of funds will be unlocked.
#[derive(Clone, Encode, Decode, Debug)]
pub struct UnlockChunk<T: Staking> {
/// Amount of funds to be unlocked.
#[codec(compact)]
pub value: T::Balance,
/// Era number at which point it'll be unlocked.
/// Era number at which point the funds will be unlocked.
#[codec(compact)]
pub era: EraIndex,
}
@@ -183,7 +183,7 @@ pub struct LedgerStore<T: Staking> {
/// Where the reward payment should be made. Keyed by stash.
#[derive(Encode, Copy, Clone, Debug, Hash, PartialEq, Eq, Ord, PartialOrd, Store)]
pub struct PayeeStore<T: Staking> {
#[store(returns = RewardDestination<T::AccountId>)]
#[store(returns = RewardDestination)]
/// Tٗhe stash account
pub stash: T::AccountId,
}
@@ -235,7 +235,7 @@ pub struct EraRewardPoints<AccountId: Ord> {
///
/// This is keyed fist by the era index to allow bulk deletion and then the stash account.
///
/// Is it removed after `HISTORY_DEPTH` eras.
/// It is removed after `HISTORY_DEPTH` eras.
/// If stakers hasn't been set or has been removed then empty exposure is returned.
#[derive(Encode, Copy, Clone, Debug, Store)]
pub struct ErasStakersClippedStore<T: Staking> {
@@ -246,7 +246,7 @@ pub struct ErasStakersClippedStore<T: Staking> {
pub validator_stash: T::AccountId,
}
/// The active era information, it holds index and start.
/// The active era information, holds index and start.
///
/// The active era is the era currently rewarded.
/// Validator set of this era must be equal to `SessionInterface::validators`.
@@ -259,21 +259,10 @@ pub struct ActiveEraStore<T: Staking> {
/// Declare no desire to either validate or nominate.
///
/// Effects will be felt at the beginning of the next era.
/// Effective at the beginning of the next era.
///
/// The dispatch origin for this call must be _Signed_ by the controller, not the stash.
/// And, it can be only called when [`EraElectionStatus`] is `Closed`.
///
/// # <weight>
/// - Independent of the arguments. Insignificant complexity.
/// - Contains one read.
/// - Writes are limited to the `origin` account key.
/// --------
/// Base Weight: 16.53 µs
/// DB Weight:
/// - Read: EraElectionStatus, Ledger
/// - Write: Validators, Nominators
/// # </weight>
/// Can only be called when [`EraElectionStatus`] is `Closed`.
#[derive(Debug, Call, Encode)]
pub struct ChillCall<T: Staking> {
/// Runtime marker
@@ -298,21 +287,10 @@ impl<T: Staking> Copy for ChillCall<T> {}
/// Declare the desire to validate for the origin controller.
///
/// Effects will be felt at the beginning of the next era.
/// Effective at the beginning of the next era.
///
/// The dispatch origin for this call must be _Signed_ by the controller, not the stash.
/// And, it can be only called when [`EraElectionStatus`] is `Closed`.
///
/// # <weight>
/// - Independent of the arguments. Insignificant complexity.
/// - Contains a limited number of reads.
/// - Writes are limited to the `origin` account key.
/// -----------
/// Base Weight: 17.13 µs
/// DB Weight:
/// - Read: Era Election Status, Ledger
/// - Write: Nominators, Validators
/// # </weight>
/// Can only be called when [`EraElectionStatus`] is `Closed`.
#[derive(Clone, Debug, PartialEq, Call, Encode)]
pub struct ValidateCall<T: Staking> {
/// Runtime marker
@@ -323,23 +301,10 @@ pub struct ValidateCall<T: Staking> {
/// Declare the desire to nominate `targets` for the origin controller.
///
/// Effects will be felt at the beginning of the next era. This can only be called when
/// [`EraElectionStatus`] is `Closed`.
/// Effective at the beginning of the next era.
///
/// The dispatch origin for this call must be _Signed_ by the controller, not the stash.
/// And, it can be only called when [`EraElectionStatus`] is `Closed`.
///
/// # <weight>
/// - The transaction's complexity is proportional to the size of `targets` (N)
/// which is capped at CompactAssignments::LIMIT (MAX_NOMINATIONS).
/// - Both the reads and writes follow a similar pattern.
/// ---------
/// Base Weight: 22.34 + .36 * N µs
/// where N is the number of targets
/// DB Weight:
/// - Reads: Era Election Status, Ledger, Current Era
/// - Writes: Validators, Nominators
/// # </weight>
/// Can only be called when [`EraElectionStatus`] is `Closed`.
#[derive(Call, Encode, Debug)]
pub struct NominateCall<T: Staking> {
/// The targets that are being nominated
+4 -4
View File
@@ -94,7 +94,7 @@ pub use crate::{
rpc::{
BlockNumber,
ExtrinsicSuccess,
Properties,
SystemProperties,
},
runtimes::*,
subscription::*,
@@ -167,7 +167,7 @@ impl<T: Runtime> ClientBuilder<T> {
rpc.metadata(),
rpc.genesis_hash(),
rpc.runtime_version(None),
rpc.properties(),
rpc.system_properties(),
)
.await;
Ok(Client {
@@ -187,7 +187,7 @@ pub struct Client<T: Runtime> {
rpc: Rpc<T>,
genesis_hash: T::Hash,
metadata: Metadata,
properties: Properties,
properties: SystemProperties,
runtime_version: RuntimeVersion,
_marker: PhantomData<(fn() -> T::Signature, T::Extra)>,
page_size: u32,
@@ -265,7 +265,7 @@ impl<T: Runtime> Client<T> {
}
/// Returns the system properties
pub fn properties(&self) -> &Properties {
pub fn properties(&self) -> &SystemProperties {
&self.properties
}
+2 -2
View File
@@ -99,7 +99,7 @@ impl From<u32> for BlockNumber {
#[derive(serde::Serialize, serde::Deserialize, Debug, Clone, PartialEq, Eq, Default)]
#[serde(rename_all = "camelCase")]
/// System properties for a Substrate-based runtime
pub struct Properties {
pub struct SystemProperties {
/// The address format
pub ss58_format: u8,
/// The number of digits after the decimal point in the native token
@@ -221,7 +221,7 @@ impl<T: Runtime> Rpc<T> {
}
/// Fetch system properties
pub async fn properties(&self) -> Result<Properties, Error> {
pub async fn system_properties(&self) -> Result<SystemProperties, Error> {
Ok(self
.client
.request("system_properties", Params::None)