Move Subxt crate into a subfolder (#424)

* move into subfolder step 1

* Make folders a workspace again

* Move examples into their own workspace crate to make them more visible and easier to run

* clippy fix

* newline

* tweak releasing steps for folder move

* reference exampels more clearly in top level readme
This commit is contained in:
James Wilson
2022-02-02 12:15:44 +00:00
committed by GitHub
parent 171f4ec268
commit 55f04c20a7
44 changed files with 94 additions and 62 deletions
+272
View File
@@ -0,0 +1,272 @@
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// 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,
// 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.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use crate::{
node_runtime::{
balances,
runtime_types,
system,
DispatchError,
},
pair_signer,
test_context,
};
use codec::Decode;
use sp_core::{
sr25519::Pair,
Pair as _,
};
use sp_keyring::AccountKeyring;
use subxt::{
DefaultConfig,
Error,
EventSubscription,
Signer,
};
#[async_std::test]
async fn tx_basic_transfer() -> Result<(), subxt::Error<DispatchError>> {
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;
let alice_pre = api
.storage()
.system()
.account(alice.account_id().clone(), None)
.await?;
let bob_pre = api
.storage()
.system()
.account(bob.account_id().clone(), None)
.await?;
let events = api
.tx()
.balances()
.transfer(bob_address, 10_000)
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await?;
let event = events
.find_first_event::<balances::events::Transfer>()
.expect("Failed to decode balances::events::Transfer")
.expect("Failed to find balances::events::Transfer");
let _extrinsic_success = events
.find_first_event::<system::events::ExtrinsicSuccess>()
.expect("Failed to decode ExtrinisicSuccess")
.expect("Failed to find ExtrinisicSuccess");
let expected_event = balances::events::Transfer {
from: alice.account_id().clone(),
to: bob.account_id().clone(),
amount: 10_000,
};
assert_eq!(event, expected_event);
let alice_post = api
.storage()
.system()
.account(alice.account_id().clone(), None)
.await?;
let bob_post = api
.storage()
.system()
.account(bob.account_id().clone(), None)
.await?;
assert!(alice_pre.data.free - 10_000 >= alice_post.data.free);
assert_eq!(bob_pre.data.free + 10_000, bob_post.data.free);
Ok(())
}
#[async_std::test]
async fn storage_total_issuance() {
let cxt = test_context().await;
let total_issuance = cxt
.api
.storage()
.balances()
.total_issuance(None)
.await
.unwrap();
assert_ne!(total_issuance, 0);
}
#[async_std::test]
async fn storage_balance_lock() -> Result<(), subxt::Error<DispatchError>> {
let bob = pair_signer(AccountKeyring::Bob.pair());
let charlie = AccountKeyring::Charlie.to_account_id();
let cxt = test_context().await;
cxt.api
.tx()
.staking()
.bond(
charlie.into(),
100_000_000_000_000,
runtime_types::pallet_staking::RewardDestination::Stash,
)
.sign_and_submit_then_watch(&bob)
.await?
.wait_for_finalized_success()
.await?
.find_first_event::<system::events::ExtrinsicSuccess>()?
.expect("No ExtrinsicSuccess Event found");
let locks = cxt
.api
.storage()
.balances()
.locks(AccountKeyring::Bob.to_account_id(), None)
.await?;
assert_eq!(
locks.0,
vec![runtime_types::pallet_balances::BalanceLock {
id: *b"staking ",
amount: 100_000_000_000_000,
reasons: runtime_types::pallet_balances::Reasons::All,
}]
);
Ok(())
}
#[async_std::test]
async fn transfer_error() {
env_logger::try_init().ok();
let alice = pair_signer(AccountKeyring::Alice.pair());
let alice_addr = alice.account_id().clone().into();
let hans = pair_signer(Pair::generate().0);
let hans_address = hans.account_id().clone().into();
let cxt = test_context().await;
cxt.api
.tx()
.balances()
.transfer(hans_address, 100_000_000_000_000_000)
.sign_and_submit_then_watch(&alice)
.await
.unwrap()
.wait_for_finalized_success()
.await
.unwrap();
let res = cxt
.api
.tx()
.balances()
.transfer(alice_addr, 100_000_000_000_000_000)
.sign_and_submit_then_watch(&hans)
.await
.unwrap()
.wait_for_finalized_success()
.await;
if let Err(Error::Runtime(err)) = res {
let details = err.inner().details().unwrap();
assert_eq!(details.pallet, "Balances");
assert_eq!(details.error, "InsufficientBalance");
} else {
panic!("expected a runtime module error");
}
}
#[async_std::test]
async fn transfer_subscription() {
env_logger::try_init().ok();
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;
let sub = cxt.client().rpc().subscribe_events().await.unwrap();
let decoder = cxt.client().events_decoder();
let mut sub = EventSubscription::<DefaultConfig>::new(sub, decoder);
sub.filter_event::<balances::events::Transfer>();
cxt.api
.tx()
.balances()
.transfer(bob_addr, 10_000)
.sign_and_submit_then_watch(&alice)
.await
.unwrap();
let raw = sub.next().await.unwrap().unwrap();
let event = balances::events::Transfer::decode(&mut &raw.data[..]).unwrap();
assert_eq!(
event,
balances::events::Transfer {
from: alice.account_id().clone(),
to: bob.clone(),
amount: 10_000
}
);
}
#[async_std::test]
async fn transfer_implicit_subscription() {
env_logger::try_init().ok();
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;
let event = cxt
.api
.tx()
.balances()
.transfer(bob_addr, 10_000)
.sign_and_submit_then_watch(&alice)
.await
.unwrap()
.wait_for_finalized_success()
.await
.unwrap()
.find_first_event::<balances::events::Transfer>()
.expect("Can decode events")
.expect("Can find balance transfer event");
assert_eq!(
event,
balances::events::Transfer {
from: alice.account_id().clone(),
to: bob.clone(),
amount: 10_000
}
);
}
#[async_std::test]
async fn constant_existential_deposit() {
let cxt = test_context().await;
let balances_metadata = cxt.client().metadata().pallet("Balances").unwrap();
let constant_metadata = balances_metadata.constant("ExistentialDeposit").unwrap();
let existential_deposit = u128::decode(&mut &constant_metadata.value[..]).unwrap();
assert_eq!(existential_deposit, 100_000_000_000_000);
assert_eq!(
existential_deposit,
cxt.api
.constants()
.balances()
.existential_deposit()
.unwrap()
);
}
+227
View File
@@ -0,0 +1,227 @@
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// 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,
// 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.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use sp_keyring::AccountKeyring;
use crate::{
node_runtime::{
contracts::{
calls::TransactionApi,
events,
storage,
},
system,
DefaultAccountData,
DispatchError,
},
test_context,
NodeRuntimeSignedExtra,
TestContext,
};
use sp_core::sr25519::Pair;
use sp_runtime::MultiAddress;
use subxt::{
Client,
Config,
DefaultConfig,
Error,
PairSigner,
TransactionProgress,
};
struct ContractsTestContext {
cxt: TestContext,
signer: PairSigner<DefaultConfig, NodeRuntimeSignedExtra, Pair>,
}
type Hash = <DefaultConfig as Config>::Hash;
type AccountId = <DefaultConfig as Config>::AccountId;
impl ContractsTestContext {
async fn init() -> Self {
let cxt = test_context().await;
let signer = PairSigner::new(AccountKeyring::Alice.pair());
Self { cxt, signer }
}
fn client(&self) -> &Client<DefaultConfig> {
self.cxt.client()
}
fn contracts_tx(
&self,
) -> TransactionApi<DefaultConfig, NodeRuntimeSignedExtra, DefaultAccountData> {
self.cxt.api.tx().contracts()
}
async fn instantiate_with_code(
&self,
) -> Result<(Hash, AccountId), Error<DispatchError>> {
log::info!("instantiate_with_code:");
const CONTRACT: &str = r#"
(module
(func (export "call"))
(func (export "deploy"))
)
"#;
let code = wabt::wat2wasm(CONTRACT).expect("invalid wabt");
let events = self
.cxt
.api
.tx()
.contracts()
.instantiate_with_code(
100_000_000_000_000_000, // endowment
500_000_000_000, // gas_limit
None, // storage_deposit_limit
code,
vec![], // data
vec![], // salt
)
.sign_and_submit_then_watch(&self.signer)
.await?
.wait_for_finalized_success()
.await?;
let code_stored = events
.find_first_event::<events::CodeStored>()?
.ok_or_else(|| Error::Other("Failed to find a CodeStored event".into()))?;
let instantiated = events
.find_first_event::<events::Instantiated>()?
.ok_or_else(|| Error::Other("Failed to find a Instantiated event".into()))?;
let _extrinsic_success = events
.find_first_event::<system::events::ExtrinsicSuccess>()?
.ok_or_else(|| {
Error::Other("Failed to find a ExtrinsicSuccess event".into())
})?;
log::info!(" Block hash: {:?}", events.block_hash());
log::info!(" Code hash: {:?}", code_stored.code_hash);
log::info!(" Contract address: {:?}", instantiated.contract);
Ok((code_stored.code_hash, instantiated.contract))
}
async fn instantiate(
&self,
code_hash: Hash,
data: Vec<u8>,
salt: Vec<u8>,
) -> Result<AccountId, Error<DispatchError>> {
// call instantiate extrinsic
let result = self
.contracts_tx()
.instantiate(
100_000_000_000_000_000, // endowment
500_000_000_000, // gas_limit
None, // storage_deposit_limit
code_hash,
data,
salt,
)
.sign_and_submit_then_watch(&self.signer)
.await?
.wait_for_finalized_success()
.await?;
log::info!("Instantiate result: {:?}", result);
let instantiated = result
.find_first_event::<events::Instantiated>()?
.ok_or_else(|| Error::Other("Failed to find a Instantiated event".into()))?;
Ok(instantiated.contract)
}
async fn call(
&self,
contract: AccountId,
input_data: Vec<u8>,
) -> Result<TransactionProgress<'_, DefaultConfig, DispatchError>, Error<DispatchError>>
{
log::info!("call: {:?}", contract);
let result = self
.contracts_tx()
.call(
MultiAddress::Id(contract),
0, // value
500_000_000, // gas_limit
None, // storage_deposit_limit
input_data,
)
.sign_and_submit_then_watch(&self.signer)
.await?;
log::info!("Call result: {:?}", result);
Ok(result)
}
}
#[async_std::test]
async fn tx_instantiate_with_code() {
let ctx = ContractsTestContext::init().await;
let result = ctx.instantiate_with_code().await;
assert!(
result.is_ok(),
"Error calling instantiate_with_code and receiving CodeStored and Instantiated Events: {:?}",
result
);
}
#[async_std::test]
async fn tx_instantiate() {
let ctx = ContractsTestContext::init().await;
let (code_hash, _) = ctx.instantiate_with_code().await.unwrap();
let instantiated = ctx.instantiate(code_hash, vec![], vec![1u8]).await;
assert!(
instantiated.is_ok(),
"Error instantiating contract: {:?}",
instantiated
);
}
#[async_std::test]
async fn tx_call() {
let cxt = ContractsTestContext::init().await;
let (_, contract) = cxt.instantiate_with_code().await.unwrap();
let contract_info = cxt
.cxt
.api
.storage()
.contracts()
.contract_info_of(contract.clone(), None)
.await;
assert!(contract_info.is_ok());
let keys = cxt
.client()
.storage()
.fetch_keys::<storage::ContractInfoOf>(5, None, None)
.await
.unwrap()
.iter()
.map(|key| hex::encode(&key.0))
.collect::<Vec<_>>();
println!("keys post: {:?}", keys);
let executed = cxt.call(contract, vec![]).await;
assert!(executed.is_ok(), "Error calling contract: {:?}", executed);
}
+24
View File
@@ -0,0 +1,24 @@
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// 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,
// 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.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
//! Test interactions with some built-in FRAME pallets.
mod balances;
mod contracts;
mod staking;
mod sudo;
mod system;
mod timestamp;
+265
View File
@@ -0,0 +1,265 @@
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// 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,
// 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.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use crate::{
node_runtime::{
runtime_types::pallet_staking::{
RewardDestination,
ValidatorPrefs,
},
staking,
DispatchError,
},
pair_signer,
test_context,
};
use assert_matches::assert_matches;
use sp_core::{
sr25519,
Pair,
};
use sp_keyring::AccountKeyring;
use subxt::{
Error,
Signer,
};
/// Helper function to generate a crypto pair from seed
fn get_from_seed(seed: &str) -> sr25519::Pair {
sr25519::Pair::from_string(&format!("//{}", seed), None)
.expect("static values are valid; qed")
}
fn default_validator_prefs() -> ValidatorPrefs {
ValidatorPrefs {
commission: sp_runtime::Perbill::default(),
blocked: false,
}
}
#[async_std::test]
async fn validate_with_controller_account() {
let alice = pair_signer(AccountKeyring::Alice.pair());
let cxt = test_context().await;
cxt.api
.tx()
.staking()
.validate(default_validator_prefs())
.sign_and_submit_then_watch(&alice)
.await
.unwrap()
.wait_for_finalized_success()
.await
.expect("should be successful");
}
#[async_std::test]
async fn validate_not_possible_for_stash_account() -> Result<(), Error<DispatchError>> {
let alice_stash = pair_signer(get_from_seed("Alice//stash"));
let cxt = test_context().await;
let announce_validator = cxt
.api
.tx()
.staking()
.validate(default_validator_prefs())
.sign_and_submit_then_watch(&alice_stash)
.await?
.wait_for_finalized_success()
.await;
assert_matches!(announce_validator, Err(Error::Runtime(err)) => {
let details = err.inner().details().unwrap();
assert_eq!(details.pallet, "Staking");
assert_eq!(details.error, "NotController");
});
Ok(())
}
#[async_std::test]
async fn nominate_with_controller_account() {
let alice = pair_signer(AccountKeyring::Alice.pair());
let bob = pair_signer(AccountKeyring::Bob.pair());
let cxt = test_context().await;
cxt.api
.tx()
.staking()
.nominate(vec![bob.account_id().clone().into()])
.sign_and_submit_then_watch(&alice)
.await
.unwrap()
.wait_for_finalized_success()
.await
.expect("should be successful");
}
#[async_std::test]
async fn nominate_not_possible_for_stash_account() -> Result<(), Error<DispatchError>> {
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
.api
.tx()
.staking()
.nominate(vec![bob.account_id().clone().into()])
.sign_and_submit_then_watch(&alice_stash)
.await?
.wait_for_finalized_success()
.await;
assert_matches!(nomination, Err(Error::Runtime(err)) => {
let details = err.inner().details().unwrap();
assert_eq!(details.pallet, "Staking");
assert_eq!(details.error, "NotController");
});
Ok(())
}
#[async_std::test]
async fn chill_works_for_controller_only() -> Result<(), Error<DispatchError>> {
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
cxt.api
.tx()
.staking()
.nominate(vec![bob_stash.account_id().clone().into()])
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await?;
let ledger = cxt
.api
.storage()
.staking()
.ledger(alice.account_id().clone(), None)
.await?
.unwrap();
assert_eq!(alice_stash.account_id(), &ledger.stash);
let chill = cxt
.api
.tx()
.staking()
.chill()
.sign_and_submit_then_watch(&alice_stash)
.await?
.wait_for_finalized_success()
.await;
assert_matches!(chill, Err(Error::Runtime(err)) => {
let details = err.inner().details().unwrap();
assert_eq!(details.pallet, "Staking");
assert_eq!(details.error, "NotController");
});
let is_chilled = cxt
.api
.tx()
.staking()
.chill()
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await?
.has_event::<staking::events::Chilled>()?;
assert!(is_chilled);
Ok(())
}
#[async_std::test]
async fn tx_bond() -> Result<(), Error<DispatchError>> {
let alice = pair_signer(AccountKeyring::Alice.pair());
let cxt = test_context().await;
let bond = cxt
.api
.tx()
.staking()
.bond(
AccountKeyring::Bob.to_account_id().into(),
100_000_000_000_000,
RewardDestination::Stash,
)
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await;
assert!(bond.is_ok());
let bond_again = cxt
.api
.tx()
.staking()
.bond(
AccountKeyring::Bob.to_account_id().into(),
100_000_000_000_000,
RewardDestination::Stash,
)
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await;
assert_matches!(bond_again, Err(Error::Runtime(err)) => {
let details = err.inner().details().unwrap();
assert_eq!(details.pallet, "Staking");
assert_eq!(details.error, "AlreadyBonded");
});
Ok(())
}
#[async_std::test]
async fn storage_history_depth() -> Result<(), Error<DispatchError>> {
let cxt = test_context().await;
let history_depth = cxt.api.storage().staking().history_depth(None).await?;
assert_eq!(history_depth, 84);
Ok(())
}
#[async_std::test]
async fn storage_current_era() -> Result<(), Error<DispatchError>> {
let cxt = test_context().await;
let _current_era = cxt
.api
.storage()
.staking()
.current_era(None)
.await?
.expect("current era always exists");
Ok(())
}
#[async_std::test]
async fn storage_era_reward_points() -> Result<(), Error<DispatchError>> {
let cxt = test_context().await;
let current_era_result = cxt
.api
.storage()
.staking()
.eras_reward_points(0, None)
.await;
assert!(current_era_result.is_ok());
Ok(())
}
+81
View File
@@ -0,0 +1,81 @@
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// 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,
// 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.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use crate::{
node_runtime::{
runtime_types,
sudo,
DispatchError,
},
pair_signer,
test_context,
};
use sp_keyring::AccountKeyring;
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<DispatchError>> {
let alice = pair_signer(AccountKeyring::Alice.pair());
let bob = AccountKeyring::Bob.to_account_id().into();
let cxt = test_context().await;
let call = Call::Balances(BalancesCall::transfer {
dest: bob,
value: 10_000,
});
let found_event = cxt
.api
.tx()
.sudo()
.sudo(call)
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await?
.has_event::<sudo::events::Sudid>()?;
assert!(found_event);
Ok(())
}
#[async_std::test]
async fn test_sudo_unchecked_weight() -> Result<(), subxt::Error<DispatchError>> {
let alice = pair_signer(AccountKeyring::Alice.pair());
let bob = AccountKeyring::Bob.to_account_id().into();
let cxt = test_context().await;
let call = Call::Balances(BalancesCall::transfer {
dest: bob,
value: 10_000,
});
let found_event = cxt
.api
.tx()
.sudo()
.sudo_unchecked_weight(call, 0)
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await?
.has_event::<sudo::events::Sudid>()?;
assert!(found_event);
Ok(())
}
+63
View File
@@ -0,0 +1,63 @@
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// 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,
// 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.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use crate::{
node_runtime::{
system,
DispatchError,
},
pair_signer,
test_context,
};
use assert_matches::assert_matches;
use sp_keyring::AccountKeyring;
use subxt::Signer;
#[async_std::test]
async fn storage_account() -> Result<(), subxt::Error<DispatchError>> {
let alice = pair_signer(AccountKeyring::Alice.pair());
let cxt = test_context().await;
let account_info = cxt
.api
.storage()
.system()
.account(alice.account_id().clone(), None)
.await;
assert_matches!(account_info, Ok(_));
Ok(())
}
#[async_std::test]
async fn tx_remark_with_event() -> Result<(), subxt::Error<DispatchError>> {
let alice = pair_signer(AccountKeyring::Alice.pair());
let cxt = test_context().await;
let found_event = cxt
.api
.tx()
.system()
.remark_with_event(b"remarkable".to_vec())
.sign_and_submit_then_watch(&alice)
.await?
.wait_for_finalized_success()
.await?
.has_event::<system::events::Remarked>()?;
assert!(found_event);
Ok(())
}
@@ -0,0 +1,26 @@
// Copyright 2019-2022 Parity Technologies (UK) Ltd.
// This file is part of subxt.
//
// 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,
// 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.
//
// You should have received a copy of the GNU General Public License
// along with subxt. If not, see <http://www.gnu.org/licenses/>.
use crate::test_context;
#[async_std::test]
async fn storage_get_current_timestamp() {
let cxt = test_context().await;
let timestamp = cxt.api.storage().timestamp().now(None).await;
assert!(timestamp.is_ok())
}