mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 02:51:08 +00:00
testing: Prepare light client testing with substrate binary and add subxt-test macro (#1507)
* testing: Add long running light client flag and cfg aliases
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Expose clients depending on feature flags
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* subxt: Use unstable backend for light client
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Disable flaky lightclient tests
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* ci: Add long runnnig step
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Revert "subxt: Use unstable backend for light client"
This reverts commit ea6f3cc58b.
* ci: Long running tests for 60 mins
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* ci: Use 16 cores for light-client testing
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* ci: Isolate light-client testing to save CI minutes
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Retry on Tx::Dropped for lightclinet only
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Wait for more blocks for the lightclient init
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* subxt: Use unstable backend for light client
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Disable legacy RPC tests
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Disable sudo and contracts tests
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Retry constructing lightclient on read-proof errors
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Disable tx dynamic test
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* proc-macro: Timeout for tests
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Add timeout 800 seconds
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* proc-macro/tests: Adjust subxt-test proc-macro
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* proc-macro: Rename crate to subxt-test-proc-macro
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Use default subxt-proc-macro timeout
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* light-client: Remove println
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* subxt: Remove tokio as dependency, use it only for testing
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Chagne default timeout to 6 seconds
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* proc-macro: Add env timeout variable
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* ci: Add subxt env var for controling test timeouts
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests/tx-retries: Retry on `Non node available` error
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Use unstable backend for testing lightclient
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Remove old lightclient object
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* testing: Adjust for the new interface
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* backend/rpc: Allow older version of the initialized event
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* rpc/tests: Check initialized decodes correctly
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* ci: Reset workflow
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Apply cargo fmt
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Remove unused dep
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Remove gitmerge old file
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* Remove unused dep
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* rename proc-macro to subxt-test-macro
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests: Remove txretries for lightclient
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests: Wait for 5 blocks for the lightclient full testing suite
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* tests: Group imports
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
* macro: Rename const value
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
---------
Signed-off-by: Alexandru Vasile <alexandru.vasile@parity.io>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
use crate::{
|
||||
node_runtime::{self, balances, runtime_types, system},
|
||||
test_context,
|
||||
subxt_test, test_context,
|
||||
};
|
||||
use codec::Decode;
|
||||
use subxt::{
|
||||
@@ -13,7 +13,7 @@ use subxt::{
|
||||
};
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn tx_basic_transfer() -> Result<(), subxt::Error> {
|
||||
let alice = dev::alice();
|
||||
let bob = dev::bob();
|
||||
@@ -45,12 +45,18 @@ async fn tx_basic_transfer() -> Result<(), subxt::Error> {
|
||||
.balances()
|
||||
.transfer_allow_death(bob_address, 10_000);
|
||||
|
||||
let events = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.await?
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
let events = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
|
||||
let event = events
|
||||
.find_first::<balances::events::Transfer>()
|
||||
.expect("Failed to decode balances::events::Transfer")
|
||||
@@ -85,7 +91,8 @@ async fn tx_basic_transfer() -> Result<(), subxt::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[cfg(fullclient)]
|
||||
#[subxt_test]
|
||||
async fn tx_dynamic_transfer() -> Result<(), subxt::Error> {
|
||||
use subxt::ext::scale_value::{At, Composite, Value};
|
||||
|
||||
@@ -207,7 +214,7 @@ async fn tx_dynamic_transfer() -> Result<(), subxt::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn multiple_sequential_transfers_work() -> Result<(), subxt::Error> {
|
||||
let alice = dev::alice();
|
||||
let bob = dev::bob();
|
||||
@@ -232,9 +239,15 @@ async fn multiple_sequential_transfers_work() -> Result<(), subxt::Error> {
|
||||
.balances()
|
||||
.transfer_allow_death(bob_address.clone(), 10_000);
|
||||
for _ in 0..3 {
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.await?
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
}
|
||||
@@ -250,7 +263,7 @@ async fn multiple_sequential_transfers_work() -> Result<(), subxt::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn storage_total_issuance() {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -267,7 +280,7 @@ async fn storage_total_issuance() {
|
||||
assert_ne!(total_issuance, 0);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn storage_balance_lock() -> Result<(), subxt::Error> {
|
||||
let bob_signer = dev::bob();
|
||||
let bob: AccountId32 = dev::bob().public_key().into();
|
||||
@@ -279,9 +292,15 @@ async fn storage_balance_lock() -> Result<(), subxt::Error> {
|
||||
runtime_types::pallet_staking::RewardDestination::Stash,
|
||||
);
|
||||
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &bob_signer)
|
||||
.await?
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.create_signed(&tx, &bob_signer, Default::default())
|
||||
.await?;
|
||||
|
||||
signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await?
|
||||
.find_first::<system::events::ExtrinsicSuccess>()?
|
||||
@@ -308,7 +327,7 @@ async fn storage_balance_lock() -> Result<(), subxt::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn transfer_error() {
|
||||
let alice = dev::alice();
|
||||
let alice_addr = alice.public_key().into();
|
||||
@@ -324,8 +343,13 @@ async fn transfer_error() {
|
||||
.balances()
|
||||
.transfer_allow_death(alice_addr, 100_000_000_000_000_000);
|
||||
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&to_bob_tx, &alice)
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.create_signed(&to_bob_tx, &alice, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
@@ -334,9 +358,14 @@ async fn transfer_error() {
|
||||
|
||||
// When we try giving all of the funds back, Bob doesn't have
|
||||
// anything left to pay transfer fees, so we hit an error.
|
||||
let res = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&to_alice_tx, &bob)
|
||||
.create_signed(&to_alice_tx, &bob, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let res = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
@@ -353,7 +382,7 @@ async fn transfer_error() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn transfer_implicit_subscription() {
|
||||
let alice = dev::alice();
|
||||
let bob: AccountId32 = dev::bob().public_key().into();
|
||||
@@ -364,9 +393,14 @@ async fn transfer_implicit_subscription() {
|
||||
.balances()
|
||||
.transfer_allow_death(bob.clone().into(), 10_000);
|
||||
|
||||
let event = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&to_bob_tx, &alice)
|
||||
.create_signed(&to_bob_tx, &alice, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
let event = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
@@ -386,7 +420,7 @@ async fn transfer_implicit_subscription() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn constant_existential_deposit() {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
|
||||
@@ -9,10 +9,10 @@ use crate::{
|
||||
runtime_types::{pallet_contracts::wasm::Determinism, sp_weights::weight_v2::Weight},
|
||||
system,
|
||||
},
|
||||
test_context, TestContext,
|
||||
subxt_test, test_context, TestClient, TestConfig, TestContext,
|
||||
};
|
||||
use subxt::ext::futures::StreamExt;
|
||||
use subxt::{tx::TxProgress, utils::MultiAddress, Config, Error, OnlineClient, SubstrateConfig};
|
||||
use subxt::{tx::TxProgress, utils::MultiAddress, Config, Error};
|
||||
use subxt_signer::sr25519::{self, dev};
|
||||
|
||||
struct ContractsTestContext {
|
||||
@@ -20,8 +20,8 @@ struct ContractsTestContext {
|
||||
signer: sr25519::Keypair,
|
||||
}
|
||||
|
||||
type Hash = <SubstrateConfig as Config>::Hash;
|
||||
type AccountId = <SubstrateConfig as Config>::AccountId;
|
||||
type Hash = <TestConfig as Config>::Hash;
|
||||
type AccountId = <TestConfig as Config>::AccountId;
|
||||
|
||||
/// A dummy contract which does nothing at all.
|
||||
const CONTRACT: &str = r#"
|
||||
@@ -42,7 +42,7 @@ impl ContractsTestContext {
|
||||
Self { cxt, signer }
|
||||
}
|
||||
|
||||
fn client(&self) -> OnlineClient<SubstrateConfig> {
|
||||
fn client(&self) -> TestClient {
|
||||
self.cxt.client()
|
||||
}
|
||||
|
||||
@@ -54,11 +54,16 @@ impl ContractsTestContext {
|
||||
.contracts()
|
||||
.upload_code(code, None, Determinism::Enforced);
|
||||
|
||||
let events = self
|
||||
let signed_extrinsic = self
|
||||
.client()
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&upload_tx, &self.signer)
|
||||
.await?
|
||||
.create_signed(&upload_tx, &self.signer, Default::default())
|
||||
.await?;
|
||||
|
||||
let events = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
|
||||
@@ -84,11 +89,16 @@ impl ContractsTestContext {
|
||||
vec![], // salt
|
||||
);
|
||||
|
||||
let events = self
|
||||
let signed_extrinsic = self
|
||||
.client()
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&instantiate_tx, &self.signer)
|
||||
.await?
|
||||
.create_signed(&instantiate_tx, &self.signer, Default::default())
|
||||
.await?;
|
||||
|
||||
let events = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
|
||||
@@ -126,11 +136,15 @@ impl ContractsTestContext {
|
||||
salt,
|
||||
);
|
||||
|
||||
let result = self
|
||||
let signed_extrinsic = self
|
||||
.client()
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&instantiate_tx, &self.signer)
|
||||
.await?
|
||||
.create_signed(&instantiate_tx, &self.signer, Default::default())
|
||||
.await?;
|
||||
let result = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
|
||||
@@ -146,7 +160,7 @@ impl ContractsTestContext {
|
||||
&self,
|
||||
contract: AccountId,
|
||||
input_data: Vec<u8>,
|
||||
) -> Result<TxProgress<SubstrateConfig, OnlineClient<SubstrateConfig>>, Error> {
|
||||
) -> Result<TxProgress<TestConfig, TestClient>, Error> {
|
||||
tracing::info!("call: {:?}", contract);
|
||||
let call_tx = node_runtime::tx().contracts().call(
|
||||
MultiAddress::Id(contract),
|
||||
@@ -170,7 +184,7 @@ impl ContractsTestContext {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn tx_instantiate_with_code() {
|
||||
let ctx = ContractsTestContext::init().await;
|
||||
let result = ctx.instantiate_with_code().await;
|
||||
@@ -181,7 +195,7 @@ async fn tx_instantiate_with_code() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn tx_instantiate() {
|
||||
let ctx = ContractsTestContext::init().await;
|
||||
let code_hash = ctx.upload_code().await.unwrap();
|
||||
@@ -194,7 +208,7 @@ async fn tx_instantiate() {
|
||||
);
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn tx_call() {
|
||||
let cxt = ContractsTestContext::init().await;
|
||||
let (_, contract) = cxt.instantiate_with_code().await.unwrap();
|
||||
|
||||
@@ -5,8 +5,11 @@
|
||||
//! Test interactions with some built-in FRAME pallets.
|
||||
|
||||
mod balances;
|
||||
mod contracts;
|
||||
mod staking;
|
||||
mod sudo;
|
||||
mod system;
|
||||
mod timestamp;
|
||||
|
||||
#[cfg(fullclient)]
|
||||
mod contracts;
|
||||
#[cfg(fullclient)]
|
||||
mod sudo;
|
||||
|
||||
@@ -11,7 +11,7 @@ use crate::{
|
||||
},
|
||||
staking,
|
||||
},
|
||||
test_context,
|
||||
subxt_test, test_context,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use subxt::error::{DispatchError, Error};
|
||||
@@ -34,7 +34,7 @@ fn default_validator_prefs() -> ValidatorPrefs {
|
||||
}
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn validate_with_stash_account() {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -45,8 +45,14 @@ async fn validate_with_stash_account() {
|
||||
.staking()
|
||||
.validate(default_validator_prefs());
|
||||
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice_stash)
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.create_signed(&tx, &alice_stash, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
@@ -54,7 +60,7 @@ async fn validate_with_stash_account() {
|
||||
.expect("should be successful");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn validate_not_possible_for_controller_account() -> Result<(), Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -65,12 +71,18 @@ async fn validate_not_possible_for_controller_account() -> Result<(), Error> {
|
||||
.staking()
|
||||
.validate(default_validator_prefs());
|
||||
|
||||
let announce_validator = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.await?
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
let announce_validator = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await;
|
||||
|
||||
assert_matches!(announce_validator, Err(Error::Runtime(DispatchError::Module(err))) => {
|
||||
let details = err.details().unwrap();
|
||||
assert_eq!(details.pallet.name(), "Staking");
|
||||
@@ -79,7 +91,7 @@ async fn validate_not_possible_for_controller_account() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn nominate_with_stash_account() {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -91,8 +103,14 @@ async fn nominate_with_stash_account() {
|
||||
.staking()
|
||||
.nominate(vec![bob.public_key().to_address()]);
|
||||
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice_stash)
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.create_signed(&tx, &alice_stash, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
|
||||
signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
@@ -100,7 +118,7 @@ async fn nominate_with_stash_account() {
|
||||
.expect("should be successful");
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn nominate_not_possible_for_controller_account() -> Result<(), Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -112,9 +130,13 @@ async fn nominate_not_possible_for_controller_account() -> Result<(), Error> {
|
||||
.staking()
|
||||
.nominate(vec![bob.public_key().to_address()]);
|
||||
|
||||
let nomination = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await
|
||||
.unwrap();
|
||||
let nomination = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
@@ -128,7 +150,7 @@ async fn nominate_not_possible_for_controller_account() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn chill_works_for_stash_only() -> Result<(), Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -141,9 +163,15 @@ async fn chill_works_for_stash_only() -> Result<(), Error> {
|
||||
let nominate_tx = node_runtime::tx()
|
||||
.staking()
|
||||
.nominate(vec![bob_stash.public_key().to_address()]);
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&nominate_tx, &alice_stash)
|
||||
.await?
|
||||
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.create_signed(&nominate_tx, &alice_stash, Default::default())
|
||||
.await?;
|
||||
signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
|
||||
@@ -161,10 +189,15 @@ async fn chill_works_for_stash_only() -> Result<(), Error> {
|
||||
|
||||
let chill_tx = node_runtime::tx().staking().chill();
|
||||
|
||||
let chill = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&chill_tx, &alice)
|
||||
.await?
|
||||
.create_signed(&chill_tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
let chill = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await
|
||||
.unwrap()
|
||||
.wait_for_finalized_success()
|
||||
.await;
|
||||
|
||||
@@ -174,19 +207,23 @@ async fn chill_works_for_stash_only() -> Result<(), Error> {
|
||||
assert_eq!(&details.variant.name, "NotController");
|
||||
});
|
||||
|
||||
let is_chilled = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&chill_tx, &alice_stash)
|
||||
.create_signed(&chill_tx, &alice_stash, Default::default())
|
||||
.await?;
|
||||
let is_chilled = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await?
|
||||
.wait_for_finalized_success()
|
||||
.await?
|
||||
.has::<staking::events::Chilled>()?;
|
||||
|
||||
assert!(is_chilled);
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn tx_bond() -> Result<(), Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -197,18 +234,24 @@ async fn tx_bond() -> Result<(), Error> {
|
||||
.staking()
|
||||
.bond(100_000_000_000_000, RewardDestination::Stash);
|
||||
|
||||
let bond = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&bond_tx, &alice)
|
||||
.create_signed(&bond_tx, &alice, Default::default())
|
||||
.await?;
|
||||
let bond = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await?
|
||||
.wait_for_finalized_success()
|
||||
.await;
|
||||
|
||||
assert!(bond.is_ok());
|
||||
|
||||
let bond_again = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&bond_tx, &alice)
|
||||
.create_signed(&bond_tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
let bond_again = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await?
|
||||
.wait_for_finalized_success()
|
||||
.await;
|
||||
@@ -221,7 +264,7 @@ async fn tx_bond() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn storage_history_depth() -> Result<(), Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -231,7 +274,7 @@ async fn storage_history_depth() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn storage_current_era() -> Result<(), Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -246,7 +289,7 @@ async fn storage_current_era() -> Result<(), Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn storage_era_reward_points() -> Result<(), Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
|
||||
@@ -8,14 +8,14 @@ use crate::{
|
||||
runtime_types::{self, sp_weights::weight_v2::Weight},
|
||||
sudo,
|
||||
},
|
||||
test_context,
|
||||
subxt_test, test_context,
|
||||
};
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
type Call = runtime_types::kitchensink_runtime::RuntimeCall;
|
||||
type BalancesCall = runtime_types::pallet_balances::pallet::Call;
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn test_sudo() -> Result<(), subxt::Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -29,9 +29,13 @@ async fn test_sudo() -> Result<(), subxt::Error> {
|
||||
});
|
||||
let tx = node_runtime::tx().sudo().sudo(call);
|
||||
|
||||
let found_event = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
let found_event = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await?
|
||||
.wait_for_finalized_success()
|
||||
.await?
|
||||
@@ -41,7 +45,7 @@ async fn test_sudo() -> Result<(), subxt::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn test_sudo_unchecked_weight() -> Result<(), subxt::Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -61,9 +65,13 @@ async fn test_sudo_unchecked_weight() -> Result<(), subxt::Error> {
|
||||
},
|
||||
);
|
||||
|
||||
let found_event = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
let found_event = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await?
|
||||
.wait_for_finalized_success()
|
||||
.await?
|
||||
|
||||
@@ -4,12 +4,12 @@
|
||||
|
||||
use crate::{
|
||||
node_runtime::{self, system},
|
||||
test_context,
|
||||
subxt_test, test_context,
|
||||
};
|
||||
use assert_matches::assert_matches;
|
||||
use subxt_signer::sr25519::dev;
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn storage_account() -> Result<(), subxt::Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -31,7 +31,7 @@ async fn storage_account() -> Result<(), subxt::Error> {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn tx_remark_with_event() -> Result<(), subxt::Error> {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
@@ -42,9 +42,13 @@ async fn tx_remark_with_event() -> Result<(), subxt::Error> {
|
||||
.system()
|
||||
.remark_with_event(b"remarkable".to_vec());
|
||||
|
||||
let found_event = api
|
||||
let signed_extrinsic = api
|
||||
.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.create_signed(&tx, &alice, Default::default())
|
||||
.await?;
|
||||
|
||||
let found_event = signed_extrinsic
|
||||
.submit_and_watch()
|
||||
.await?
|
||||
.wait_for_finalized_success()
|
||||
.await?
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
// This file is dual-licensed as Apache-2.0 or GPL-3.0.
|
||||
// see LICENSE for license details.
|
||||
|
||||
use crate::{node_runtime, test_context};
|
||||
use crate::{node_runtime, subxt_test, test_context};
|
||||
|
||||
#[tokio::test]
|
||||
#[subxt_test]
|
||||
async fn storage_get_current_timestamp() {
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
|
||||
Reference in New Issue
Block a user