@@ -11,8 +11,10 @@ import {
11
11
ASSOCIATED_TOKEN_PROGRAM_ID ,
12
12
createAssociatedTokenAccountIdempotentInstruction ,
13
13
createAssociatedTokenAccountInstruction ,
14
+ createFreezeAccountInstruction ,
14
15
createInitializeMintInstruction ,
15
16
createMintToInstruction ,
17
+ createThawAccountInstruction ,
16
18
createTransferCheckedInstruction ,
17
19
getAccount ,
18
20
getAssociatedTokenAddressSync ,
@@ -3675,6 +3677,78 @@ describe("vesting", () => {
3675
3677
}
3676
3678
} ) ;
3677
3679
3680
+ it ( "should fail to transfer vest if vester_ta is frozen" , async ( ) => {
3681
+ let freezeTx = new Transaction ( ) ;
3682
+ freezeTx . add (
3683
+ createFreezeAccountInstruction (
3684
+ vester3Ta ,
3685
+ whMintAccount . publicKey ,
3686
+ whMintAuthority . publicKey ,
3687
+ )
3688
+ ) ;
3689
+ await stakeConnection . provider . sendAndConfirm ( freezeTx , [ whMintAuthority ] ) ;
3690
+
3691
+ let vester3TaAccount = await getAccount ( stakeConnection . provider . connection , vester3Ta ) ;
3692
+ assert . equal ( vester3TaAccount . isFrozen , true , "vester3Ta should be frozen" ) ;
3693
+
3694
+ let stakeAccountMetadataAddress = await vester3StakeConnection . getStakeMetadataAddress (
3695
+ vester3 . publicKey
3696
+ ) ;
3697
+ let newVester3StakeAccountMetadataAddress =
3698
+ await newVester3StakeConnection . getStakeMetadataAddress (
3699
+ newVester3 . publicKey ,
3700
+ ) ;
3701
+
3702
+ let newVester3Vest = PublicKey . findProgramAddressSync (
3703
+ [
3704
+ Buffer . from ( wasm . Constants . VEST_SEED ( ) ) ,
3705
+ config . toBuffer ( ) ,
3706
+ newVester3Ta . toBuffer ( ) ,
3707
+ FEW_LATER . toBuffer ( "le" , 8 ) ,
3708
+ ] ,
3709
+ stakeConnection . program . programId
3710
+ ) [ 0 ] ;
3711
+
3712
+ try {
3713
+ await vesterStakeConnection . program . methods
3714
+ . transferVesting ( )
3715
+ . accounts ( {
3716
+ ...accounts ,
3717
+ vester : vester3 . publicKey ,
3718
+ vest : vest3NowForTransfer ,
3719
+ vestingBalance : vesting3Balance ,
3720
+ delegateStakeAccountCheckpoints : null ,
3721
+ delegateStakeAccountMetadata : null ,
3722
+ stakeAccountMetadata : stakeAccountMetadataAddress ,
3723
+ newStakeAccountMetadata : newVester3StakeAccountMetadataAddress ,
3724
+ vesterTa : vester3Ta ,
3725
+ newVesterTa : newVester3Ta ,
3726
+ newVest : newVester3Vest ,
3727
+ newVestingBalance : newVesting3Balance ,
3728
+ globalConfig : vester3StakeConnection . configAddress ,
3729
+ } )
3730
+ . signers ( [ vester3 ] )
3731
+ . rpc ( )
3732
+ . then ( confirm ) ;
3733
+
3734
+ assert . fail ( "Expected error was not thrown" ) ;
3735
+ } catch ( e ) {
3736
+ assert (
3737
+ ( e as AnchorError ) . error ?. errorCode ?. code === "FrozenVesterAccount" ,
3738
+ ) ;
3739
+ }
3740
+
3741
+ let thawTx = new Transaction ( ) ;
3742
+ thawTx . add (
3743
+ createThawAccountInstruction (
3744
+ vester3Ta ,
3745
+ whMintAccount . publicKey ,
3746
+ whMintAuthority . publicKey ,
3747
+ )
3748
+ ) ;
3749
+ await stakeConnection . provider . sendAndConfirm ( thawTx , [ whMintAuthority ] ) ;
3750
+ } ) ;
3751
+
3678
3752
it ( "should fail to transfer vest if the sender hasn't delegated, but the recipient has" , async ( ) => { } ) ;
3679
3753
3680
3754
it ( "should successfully transfer a vest when both the sender and recipient haven't delegated" , async ( ) => { } ) ;
0 commit comments