Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test jsonrpsee v0.16 #690

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 20 additions & 10 deletions examples/examples/benchmark_bulk_xt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,15 @@

//! This example floods the node with a series of transactions.

use codec::Encode;
use kitchensink_runtime::{AccountId, BalancesCall, RuntimeCall};
use sp_core::{Bytes, H256};
use sp_keyring::AccountKeyring;
use substrate_api_client::{
ac_compose_macros::rpc_params,
ac_primitives::{AssetRuntimeConfig, ExtrinsicSigner as GenericExtrinsicSigner, SignExtrinsic},
rpc::JsonrpseeClient,
Api, SubmitExtrinsic,
rpc::{JsonrpseeClient, Request},
Api,
};

// To test this example with CI we run it against the Substrate kitchensink node, which uses the asset pallet.
Expand Down Expand Up @@ -55,16 +58,23 @@ async fn main() {
// waiting for the response of the node.
let mut nonce = api.get_nonce().unwrap();
let first_nonce = nonce;
while nonce < first_nonce + 500 {
// Compose a balance extrinsic.
let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death {
dest: recipient.clone(),
value: 1_000_000,
});
let xt = api.compose_extrinsic_offline(call, nonce);

// Compose a balance extrinsic.
let call = RuntimeCall::Balances(BalancesCall::transfer_allow_death {
dest: recipient.clone(),
value: 1_000_000,
});

while nonce < first_nonce + 60 {
// Create the extrinsic.
let xt = api.compose_extrinsic_offline(call.clone(), nonce);
let xt_bytes: Bytes = xt.encode().into();
let hex_encoded_xt = rpc_params![xt_bytes];
println!("Sending extrinsic with nonce {}", nonce);
let _tx_hash = api.submit_extrinsic(xt).unwrap();

// Send the extrinsic with jsonrpsee
let _xt_hash: H256 =
api.client().request("author_submitExtrinsic", hex_encoded_xt).unwrap();

nonce += 1;
}
Expand Down