mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-14 01:41:09 +00:00
chainHead based backend implementation (#1161)
* add follow_stream impl * follow_stream_unpin first draft * add tests for follow_stream_unpin * more tests and fixes for follow_stream_unpin * first pass follow_stream_driver * follow_stream_driver: add tests, fix things, buffer events from last finalized * First pass finishing Backend impl * Fix test compile issues * clippy fixes * clippy fix and consistify light_client * revert lightclient tweak * revert other lightclient thing * cargo fmt * start testing unstable backend behind feature flag * more test fixes and move test-runtime metadata path just incase * fix compile error * ensure transaction progress stream actually used and fix another test * cargo fmt * CI tweak * improve some comments and address some feedback bits * update CI to use our own nightly binary * wait for finalized block perhaps
This commit is contained in:
@@ -41,7 +41,9 @@ async fn tx_basic_transfer() -> Result<(), subxt::Error> {
|
||||
.fetch_or_default(&bob_account_addr)
|
||||
.await?;
|
||||
|
||||
let tx = node_runtime::tx().balances().transfer(bob_address, 10_000);
|
||||
let tx = node_runtime::tx()
|
||||
.balances()
|
||||
.transfer_allow_death(bob_address, 10_000);
|
||||
|
||||
let events = api
|
||||
.tx()
|
||||
@@ -118,7 +120,7 @@ async fn tx_dynamic_transfer() -> Result<(), subxt::Error> {
|
||||
|
||||
let tx = subxt::dynamic::tx(
|
||||
"Balances",
|
||||
"transfer",
|
||||
"transfer_allow_death",
|
||||
vec![
|
||||
Value::unnamed_variant(
|
||||
"Id",
|
||||
@@ -206,14 +208,14 @@ async fn tx_dynamic_transfer() -> Result<(), subxt::Error> {
|
||||
}
|
||||
|
||||
#[tokio::test]
|
||||
async fn multiple_transfers_work_nonce_incremented() -> Result<(), subxt::Error> {
|
||||
async fn multiple_sequential_transfers_work() -> Result<(), subxt::Error> {
|
||||
let alice = dev::alice();
|
||||
let bob = dev::bob();
|
||||
let bob_address: MultiAddress<AccountId32, u32> = bob.public_key().into();
|
||||
let ctx = test_context().await;
|
||||
let api = ctx.client();
|
||||
|
||||
let bob_account_addr = node_runtime::storage()
|
||||
let bob_account_info_addr = node_runtime::storage()
|
||||
.system()
|
||||
.account(bob.public_key().to_account_id());
|
||||
|
||||
@@ -221,19 +223,19 @@ async fn multiple_transfers_work_nonce_incremented() -> Result<(), subxt::Error>
|
||||
.storage()
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch_or_default(&bob_account_addr)
|
||||
.fetch_or_default(&bob_account_info_addr)
|
||||
.await?;
|
||||
|
||||
// Do a transfer several times. If this works, it indicates that the
|
||||
// nonce is properly incremented each time.
|
||||
let tx = node_runtime::tx()
|
||||
.balances()
|
||||
.transfer(bob_address.clone(), 10_000);
|
||||
.transfer_allow_death(bob_address.clone(), 10_000);
|
||||
for _ in 0..3 {
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&tx, &alice)
|
||||
.await?
|
||||
.wait_for_in_block() // Don't need to wait for finalization; this is quicker.
|
||||
.await?
|
||||
.wait_for_success()
|
||||
.wait_for_finalized_success()
|
||||
.await?;
|
||||
}
|
||||
|
||||
@@ -241,7 +243,7 @@ async fn multiple_transfers_work_nonce_incremented() -> Result<(), subxt::Error>
|
||||
.storage()
|
||||
.at_latest()
|
||||
.await?
|
||||
.fetch_or_default(&bob_account_addr)
|
||||
.fetch_or_default(&bob_account_info_addr)
|
||||
.await?;
|
||||
|
||||
assert_eq!(bob_pre.data.free + 30_000, bob_post.data.free);
|
||||
@@ -317,10 +319,10 @@ async fn transfer_error() {
|
||||
|
||||
let to_bob_tx = node_runtime::tx()
|
||||
.balances()
|
||||
.transfer(bob_address, 100_000_000_000_000_000);
|
||||
.transfer_allow_death(bob_address, 100_000_000_000_000_000);
|
||||
let to_alice_tx = node_runtime::tx()
|
||||
.balances()
|
||||
.transfer(alice_addr, 100_000_000_000_000_000);
|
||||
.transfer_allow_death(alice_addr, 100_000_000_000_000_000);
|
||||
|
||||
api.tx()
|
||||
.sign_and_submit_then_watch_default(&to_bob_tx, &alice)
|
||||
@@ -360,7 +362,7 @@ async fn transfer_implicit_subscription() {
|
||||
|
||||
let to_bob_tx = node_runtime::tx()
|
||||
.balances()
|
||||
.transfer(bob.clone().into(), 10_000);
|
||||
.transfer_allow_death(bob.clone().into(), 10_000);
|
||||
|
||||
let event = api
|
||||
.tx()
|
||||
|
||||
@@ -203,7 +203,6 @@ async fn tx_call() {
|
||||
let info_addr = node_runtime::storage()
|
||||
.contracts()
|
||||
.contract_info_of(&contract);
|
||||
let info_addr_iter = node_runtime::storage().contracts().contract_info_of_iter();
|
||||
|
||||
let contract_info = cxt
|
||||
.client()
|
||||
@@ -213,7 +212,13 @@ async fn tx_call() {
|
||||
.unwrap()
|
||||
.fetch(&info_addr)
|
||||
.await;
|
||||
assert!(contract_info.is_ok());
|
||||
|
||||
assert!(
|
||||
contract_info.is_ok(),
|
||||
"Contract info is not ok, is: {contract_info:?}"
|
||||
);
|
||||
|
||||
let info_addr_iter = node_runtime::storage().contracts().contract_info_of_iter();
|
||||
|
||||
let keys_and_values = cxt
|
||||
.client()
|
||||
|
||||
@@ -23,7 +23,7 @@ async fn test_sudo() -> Result<(), subxt::Error> {
|
||||
let alice = dev::alice();
|
||||
let bob = dev::bob().public_key().into();
|
||||
|
||||
let call = Call::Balances(BalancesCall::transfer {
|
||||
let call = Call::Balances(BalancesCall::transfer_allow_death {
|
||||
dest: bob,
|
||||
value: 10_000,
|
||||
});
|
||||
@@ -49,7 +49,7 @@ async fn test_sudo_unchecked_weight() -> Result<(), subxt::Error> {
|
||||
let alice = dev::alice();
|
||||
let bob = dev::bob().public_key().into();
|
||||
|
||||
let call = Call::Balances(BalancesCall::transfer {
|
||||
let call = Call::Balances(BalancesCall::transfer_allow_death {
|
||||
dest: bob,
|
||||
value: 10_000,
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user