mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-12 15:51:12 +00:00
Configurable Config and Extra types (#373)
* WIP config * WIP separate default config * Separate trait impls on client * WIP introduce new ApiConfig (to be renamed) trait * Update generated polkadot codegen * Allow configuring Config and Extra types independently * Add extra default configuration * Revert ir parsing of config attr * Add default-features = false to substrate deps * Revert "Add default-features = false to substrate deps" This reverts commit 099d20cd4cbf8000ff938d1dc090ecbc28a5e788.
This commit is contained in:
@@ -19,8 +19,8 @@ use crate::{
|
||||
balances,
|
||||
runtime_types,
|
||||
system,
|
||||
DefaultConfig,
|
||||
},
|
||||
pair_signer,
|
||||
test_context,
|
||||
};
|
||||
use codec::Decode;
|
||||
@@ -30,20 +30,18 @@ use sp_core::{
|
||||
};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::{
|
||||
extrinsic::{
|
||||
PairSigner,
|
||||
Signer,
|
||||
},
|
||||
DefaultConfig,
|
||||
Error,
|
||||
EventSubscription,
|
||||
PalletError,
|
||||
RuntimeError,
|
||||
Signer,
|
||||
};
|
||||
|
||||
#[async_std::test]
|
||||
async fn tx_basic_transfer() -> Result<(), subxt::Error> {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let bob = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Bob.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let bob = pair_signer(AccountKeyring::Bob.pair());
|
||||
let bob_address = bob.account_id().clone().into();
|
||||
let cxt = test_context().await;
|
||||
let api = &cxt.api;
|
||||
@@ -114,7 +112,7 @@ async fn storage_total_issuance() {
|
||||
|
||||
#[async_std::test]
|
||||
async fn storage_balance_lock() -> Result<(), subxt::Error> {
|
||||
let bob = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Bob.pair());
|
||||
let bob = pair_signer(AccountKeyring::Bob.pair());
|
||||
let charlie = AccountKeyring::Charlie.to_account_id();
|
||||
let cxt = test_context().await;
|
||||
|
||||
@@ -155,9 +153,9 @@ async fn storage_balance_lock() -> Result<(), subxt::Error> {
|
||||
#[async_std::test]
|
||||
async fn transfer_error() {
|
||||
env_logger::try_init().ok();
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let alice_addr = alice.account_id().clone().into();
|
||||
let hans = PairSigner::<DefaultConfig, _>::new(Pair::generate().0);
|
||||
let hans = pair_signer(Pair::generate().0);
|
||||
let hans_address = hans.account_id().clone().into();
|
||||
let cxt = test_context().await;
|
||||
|
||||
@@ -198,7 +196,7 @@ async fn transfer_error() {
|
||||
#[async_std::test]
|
||||
async fn transfer_subscription() {
|
||||
env_logger::try_init().ok();
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let bob = AccountKeyring::Bob.to_account_id();
|
||||
let bob_addr = bob.clone().into();
|
||||
let cxt = test_context().await;
|
||||
@@ -230,7 +228,7 @@ async fn transfer_subscription() {
|
||||
#[async_std::test]
|
||||
async fn transfer_implicit_subscription() {
|
||||
env_logger::try_init().ok();
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let bob = AccountKeyring::Bob.to_account_id();
|
||||
let bob_addr = bob.clone().into();
|
||||
let cxt = test_context().await;
|
||||
|
||||
@@ -24,9 +24,10 @@ use crate::{
|
||||
storage,
|
||||
},
|
||||
system,
|
||||
DefaultConfig,
|
||||
DefaultAccountData,
|
||||
},
|
||||
test_context,
|
||||
NodeRuntimeSignedExtra,
|
||||
TestContext,
|
||||
};
|
||||
use sp_core::sr25519::Pair;
|
||||
@@ -34,6 +35,7 @@ use sp_runtime::MultiAddress;
|
||||
use subxt::{
|
||||
Client,
|
||||
Config,
|
||||
DefaultConfig,
|
||||
Error,
|
||||
PairSigner,
|
||||
TransactionProgress,
|
||||
@@ -41,7 +43,7 @@ use subxt::{
|
||||
|
||||
struct ContractsTestContext {
|
||||
cxt: TestContext,
|
||||
signer: PairSigner<DefaultConfig, Pair>,
|
||||
signer: PairSigner<DefaultConfig, NodeRuntimeSignedExtra, Pair>,
|
||||
}
|
||||
|
||||
type Hash = <DefaultConfig as Config>::Hash;
|
||||
@@ -59,7 +61,9 @@ impl ContractsTestContext {
|
||||
self.cxt.client()
|
||||
}
|
||||
|
||||
fn contracts_tx(&self) -> TransactionApi<DefaultConfig> {
|
||||
fn contracts_tx(
|
||||
&self,
|
||||
) -> TransactionApi<DefaultConfig, NodeRuntimeSignedExtra, DefaultAccountData> {
|
||||
self.cxt.api.tx().contracts()
|
||||
}
|
||||
|
||||
|
||||
@@ -21,8 +21,8 @@ use crate::{
|
||||
ValidatorPrefs,
|
||||
},
|
||||
staking,
|
||||
DefaultConfig,
|
||||
},
|
||||
pair_signer,
|
||||
test_context,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
@@ -32,12 +32,9 @@ use sp_core::{
|
||||
};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::{
|
||||
extrinsic::{
|
||||
PairSigner,
|
||||
Signer,
|
||||
},
|
||||
Error,
|
||||
RuntimeError,
|
||||
Signer,
|
||||
};
|
||||
|
||||
/// Helper function to generate a crypto pair from seed
|
||||
@@ -55,7 +52,7 @@ fn default_validator_prefs() -> ValidatorPrefs {
|
||||
|
||||
#[async_std::test]
|
||||
async fn validate_with_controller_account() {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let cxt = test_context().await;
|
||||
cxt.api
|
||||
.tx()
|
||||
@@ -71,7 +68,7 @@ async fn validate_with_controller_account() {
|
||||
|
||||
#[async_std::test]
|
||||
async fn validate_not_possible_for_stash_account() -> Result<(), Error> {
|
||||
let alice_stash = PairSigner::<DefaultConfig, _>::new(get_from_seed("Alice//stash"));
|
||||
let alice_stash = pair_signer(get_from_seed("Alice//stash"));
|
||||
let cxt = test_context().await;
|
||||
let announce_validator = cxt
|
||||
.api
|
||||
@@ -91,8 +88,8 @@ async fn validate_not_possible_for_stash_account() -> Result<(), Error> {
|
||||
|
||||
#[async_std::test]
|
||||
async fn nominate_with_controller_account() {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let bob = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Bob.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let bob = pair_signer(AccountKeyring::Bob.pair());
|
||||
let cxt = test_context().await;
|
||||
|
||||
cxt.api
|
||||
@@ -109,9 +106,8 @@ async fn nominate_with_controller_account() {
|
||||
|
||||
#[async_std::test]
|
||||
async fn nominate_not_possible_for_stash_account() -> Result<(), Error> {
|
||||
let alice_stash =
|
||||
PairSigner::<DefaultConfig, sr25519::Pair>::new(get_from_seed("Alice//stash"));
|
||||
let bob = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Bob.pair());
|
||||
let alice_stash = pair_signer(get_from_seed("Alice//stash"));
|
||||
let bob = pair_signer(AccountKeyring::Bob.pair());
|
||||
let cxt = test_context().await;
|
||||
|
||||
let nomination = cxt
|
||||
@@ -133,11 +129,9 @@ async fn nominate_not_possible_for_stash_account() -> Result<(), Error> {
|
||||
|
||||
#[async_std::test]
|
||||
async fn chill_works_for_controller_only() -> Result<(), Error> {
|
||||
let alice_stash =
|
||||
PairSigner::<DefaultConfig, sr25519::Pair>::new(get_from_seed("Alice//stash"));
|
||||
let bob_stash =
|
||||
PairSigner::<DefaultConfig, sr25519::Pair>::new(get_from_seed("Bob//stash"));
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice_stash = pair_signer(get_from_seed("Alice//stash"));
|
||||
let bob_stash = pair_signer(get_from_seed("Bob//stash"));
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let cxt = test_context().await;
|
||||
|
||||
// this will fail the second time, which is why this is one test, not two
|
||||
@@ -191,7 +185,7 @@ async fn chill_works_for_controller_only() -> Result<(), Error> {
|
||||
|
||||
#[async_std::test]
|
||||
async fn tx_bond() -> Result<(), Error> {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let cxt = test_context().await;
|
||||
|
||||
let bond = cxt
|
||||
|
||||
@@ -18,19 +18,18 @@ use crate::{
|
||||
node_runtime::{
|
||||
runtime_types,
|
||||
sudo,
|
||||
DefaultConfig,
|
||||
},
|
||||
pair_signer,
|
||||
test_context,
|
||||
};
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::extrinsic::PairSigner;
|
||||
|
||||
type Call = runtime_types::node_runtime::Call;
|
||||
type BalancesCall = runtime_types::pallet_balances::pallet::Call;
|
||||
|
||||
#[async_std::test]
|
||||
async fn test_sudo() -> Result<(), subxt::Error> {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let bob = AccountKeyring::Bob.to_account_id().into();
|
||||
let cxt = test_context().await;
|
||||
|
||||
@@ -56,7 +55,7 @@ async fn test_sudo() -> Result<(), subxt::Error> {
|
||||
|
||||
#[async_std::test]
|
||||
async fn test_sudo_unchecked_weight() -> Result<(), subxt::Error> {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let bob = AccountKeyring::Bob.to_account_id().into();
|
||||
let cxt = test_context().await;
|
||||
|
||||
|
||||
@@ -15,22 +15,17 @@
|
||||
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
use crate::{
|
||||
node_runtime::{
|
||||
system,
|
||||
DefaultConfig,
|
||||
},
|
||||
node_runtime::system,
|
||||
pair_signer,
|
||||
test_context,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use sp_keyring::AccountKeyring;
|
||||
use subxt::extrinsic::{
|
||||
PairSigner,
|
||||
Signer,
|
||||
};
|
||||
use subxt::Signer;
|
||||
|
||||
#[async_std::test]
|
||||
async fn storage_account() -> Result<(), subxt::Error> {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
|
||||
let cxt = test_context().await;
|
||||
let account_info = cxt
|
||||
@@ -46,7 +41,7 @@ async fn storage_account() -> Result<(), subxt::Error> {
|
||||
|
||||
#[async_std::test]
|
||||
async fn tx_remark_with_event() -> Result<(), subxt::Error> {
|
||||
let alice = PairSigner::<DefaultConfig, _>::new(AccountKeyring::Alice.pair());
|
||||
let alice = pair_signer(AccountKeyring::Alice.pair());
|
||||
let cxt = test_context().await;
|
||||
|
||||
let found_event = cxt
|
||||
|
||||
Reference in New Issue
Block a user