referrerpolicy=no-referrer-when-downgrade

remote_ext_tests_bags_list/
main.rs

1// Copyright (C) Parity Technologies (UK) Ltd.
2// This file is part of Polkadot.
3
4// Polkadot is free software: you can redistribute it and/or modify
5// it under the terms of the GNU General Public License as published by
6// the Free Software Foundation, either version 3 of the License, or
7// (at your option) any later version.
8
9// Polkadot is distributed in the hope that it will be useful,
10// but WITHOUT ANY WARRANTY; without even the implied warranty of
11// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12// GNU General Public License for more details.
13
14// You should have received a copy of the GNU General Public License
15// along with Polkadot.  If not, see <http://www.gnu.org/licenses/>.
16
17//! Remote tests for bags-list pallet.
18
19use clap::{Parser, ValueEnum};
20
21#[derive(Clone, Debug, ValueEnum)]
22#[value(rename_all = "PascalCase")]
23enum Command {
24	CheckMigration,
25	SanityCheck,
26	Snapshot,
27}
28
29#[derive(Clone, Debug, ValueEnum)]
30#[value(rename_all = "PascalCase")]
31enum Runtime {
32	Westend,
33}
34
35#[derive(Parser)]
36struct Cli {
37	#[arg(long, short, default_value = "wss://westend-rpc.polkadot.io:443")]
38	uri: String,
39	#[arg(long, short, ignore_case = true, value_enum, default_value_t = Runtime::Westend)]
40	runtime: Runtime,
41	#[arg(long, short, ignore_case = true, value_enum, default_value_t = Command::SanityCheck)]
42	command: Command,
43	#[arg(long, short)]
44	snapshot_limit: Option<usize>,
45}
46
47#[tokio::main]
48async fn main() {
49	let options = Cli::parse();
50	sp_tracing::try_init_simple();
51
52	log::info!(
53		target: "remote-ext-tests",
54		"using runtime {:?} / command: {:?}",
55		options.runtime,
56		options.command
57	);
58
59	use pallet_bags_list_remote_tests::*;
60	match options.runtime {
61		Runtime::Westend => sp_core::crypto::set_default_ss58_version(
62			<westend_runtime::Runtime as frame_system::Config>::SS58Prefix::get()
63				.try_into()
64				.unwrap(),
65		),
66	};
67
68	match (options.runtime, options.command) {
69		(Runtime::Westend, Command::CheckMigration) => {
70			use westend_runtime::{Block, Runtime};
71			use westend_runtime_constants::currency::UNITS;
72			migration::execute::<Runtime, Block>(UNITS as u64, "WND", options.uri.clone()).await;
73		},
74		(Runtime::Westend, Command::SanityCheck) => {
75			use westend_runtime::{Block, Runtime};
76			use westend_runtime_constants::currency::UNITS;
77			try_state::execute::<Runtime, Block>(UNITS as u64, "WND", options.uri.clone()).await;
78		},
79		(Runtime::Westend, Command::Snapshot) => {
80			use westend_runtime::{Block, Runtime};
81			use westend_runtime_constants::currency::UNITS;
82			snapshot::execute::<Runtime, Block>(
83				options.snapshot_limit,
84				UNITS.try_into().unwrap(),
85				options.uri.clone(),
86			)
87			.await;
88		},
89	}
90}