1- use frame_support:: { assert_ok, traits:: InstanceFilter } ;
1+ use frame_support:: { assert_ok, traits:: InstanceFilter , BoundedVec } ;
22use node_subtensor_runtime:: {
3- AccountId , BalancesCall , BuildStorage , Proxy , ProxyType , Runtime , RuntimeCall ,
3+ AccountId , BalancesCall , BuildStorage , Proxy , ProxyType , Runtime , RuntimeCall , RuntimeEvent ,
44 RuntimeGenesisConfig , RuntimeOrigin , SubtensorModule , System , SystemCall ,
55} ;
66
@@ -28,6 +28,10 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
2828 members : vec ! [ AccountId :: from( ACCOUNT ) ] ,
2929 phantom : Default :: default ( ) ,
3030 } ,
31+ senate_members : pallet_membership:: GenesisConfig {
32+ members : BoundedVec :: try_from ( vec ! [ AccountId :: from( ACCOUNT ) ] ) . unwrap ( ) ,
33+ phantom : Default :: default ( ) ,
34+ } ,
3135 ..Default :: default ( )
3236 }
3337 . build_storage ( )
@@ -37,12 +41,6 @@ pub fn new_test_ext() -> sp_io::TestExternalities {
3741 ext
3842}
3943
40- pub fn add_network ( netuid : u16 , tempo : u16 ) {
41- SubtensorModule :: init_new_network ( netuid, tempo) ;
42- SubtensorModule :: set_network_registration_allowed ( netuid, true ) ;
43- SubtensorModule :: set_network_pow_registration_allowed ( netuid, true ) ;
44- }
45-
4644// transfer call
4745fn call_transfer ( ) -> RuntimeCall {
4846 let value = 100 ;
@@ -62,9 +60,6 @@ fn call_remark() -> RuntimeCall {
6260fn call_owner_util ( ) -> RuntimeCall {
6361 let netuid = 1 ;
6462 let serving_rate_limit = 2 ;
65-
66- pallet_subtensor:: SubnetOwner :: < Runtime > :: insert ( netuid, AccountId :: from ( ACCOUNT ) ) ;
67-
6863 RuntimeCall :: AdminUtils ( pallet_admin_utils:: Call :: sudo_set_serving_rate_limit {
6964 netuid,
7065 serving_rate_limit,
@@ -116,19 +111,6 @@ fn call_add_stake() -> RuntimeCall {
116111 & AccountId :: from ( ACCOUNT ) ,
117112 ) ;
118113
119- add_network ( netuid, tempo) ;
120- pallet_subtensor:: Owner :: < Runtime > :: insert ( AccountId :: from ( DELEGATE ) , AccountId :: from ( ACCOUNT ) ) ;
121-
122- assert_ok ! ( SubtensorModule :: register(
123- RuntimeOrigin :: signed( AccountId :: from( ACCOUNT ) ) ,
124- netuid,
125- block_number,
126- nonce,
127- work,
128- AccountId :: from( DELEGATE ) ,
129- AccountId :: from( ACCOUNT ) ,
130- ) ) ;
131-
132114 let amount_staked = 100 ;
133115 RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: add_stake {
134116 hotkey : AccountId :: from ( DELEGATE ) . into ( ) ,
@@ -148,8 +130,6 @@ fn call_register() -> RuntimeCall {
148130 & AccountId :: from ( ACCOUNT ) ,
149131 ) ;
150132
151- add_network ( netuid, tempo) ;
152-
153133 RuntimeCall :: SubtensorModule ( pallet_subtensor:: Call :: register {
154134 netuid,
155135 block_number,
@@ -168,15 +148,19 @@ fn verify_call_with_proxy_type(proxy_type: &ProxyType, call: &RuntimeCall) {
168148 Box :: new( call. clone( ) ) ,
169149 ) ) ;
170150
151+ let filtered_event: RuntimeEvent = pallet_proxy:: Event :: ProxyExecuted {
152+ result : Err ( SystemError :: CallFiltered . into ( ) ) ,
153+ }
154+ . into ( ) ;
155+
156+ // check if the filter works by checking the last event
157+ // filtered if the last event is SystemError::CallFiltered
158+ // not filtered if the last event is proxy executed done or any error from proxy call
171159 if proxy_type. filter ( call) {
172- System :: assert_last_event ( pallet_proxy:: Event :: ProxyExecuted { result : Ok ( ( ) ) } . into ( ) ) ;
160+ let last_event = System :: events ( ) . last ( ) . unwrap ( ) . event . clone ( ) ;
161+ assert_ne ! ( last_event, filtered_event) ;
173162 } else {
174- System :: assert_last_event (
175- pallet_proxy:: Event :: ProxyExecuted {
176- result : Err ( SystemError :: CallFiltered . into ( ) ) ,
177- }
178- . into ( ) ,
179- ) ;
163+ System :: assert_last_event ( filtered_event) ;
180164 }
181165}
182166
0 commit comments