@@ -92,6 +92,87 @@ async fn test_revoke_council_tokens() {
92
92
assert_eq ! ( holding_account. amount, 0 ) ;
93
93
}
94
94
95
+ #[ tokio:: test]
96
+ async fn test_revoke_own_council_tokens ( ) {
97
+ // Arrange
98
+ let mut governance_test = GovernanceProgramTest :: start_new ( ) . await ;
99
+
100
+ let mut realm_config_args = RealmSetupArgs :: default ( ) ;
101
+ realm_config_args. council_token_config_args . token_type = GoverningTokenType :: Membership ;
102
+
103
+ let realm_cookie = governance_test
104
+ . with_realm_using_args ( & realm_config_args)
105
+ . await ;
106
+
107
+ let token_owner_record_cookie = governance_test
108
+ . with_council_token_deposit ( & realm_cookie)
109
+ . await
110
+ . unwrap ( ) ;
111
+
112
+ // Act
113
+ governance_test
114
+ . revoke_governing_tokens_using_instruction (
115
+ & realm_cookie,
116
+ & token_owner_record_cookie,
117
+ & realm_cookie. account . config . council_mint . unwrap ( ) ,
118
+ & token_owner_record_cookie. token_owner ,
119
+ token_owner_record_cookie
120
+ . account
121
+ . governing_token_deposit_amount ,
122
+ NopOverride ,
123
+ None ,
124
+ )
125
+ . await
126
+ . unwrap ( ) ;
127
+
128
+ // Assert
129
+
130
+ let token_owner_record = governance_test
131
+ . get_token_owner_record_account ( & token_owner_record_cookie. address )
132
+ . await ;
133
+
134
+ assert_eq ! ( token_owner_record. governing_token_deposit_amount, 0 ) ;
135
+ }
136
+
137
+ #[ tokio:: test]
138
+ async fn test_revoke_own_council_tokens_with_owner_must_sign_error ( ) {
139
+ // Arrange
140
+ let mut governance_test = GovernanceProgramTest :: start_new ( ) . await ;
141
+
142
+ let mut realm_config_args = RealmSetupArgs :: default ( ) ;
143
+ realm_config_args. council_token_config_args . token_type = GoverningTokenType :: Membership ;
144
+
145
+ let realm_cookie = governance_test
146
+ . with_realm_using_args ( & realm_config_args)
147
+ . await ;
148
+
149
+ let token_owner_record_cookie = governance_test
150
+ . with_council_token_deposit ( & realm_cookie)
151
+ . await
152
+ . unwrap ( ) ;
153
+
154
+ // Act
155
+ let err = governance_test
156
+ . revoke_governing_tokens_using_instruction (
157
+ & realm_cookie,
158
+ & token_owner_record_cookie,
159
+ & realm_cookie. account . config . council_mint . unwrap ( ) ,
160
+ & token_owner_record_cookie. token_owner ,
161
+ token_owner_record_cookie
162
+ . account
163
+ . governing_token_deposit_amount ,
164
+ |i| i. accounts [ 4 ] . is_signer = false , // revoke_authority
165
+ Some ( & [ ] ) ,
166
+ )
167
+ . await
168
+ . err ( )
169
+ . unwrap ( ) ;
170
+
171
+ // Assert
172
+
173
+ assert_eq ! ( err, GovernanceError :: GoverningTokenOwnerMustSign . into( ) ) ;
174
+ }
175
+
95
176
#[ tokio:: test]
96
177
async fn test_revoke_community_tokens_with_cannot_revoke_liquid_token_error ( ) {
97
178
// Arrange
@@ -171,6 +252,7 @@ async fn test_revoke_council_tokens_with_mint_authority_must_sign_error() {
171
252
& realm_cookie,
172
253
& token_owner_record_cookie,
173
254
& realm_cookie. account . config . council_mint . unwrap ( ) ,
255
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
174
256
1 ,
175
257
|i| i. accounts [ 4 ] . is_signer = false , // mint_authority
176
258
Some ( & [ ] ) ,
@@ -185,7 +267,7 @@ async fn test_revoke_council_tokens_with_mint_authority_must_sign_error() {
185
267
}
186
268
187
269
#[ tokio:: test]
188
- async fn test_revoke_council_tokens_with_invalid_mint_authority_error ( ) {
270
+ async fn test_revoke_council_tokens_with_invalid_revoke_authority_error ( ) {
189
271
// Arrange
190
272
let mut governance_test = GovernanceProgramTest :: start_new ( ) . await ;
191
273
@@ -201,18 +283,16 @@ async fn test_revoke_council_tokens_with_invalid_mint_authority_error() {
201
283
. await
202
284
. unwrap ( ) ;
203
285
204
- // Try to use fake authority
205
- let mint_authority = Keypair :: new ( ) ;
206
-
207
286
// Act
208
287
let err = governance_test
209
288
. revoke_governing_tokens_using_instruction (
210
289
& realm_cookie,
211
290
& token_owner_record_cookie,
212
291
& realm_cookie. account . config . council_mint . unwrap ( ) ,
292
+ & Keypair :: new ( ) , // Try to use fake authority
213
293
1 ,
214
- |i| i . accounts [ 4 ] . pubkey = mint_authority . pubkey ( ) , // mint_authority
215
- Some ( & [ & mint_authority ] ) ,
294
+ NopOverride ,
295
+ None ,
216
296
)
217
297
. await
218
298
. err ( )
@@ -253,6 +333,7 @@ async fn test_revoke_council_tokens_with_invalid_token_holding_error() {
253
333
& realm_cookie,
254
334
& token_owner_record_cookie,
255
335
& realm_cookie. account . config . council_mint . unwrap ( ) ,
336
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
256
337
1 ,
257
338
|i| i. accounts [ 1 ] . pubkey = governing_token_holding_address, // governing_token_holding_address
258
339
None ,
@@ -295,6 +376,7 @@ async fn test_revoke_council_tokens_with_other_realm_config_account_error() {
295
376
& realm_cookie,
296
377
& token_owner_record_cookie,
297
378
& realm_cookie. account . config . council_mint . unwrap ( ) ,
379
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
298
380
1 ,
299
381
|i| i. accounts [ 5 ] . pubkey = realm_cookie2. realm_config . address , //realm_config_address
300
382
None ,
@@ -334,6 +416,7 @@ async fn test_revoke_council_tokens_with_invalid_realm_config_account_address_er
334
416
& realm_cookie,
335
417
& token_owner_record_cookie,
336
418
& realm_cookie. account . config . council_mint . unwrap ( ) ,
419
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
337
420
1 ,
338
421
|i| i. accounts [ 5 ] . pubkey = realm_config_address, // realm_config_address
339
422
None ,
@@ -376,6 +459,7 @@ async fn test_revoke_council_tokens_with_token_owner_record_for_different_mint_e
376
459
& realm_cookie,
377
460
& token_owner_record_cookie,
378
461
& realm_cookie. account . config . council_mint . unwrap ( ) ,
462
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
379
463
1 ,
380
464
|i| i. accounts [ 2 ] . pubkey = token_owner_record_cookie2. address , // token_owner_record_address
381
465
None ,
@@ -415,6 +499,7 @@ async fn test_revoke_council_tokens_with_too_large_amount_error() {
415
499
& realm_cookie,
416
500
& token_owner_record_cookie,
417
501
& realm_cookie. account . config . council_mint . unwrap ( ) ,
502
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
418
503
200 ,
419
504
NopOverride ,
420
505
None ,
@@ -451,6 +536,7 @@ async fn test_revoke_council_tokens_with_partial_revoke_amount() {
451
536
& realm_cookie,
452
537
& token_owner_record_cookie,
453
538
& realm_cookie. account . config . council_mint . unwrap ( ) ,
539
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
454
540
5 ,
455
541
NopOverride ,
456
542
None ,
@@ -499,6 +585,7 @@ async fn test_revoke_council_tokens_with_community_mint_error() {
499
585
& realm_cookie,
500
586
& token_owner_record_cookie,
501
587
& realm_cookie. account . config . council_mint . unwrap ( ) ,
588
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
502
589
1 ,
503
590
|i| {
504
591
i. accounts [ 1 ] . pubkey = governing_token_holding_address;
@@ -543,6 +630,7 @@ async fn test_revoke_council_tokens_with_not_matching_mint_and_authority_error()
543
630
& realm_cookie,
544
631
& token_owner_record_cookie,
545
632
& realm_cookie. account . config . council_mint . unwrap ( ) ,
633
+ realm_cookie. council_mint_authority . as_ref ( ) . unwrap ( ) ,
546
634
1 ,
547
635
|i| {
548
636
i. accounts [ 3 ] . pubkey = governing_token_mint;
0 commit comments