|
| 1 | +#![cfg(feature = "test-sbf")] |
| 2 | +#![feature(type_changing_struct_update)] |
| 3 | + |
| 4 | +use example_native_token_transfers::error::NTTError; |
| 5 | +use ntt_messages::mode::Mode; |
| 6 | +use solana_program_test::*; |
| 7 | +use solana_sdk::{instruction::InstructionError, signer::Signer, transaction::TransactionError}; |
| 8 | + |
| 9 | +use crate::{ |
| 10 | + common::{setup::setup, submit::Submittable}, |
| 11 | + sdk::instructions::admin::{set_threshold, SetThreshold}, |
| 12 | +}; |
| 13 | + |
| 14 | +pub mod common; |
| 15 | +pub mod sdk; |
| 16 | + |
| 17 | +#[tokio::test] |
| 18 | +async fn test_zero_threshold() { |
| 19 | + let (mut ctx, test_data) = setup(Mode::Locking).await; |
| 20 | + |
| 21 | + let err = set_threshold( |
| 22 | + &test_data.ntt, |
| 23 | + SetThreshold { |
| 24 | + owner: test_data.program_owner.pubkey(), |
| 25 | + }, |
| 26 | + 0, |
| 27 | + ) |
| 28 | + .submit_with_signers(&[&test_data.program_owner], &mut ctx) |
| 29 | + .await |
| 30 | + .unwrap_err(); |
| 31 | + assert_eq!( |
| 32 | + err.unwrap(), |
| 33 | + TransactionError::InstructionError( |
| 34 | + 0, |
| 35 | + InstructionError::Custom(NTTError::ZeroThreshold.into()) |
| 36 | + ) |
| 37 | + ); |
| 38 | +} |
| 39 | + |
| 40 | +#[tokio::test] |
| 41 | +async fn test_threshold_too_high() { |
| 42 | + let (mut ctx, test_data) = setup(Mode::Burning).await; |
| 43 | + |
| 44 | + let err = set_threshold( |
| 45 | + &test_data.ntt, |
| 46 | + SetThreshold { |
| 47 | + owner: test_data.program_owner.pubkey(), |
| 48 | + }, |
| 49 | + 2, |
| 50 | + ) |
| 51 | + .submit_with_signers(&[&test_data.program_owner], &mut ctx) |
| 52 | + .await |
| 53 | + .unwrap_err(); |
| 54 | + assert_eq!( |
| 55 | + err.unwrap(), |
| 56 | + TransactionError::InstructionError( |
| 57 | + 0, |
| 58 | + InstructionError::Custom(NTTError::ThresholdTooHigh.into()) |
| 59 | + ) |
| 60 | + ); |
| 61 | +} |
0 commit comments