|
1 | 1 | use crate::program_test::nft_voter_test::ConfigureCollectionArgs;
|
| 2 | +use gpl_nft_voter::error::NftVoterError; |
2 | 3 | use program_test::nft_voter_test::NftVoterTest;
|
| 4 | +use program_test::tools::assert_nft_voter_err; |
3 | 5 | use solana_program_test::*;
|
4 | 6 | use solana_sdk::transport::TransportError;
|
5 | 7 |
|
@@ -194,3 +196,82 @@ async fn test_relinquish_nft_vote_for_proposal_in_voting_state() -> Result<(), T
|
194 | 196 |
|
195 | 197 | Ok(())
|
196 | 198 | }
|
| 199 | + |
| 200 | +#[tokio::test] |
| 201 | +async fn test_relinquish_nft_vote_for_proposal_in_voting_state_and_vote_record_exists_error( |
| 202 | +) -> Result<(), TransportError> { |
| 203 | + // Arrange |
| 204 | + let mut nft_voter_test = NftVoterTest::start_new().await; |
| 205 | + |
| 206 | + let realm_cookie = nft_voter_test.governance.with_realm().await?; |
| 207 | + |
| 208 | + let registrar_cookie = nft_voter_test.with_registrar(&realm_cookie).await?; |
| 209 | + |
| 210 | + let nft_collection_cookie = nft_voter_test.token_metadata.with_nft_collection().await?; |
| 211 | + |
| 212 | + let max_voter_weight_record_cookie = nft_voter_test |
| 213 | + .with_max_voter_weight_record(®istrar_cookie) |
| 214 | + .await?; |
| 215 | + |
| 216 | + nft_voter_test |
| 217 | + .with_collection( |
| 218 | + ®istrar_cookie, |
| 219 | + &nft_collection_cookie, |
| 220 | + &max_voter_weight_record_cookie, |
| 221 | + None, |
| 222 | + ) |
| 223 | + .await?; |
| 224 | + |
| 225 | + let voter_cookie = nft_voter_test.bench.with_wallet().await; |
| 226 | + |
| 227 | + let voter_token_owner_record_cookie = nft_voter_test |
| 228 | + .governance |
| 229 | + .with_token_owner_record(&realm_cookie, &voter_cookie) |
| 230 | + .await?; |
| 231 | + |
| 232 | + let voter_weight_record_cookie = nft_voter_test |
| 233 | + .with_voter_weight_record(®istrar_cookie, &voter_cookie) |
| 234 | + .await?; |
| 235 | + |
| 236 | + let proposal_cookie = nft_voter_test |
| 237 | + .governance |
| 238 | + .with_proposal(&realm_cookie) |
| 239 | + .await?; |
| 240 | + |
| 241 | + let nft_cookie1 = nft_voter_test |
| 242 | + .token_metadata |
| 243 | + .with_nft_v2(&nft_collection_cookie, &voter_cookie, None) |
| 244 | + .await?; |
| 245 | + |
| 246 | + let nft_vote_record_cookies = nft_voter_test |
| 247 | + .cast_nft_vote( |
| 248 | + ®istrar_cookie, |
| 249 | + &voter_weight_record_cookie, |
| 250 | + &max_voter_weight_record_cookie, |
| 251 | + &proposal_cookie, |
| 252 | + &voter_cookie, |
| 253 | + &voter_token_owner_record_cookie, |
| 254 | + &[&nft_cookie1], |
| 255 | + ) |
| 256 | + .await?; |
| 257 | + |
| 258 | + // Act |
| 259 | + |
| 260 | + let err = nft_voter_test |
| 261 | + .relinquish_nft_vote( |
| 262 | + ®istrar_cookie, |
| 263 | + &voter_weight_record_cookie, |
| 264 | + &proposal_cookie, |
| 265 | + &voter_cookie, |
| 266 | + &voter_token_owner_record_cookie, |
| 267 | + &nft_vote_record_cookies, |
| 268 | + ) |
| 269 | + .await |
| 270 | + .err() |
| 271 | + .unwrap(); |
| 272 | + |
| 273 | + // Assert |
| 274 | + assert_nft_voter_err(err, NftVoterError::VoteRecordMustBeWithdrawn); |
| 275 | + |
| 276 | + Ok(()) |
| 277 | +} |
0 commit comments