// Copyright 2019-2023 Parity Technologies (UK) Ltd. // This file is dual-licensed as Apache-2.0 or GPL-3.0. // see LICENSE for license details. use crate::{ node_runtime::{ self, runtime_types::{self, sp_weights::weight_v2::Weight}, sudo, }, test_context, }; use subxt_signer::sr25519::dev; type Call = runtime_types::kitchensink_runtime::RuntimeCall; type BalancesCall = runtime_types::pallet_balances::pallet::Call; #[tokio::test] async fn test_sudo() -> Result<(), subxt::Error> { let ctx = test_context().await; let api = ctx.client(); let alice = dev::alice(); let bob = dev::bob().public_key().into(); let call = Call::Balances(BalancesCall::transfer_allow_death { dest: bob, value: 10_000, }); let tx = node_runtime::tx().sudo().sudo(call); let found_event = api .tx() .sign_and_submit_then_watch_default(&tx, &alice) .await? .wait_for_finalized_success() .await? .has::()?; assert!(found_event); Ok(()) } #[tokio::test] async fn test_sudo_unchecked_weight() -> Result<(), subxt::Error> { let ctx = test_context().await; let api = ctx.client(); let alice = dev::alice(); let bob = dev::bob().public_key().into(); let call = Call::Balances(BalancesCall::transfer_allow_death { dest: bob, value: 10_000, }); let tx = node_runtime::tx().sudo().sudo_unchecked_weight( call, Weight { ref_time: 0, proof_size: 0, }, ); let found_event = api .tx() .sign_and_submit_then_watch_default(&tx, &alice) .await? .wait_for_finalized_success() .await? .has::()?; assert!(found_event); Ok(()) }