Skip to content
Snippets Groups Projects
Select Git revision
  • ed0fcb4c2a80d4c6b71dbc9337ab3ceefffdaccc
  • master default protected
  • tuxmain/fix-change-owner-key
  • fix_picked_up_file_in_runtime_release
  • network/gtest-1000 protected
  • upgradable-multisig
  • runtime/gtest-1000
  • network/gdev-800 protected
  • cgeek/issue-297-cpu
  • gdev-800-tests
  • update-docker-compose-rpc-squid-names
  • fix-252
  • 1000i100-test
  • hugo/tmp-0.9.1
  • network/gdev-803 protected
  • hugo/endpoint-gossip
  • network/gdev-802 protected
  • hugo/distance-precompute
  • network/gdev-900 protected
  • tuxmain/anonymous-tx
  • debug/podman
  • gtest-1000-0.11.1 protected
  • gtest-1000-0.11.0 protected
  • gtest-1000 protected
  • gdev-900-0.10.1 protected
  • gdev-900-0.10.0 protected
  • gdev-900-0.9.2 protected
  • gdev-800-0.8.0 protected
  • gdev-900-0.9.1 protected
  • gdev-900-0.9.0 protected
  • gdev-803 protected
  • gdev-802 protected
  • runtime-801 protected
  • gdev-800 protected
  • runtime-800-bis protected
  • runtime-800 protected
  • runtime-800-backup protected
  • runtime-701 protected
  • runtime-700 protected
  • runtime-600 protected
  • runtime-500 protected
41 results

setup.md

Blame
    • Hugo Trentesaux's avatar
      b145f36f
      gtest genesis parsing (!176) · b145f36f
      Hugo Trentesaux authored and Hugo Trentesaux's avatar Hugo Trentesaux committed
      * fix clippy
      
      * fix after rebase
      
      * WIP example specs
      
      * fix after rebase
      
      * add reproducibility
      
      * doc add missing protobuf compiler
      
      * remove ref to genesis timestamp
      
      * fix broken next identity index genesis
      
      * our pallets are not coming from the framework
      
      * fix first_ud everywhere
      
      * remove files unwanted on main branch
      
      * also apply renaming to gdev
      
      * rename first_ud_value and add comments
      
      (to put in value the absence of first_ud_time)
      
      * use index provided in GenesisIdty
      
      * add mold to documentation
      
      * change gtest existential deposit
      
      and adapt genesis parsing to real-world data
      
      * embed raw chainspecs only when enabled
      
      * add comments
      b145f36f
      History
      gtest genesis parsing (!176)
      Hugo Trentesaux authored and Hugo Trentesaux's avatar Hugo Trentesaux committed
      * fix clippy
      
      * fix after rebase
      
      * WIP example specs
      
      * fix after rebase
      
      * add reproducibility
      
      * doc add missing protobuf compiler
      
      * remove ref to genesis timestamp
      
      * fix broken next identity index genesis
      
      * our pallets are not coming from the framework
      
      * fix first_ud everywhere
      
      * remove files unwanted on main branch
      
      * also apply renaming to gdev
      
      * rename first_ud_value and add comments
      
      (to put in value the absence of first_ud_time)
      
      * use index provided in GenesisIdty
      
      * add mold to documentation
      
      * change gtest existential deposit
      
      and adapt genesis parsing to real-world data
      
      * embed raw chainspecs only when enabled
      
      * add comments
    net_test.rs 2.44 KiB
    use crate::*;
    
    use sp_core::DeriveJunction;
    use subxt::ext::sp_runtime::MultiAddress;
    
    pub async fn repart(
    	data: &Data,
    	target: u32,
    	actual_repart: Option<u32>,
    ) -> anyhow::Result<()> {
    	let mut pairs = Vec::new();
    	for i in actual_repart.unwrap_or_default()..target {
    		let pair_i = data.keypair()
    			.derive(std::iter::once(DeriveJunction::hard::<u32>(i)), None)
    			.map_err(|_| anyhow!("Fail to derive //{}", i))?
    			.0;
    		pairs.push((i, pair_i));
    	}
    
    	for (i, pair_i) in &pairs {
    		/*let _ = api
    			.tx()
    			.balances()
    			.transfer(MultiAddress::Id(pair_i.public().into()), 501)?
    			.sign_and_submit_then_watch(&signer, BaseExtrinsicParamsBuilder::new())
    			.await?
    			.wait_for_in_block()
    			.await?;
    		signer.increment_nonce();*/
    
    		if let Some(pair_i_account) = data.client()
    			.storage()
    			.fetch(
    				&runtime::storage().system().account(&pair_i.public().into()),
    				None,
    			)
    			.await?
    		{
    			log::info!("account //{} balance: {}", i, pair_i_account.data.free);
    		}
    	}
    
    	Ok(())
    }
    
    pub async fn spam_roll(data: &Data, actual_repart: usize) -> anyhow::Result<()> {
    	let client = data.client();
    	let mut nonce = 0;
    	let mut pairs = Vec::<(PairSigner<Runtime, Pair>, AccountId)>::with_capacity(actual_repart);
    	for i in 0..actual_repart {
    		let pair_i = data.keypair()
    			.derive(std::iter::once(DeriveJunction::hard::<u32>(i as u32)), None)
    			.map_err(|_| anyhow!("Fail to derive //{}", i))?
    			.0;
    		let account_id_i = pair_i.public().into();
    		pairs.push((PairSigner::new(pair_i), account_id_i));
    	}
    
    	loop {
    		let mut watchers = Vec::with_capacity(actual_repart);
    		for i in 0..(actual_repart - 1) {
    			let dest: AccountId = pairs[i + 1].1.clone();
    			let watcher = client
    				.tx()
    				.create_signed_with_nonce(
    					&runtime::tx().balances().transfer(MultiAddress::Id(dest), 1),
    					&pairs[i].0,
    					nonce,
    					BaseExtrinsicParamsBuilder::new(),
    				)?
    				.submit_and_watch()
    				.await?;
    			nonce += 1;
    			log::info!("send 1 cent from //{} to //{}", i, i + 1);
    			watchers.push(watcher);
    		}
    		let dest: AccountId = pairs[0].1.clone();
    		let watcher = client
    			.tx()
    			.sign_and_submit_then_watch(
    				&runtime::tx().balances().transfer(MultiAddress::Id(dest), 1),
    				&pairs[actual_repart - 1].0,
    				BaseExtrinsicParamsBuilder::new(),
    			)
    			.await?;
    		nonce += 1;
    		log::info!("send 1 cent from //{} to //0", actual_repart - 1);
    		watchers.push(watcher);
    
    		// Wait all transactions
    		for watcher in watchers {
    			watcher.wait_for_in_block().await?;
    		}
    	}
    }