Skip to content

Commit 0724349

Browse files
committed
test(chain-extensions): add test for AddProxyV1
Add test verifying AddProxyV1 creates proxy relationship with correct delegate, proxy type (Staking), and delay (0).
1 parent 7e89630 commit 0724349

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

chain-extensions/src/tests.rs

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -659,6 +659,40 @@ fn unstake_all_alpha_success_moves_stake_to_root() {
659659
});
660660
}
661661

662+
#[test]
663+
fn add_proxy_success_creates_proxy_relationship() {
664+
mock::new_test_ext(1).execute_with(|| {
665+
let delegator = U256::from(6001);
666+
let delegate = U256::from(6002);
667+
668+
pallet_subtensor::Pallet::<mock::Test>::add_balance_to_coldkey_account(
669+
&delegator,
670+
1_000_000_000,
671+
);
672+
673+
assert_eq!(
674+
pallet_subtensor_proxy::Proxies::<mock::Test>::get(delegator)
675+
.0
676+
.len(),
677+
0
678+
);
679+
680+
let mut env = MockEnv::new(FunctionId::AddProxyV1, delegator, delegate.encode());
681+
682+
let ret = SubtensorChainExtension::<mock::Test>::dispatch(&mut env).unwrap();
683+
assert_success(ret);
684+
685+
let proxies = pallet_subtensor_proxy::Proxies::<mock::Test>::get(delegator).0;
686+
assert_eq!(proxies.len(), 1);
687+
assert_eq!(proxies[0].delegate, delegate);
688+
assert_eq!(
689+
proxies[0].proxy_type,
690+
subtensor_runtime_common::ProxyType::Staking
691+
);
692+
assert_eq!(proxies[0].delay, 0u64);
693+
});
694+
}
695+
662696
impl MockEnv {
663697
fn new(func_id: FunctionId, caller: AccountId, input: Vec<u8>) -> Self {
664698
Self {

0 commit comments

Comments
 (0)