This commit is contained in:
David Palm
2020-09-15 23:41:28 +02:00
parent b3687af2bf
commit 303c5f4742
4 changed files with 90 additions and 1 deletions
+1 -1
View File
@@ -1,3 +1,3 @@
#!/bin/sh
NODE_TEMPLATE=../target/release/test-node
$NODE_TEMPLATE --chain=dev-chain.json --alice
$NODE_TEMPLATE --chain=dev-chain.json --alice -lrpc=debug
+62
View File
@@ -195,3 +195,65 @@ pub struct NominateCall<T: Staking> {
/// The targets that are being nominated
pub targets: Vec<T::Address>,
}
#[cfg(test)]
mod tests {
use super::*;
use crate::{
// events::EventsDecoder,
extrinsic::PairSigner,
// subscription::EventSubscription,
// system::AccountStoreExt,
// tests::{test_client, TestRuntime},
runtimes::KusamaRuntime as RT,
ClientBuilder,
// frame::staking::NominateCallExt,
// frame::staking::CurrentEraStoreExt,
// frame::staking::CurrentEraStore,
// frame::staking::HistoryDepthStore,
// runtimes::StakingRuntime as RT,
};
// use sp_core::{sr25519::Pair, Pair as _};
use sp_keyring::AccountKeyring;
use core::marker::PhantomData;
use crate::frame::balances::*;
use crate::frame::system::*;
use crate::extrinsic::Signer;
#[async_std::test]
async fn test_nominate() {
env_logger::try_init().ok();
let alice = PairSigner::<RT, _>::new(AccountKeyring::Alice.pair());
let bob = PairSigner::<RT, _>::new(AccountKeyring::Bob.pair());
let client = ClientBuilder::<RT>::new()
.build()
.await
.unwrap();
println!("HAVE CLIENT");
let current_era = client.current_era(None).await;
println!("Current era: {:?}", current_era);
let hd = client.history_depth(None).await;
println!("History depth: {:?}", hd);
let total_issuance = client.total_issuance(None).await;
println!("total issuance: {:?}", total_issuance);
let alice_account = client.account(&alice.account_id(), None).await;
println!("Alice's account info: {:?}", alice_account);
let o = client.nominate(&alice, vec![bob.account_id().clone()]).await;
println!("Nom nom: {:?}", o);
// let event = client.
// current_era()
// .await;
// println!("Current era: {:?}", event);
// let (client, _) = test_client().await;
// let event = client.
// nominate_and_watch(&alice, vec![AccountKeyring::Bob.to_account_id()])
// .await
// .unwrap();
// // .nominate()
// // .unwrap()
// // .unwrap();
// dbg!(event);
}
}
+1
View File
@@ -20,6 +20,7 @@ pallet-aura = { version = "2.0.0-rc6", default-features = false }
pallet-balances = { version = "2.0.0-rc6", default-features = false }
pallet-grandpa = { version = "2.0.0-rc6", default-features = false }
pallet-randomness-collective-flip = { version = "2.0.0-rc6", default-features = false }
pallet-staking = { version = "2.0.0-rc6", default-features = false }
pallet-sudo = { version = "2.0.0-rc6", default-features = false }
pallet-timestamp = { version = "2.0.0-rc6", default-features = false }
pallet-transaction-payment = { version = "2.0.0-rc6", default-features = false }
+26
View File
@@ -82,6 +82,7 @@ pub use frame_support::{
StorageValue,
};
pub use pallet_balances::Call as BalancesCall;
pub use pallet_staking::Call as StakingCall;
pub use pallet_timestamp::Call as TimestampCall;
#[cfg(any(feature = "std", test))]
pub use sp_runtime::BuildStorage;
@@ -305,6 +306,31 @@ impl pallet_sudo::Trait for Runtime {
type Call = Call;
}
// impl pallet_staking::Trait for Runtime {
// type Currency = Balances;
// type UnixTime = pallet_timestamp::Module<Self>;
// type CurrencyToVote = CurrencyToVoteHandler;
// type RewardRemainder = ();
// type Event = ();
// type Slash = ();
// type Reward = ();
// type SessionsPerEra = ();
// type SlashDeferDuration = ();
// type SlashCancelOrigin = frame_system::EnsureRoot<Self::AccountId>;
// type BondingDuration = ();
// type SessionInterface = Self;
// type RewardCurve = RewardCurve;
// type NextNewSession = Session;
// type ElectionLookahead = ();
// type Call = Call;
// type MaxIterations = MaxIterations;
// type MinSolutionScoreBump = ();
// type MaxNominatorRewardedPerValidator = MaxNominatorRewardedPerValidator;
// type UnsignedPriority = ();
// type WeightInfo = ();
// }
construct_runtime!(
pub enum Runtime where
Block = Block,