Skip to content

Commit 4d21b40

Browse files
committed
Finish integration tests
1 parent 1217806 commit 4d21b40

File tree

3 files changed

+65
-8
lines changed

3 files changed

+65
-8
lines changed

Cargo.lock

+1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/integration/Cargo.toml

+2
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ sp-runtime = { workspace = true }
3737
# astar dependencies
3838
assets-chain-extension-types = { workspace = true }
3939
pallet-collator-selection = { workspace = true }
40+
pallet-collective-proxy = { workspace = true }
4041
pallet-dapp-staking-v3 = { workspace = true }
4142
pallet-ethereum-checked = { workspace = true }
4243
pallet-evm-precompile-assets-erc20 = { workspace = true }
@@ -68,6 +69,7 @@ std = [
6869
"astar-primitives/std",
6970
"astar-test-utils/std",
7071
"assets-chain-extension-types/std",
72+
"pallet-collective-proxy/std",
7173
"ethereum?/std",
7274
"fp-evm/std",
7375
"fp-rpc?/std",

tests/integration/src/governance.rs

+62-8
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818

1919
use crate::setup::*;
2020

21-
use frame_support::{dispatch::GetDispatchInfo, traits::StorePreimage};
21+
use frame_support::{
22+
dispatch::GetDispatchInfo,
23+
traits::{Currency, StorePreimage},
24+
};
2225
use parity_scale_codec::Encode;
2326
use sp_runtime::traits::{BlakeTwo256, Hash};
2427

@@ -31,7 +34,7 @@ fn external_proposals_work() {
3134
let remark_call_bounded = Preimage::bound(remark_call).unwrap();
3235

3336
let external_propose_call =
34-
RuntimeCall::Democracy(pallet_democracy::Call::external_propose {
37+
RuntimeCall::Democracy(pallet_democracy::Call::external_propose_majority {
3538
proposal: remark_call_bounded.clone(),
3639
});
3740
let external_propose_call_hash = BlakeTwo256::hash_of(&external_propose_call);
@@ -79,26 +82,26 @@ fn external_proposals_work() {
7982
let fast_track_call_hash = BlakeTwo256::hash_of(&fast_track_call);
8083

8184
// Tech committee should be able to fast-track external proposals
82-
assert_ok!(Council::propose(
85+
assert_ok!(TechnicalCommittee::propose(
8386
RuntimeOrigin::signed(ALICE.clone()),
8487
2,
8588
Box::new(fast_track_call.clone()),
8689
fast_track_call.encode().len() as u32
8790
));
8891

89-
for signer in &[BOB, CAT] {
90-
assert_ok!(Council::vote(
92+
for signer in &[ALICE, BOB, CAT] {
93+
assert_ok!(TechnicalCommittee::vote(
9194
RuntimeOrigin::signed(signer.clone()),
9295
fast_track_call_hash,
93-
1,
96+
0,
9497
true
9598
));
9699
}
97100

98-
assert_ok!(Council::close(
101+
assert_ok!(TechnicalCommittee::close(
99102
RuntimeOrigin::signed(ALICE.clone()),
100103
fast_track_call_hash,
101-
1,
104+
0,
102105
fast_track_call.get_dispatch_info().weight,
103106
fast_track_call.encode().len() as u32,
104107
));
@@ -113,3 +116,54 @@ fn external_proposals_work() {
113116
);
114117
})
115118
}
119+
120+
#[test]
121+
fn community_council_can_execute_dapp_staking_calls() {
122+
new_test_ext().execute_with(|| {
123+
// Fund the proxy account
124+
let proxy_account = <Runtime as pallet_collective_proxy::Config>::ProxyAccountId::get();
125+
let lock_amount = 10_000_000_000_000_000_000_000;
126+
Balances::make_free_balance_be(&proxy_account, lock_amount);
127+
128+
// Prepare the wrapped dApp staking lock call
129+
let lock_call = RuntimeCall::DappStaking(pallet_dapp_staking_v3::Call::lock {
130+
amount: lock_amount,
131+
});
132+
let collective_proxy_call =
133+
RuntimeCall::CollectiveProxy(pallet_collective_proxy::Call::execute_call {
134+
call: Box::new(lock_call),
135+
});
136+
let collective_proxy_call_hash = BlakeTwo256::hash_of(&collective_proxy_call);
137+
138+
// Community council should be able to execute dApp staking calls
139+
assert_ok!(CommunityCouncil::propose(
140+
RuntimeOrigin::signed(ALICE.clone()),
141+
2,
142+
Box::new(collective_proxy_call.clone()),
143+
collective_proxy_call.encode().len() as u32
144+
));
145+
146+
for signer in &[BOB, CAT] {
147+
assert_ok!(CommunityCouncil::vote(
148+
RuntimeOrigin::signed(signer.clone()),
149+
collective_proxy_call_hash,
150+
0,
151+
true
152+
));
153+
}
154+
155+
assert_ok!(CommunityCouncil::close(
156+
RuntimeOrigin::signed(ALICE.clone()),
157+
collective_proxy_call_hash,
158+
0,
159+
collective_proxy_call.get_dispatch_info().weight,
160+
collective_proxy_call.encode().len() as u32,
161+
));
162+
163+
// Check that the lock was successful
164+
assert_eq!(
165+
pallet_dapp_staking_v3::Ledger::<Runtime>::get(&proxy_account).locked,
166+
lock_amount
167+
);
168+
})
169+
}

0 commit comments

Comments
 (0)