remote_ext_tests_bags_list/
main.rs1use 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}