diff --git a/Cargo.lock b/Cargo.lock index 729b498fd3..0770a35cce 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -5502,6 +5502,7 @@ dependencies = [ "pallet-assets", "pallet-balances", "pallet-collator-selection", + "pallet-collective-proxy", "pallet-contracts", "pallet-contracts-primitives", "pallet-dapp-staking-v3", diff --git a/tests/integration/Cargo.toml b/tests/integration/Cargo.toml index 0dc8e16c19..0c42b0aae6 100644 --- a/tests/integration/Cargo.toml +++ b/tests/integration/Cargo.toml @@ -37,6 +37,7 @@ sp-runtime = { workspace = true } # astar dependencies assets-chain-extension-types = { workspace = true } pallet-collator-selection = { workspace = true } +pallet-collective-proxy = { workspace = true } pallet-dapp-staking-v3 = { workspace = true } pallet-ethereum-checked = { workspace = true } pallet-evm-precompile-assets-erc20 = { workspace = true } @@ -68,6 +69,7 @@ std = [ "astar-primitives/std", "astar-test-utils/std", "assets-chain-extension-types/std", + "pallet-collective-proxy/std", "ethereum?/std", "fp-evm/std", "fp-rpc?/std", diff --git a/tests/integration/src/governance.rs b/tests/integration/src/governance.rs index c7101f0eed..01087cea5d 100644 --- a/tests/integration/src/governance.rs +++ b/tests/integration/src/governance.rs @@ -18,7 +18,10 @@ use crate::setup::*; -use frame_support::{dispatch::GetDispatchInfo, traits::StorePreimage}; +use frame_support::{ + dispatch::GetDispatchInfo, + traits::{Currency, StorePreimage}, +}; use parity_scale_codec::Encode; use sp_runtime::traits::{BlakeTwo256, Hash}; @@ -31,7 +34,7 @@ fn external_proposals_work() { let remark_call_bounded = Preimage::bound(remark_call).unwrap(); let external_propose_call = - RuntimeCall::Democracy(pallet_democracy::Call::external_propose { + RuntimeCall::Democracy(pallet_democracy::Call::external_propose_majority { proposal: remark_call_bounded.clone(), }); let external_propose_call_hash = BlakeTwo256::hash_of(&external_propose_call); @@ -79,26 +82,26 @@ fn external_proposals_work() { let fast_track_call_hash = BlakeTwo256::hash_of(&fast_track_call); // Tech committee should be able to fast-track external proposals - assert_ok!(Council::propose( + assert_ok!(TechnicalCommittee::propose( RuntimeOrigin::signed(ALICE.clone()), 2, Box::new(fast_track_call.clone()), fast_track_call.encode().len() as u32 )); - for signer in &[BOB, CAT] { - assert_ok!(Council::vote( + for signer in &[ALICE, BOB, CAT] { + assert_ok!(TechnicalCommittee::vote( RuntimeOrigin::signed(signer.clone()), fast_track_call_hash, - 1, + 0, true )); } - assert_ok!(Council::close( + assert_ok!(TechnicalCommittee::close( RuntimeOrigin::signed(ALICE.clone()), fast_track_call_hash, - 1, + 0, fast_track_call.get_dispatch_info().weight, fast_track_call.encode().len() as u32, )); @@ -113,3 +116,54 @@ fn external_proposals_work() { ); }) } + +#[test] +fn community_council_can_execute_dapp_staking_calls() { + new_test_ext().execute_with(|| { + // Fund the proxy account + let proxy_account = ::ProxyAccountId::get(); + let lock_amount = 10_000_000_000_000_000_000_000; + Balances::make_free_balance_be(&proxy_account, lock_amount); + + // Prepare the wrapped dApp staking lock call + let lock_call = RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::lock { + amount: lock_amount, + }); + let collective_proxy_call = + RuntimeCall::CollectiveProxy(pallet_collective_proxy::Call::execute_call { + call: Box::new(lock_call), + }); + let collective_proxy_call_hash = BlakeTwo256::hash_of(&collective_proxy_call); + + // Community council should be able to execute dApp staking calls + assert_ok!(CommunityCouncil::propose( + RuntimeOrigin::signed(ALICE.clone()), + 2, + Box::new(collective_proxy_call.clone()), + collective_proxy_call.encode().len() as u32 + )); + + for signer in &[BOB, CAT] { + assert_ok!(CommunityCouncil::vote( + RuntimeOrigin::signed(signer.clone()), + collective_proxy_call_hash, + 0, + true + )); + } + + assert_ok!(CommunityCouncil::close( + RuntimeOrigin::signed(ALICE.clone()), + collective_proxy_call_hash, + 0, + collective_proxy_call.get_dispatch_info().weight, + collective_proxy_call.encode().len() as u32, + )); + + // Check that the lock was successful + assert_eq!( + pallet_dapp_staking_v3::Ledger::::get(&proxy_account).locked, + lock_amount + ); + }) +}