@@ -17,6 +17,7 @@ import {
17
17
createReplaceIx ,
18
18
createTransferAuthorityIx ,
19
19
createVerifyLeafIx ,
20
+ prepareTreeIx ,
20
21
ValidDepthSizePair ,
21
22
} from '../src' ;
22
23
import { hash , MerkleTree } from '../src/merkle-tree' ;
@@ -708,6 +709,30 @@ describe('Account Compression', () => {
708
709
'Updated on chain root matches root of updated off chain tree'
709
710
) ;
710
711
} ) ;
712
+
713
+ it ( 'Should fail to prepare a batch ready tree for an existing tree' , async ( ) => {
714
+ const prepareIx = prepareTreeIx ( cmt , payer , DEPTH_SIZE_PAIR ) ;
715
+ try {
716
+ await execute ( provider , [ prepareIx ] , [ payerKeypair ] ) ;
717
+ assert ( false , 'Prepare a batch tree should have failed for the existing tree' ) ;
718
+ } catch { }
719
+ } ) ;
720
+
721
+ it ( 'Should fail to finalize an existing tree' , async ( ) => {
722
+ const index = offChainTree . leaves . length - 1 ;
723
+ const finalizeIx = createFinalizeMerkleTreeWithRootIx (
724
+ cmt ,
725
+ payer ,
726
+ offChainTree . root ,
727
+ offChainTree . leaves [ index ] . node ,
728
+ index ,
729
+ offChainTree . getProof ( index ) . proof ,
730
+ ) ;
731
+ try {
732
+ await execute ( provider , [ finalizeIx ] , [ payerKeypair ] ) ;
733
+ assert ( false , 'Finalize an existing tree should have failed' ) ;
734
+ } catch { }
735
+ } ) ;
711
736
} ) ;
712
737
713
738
describe ( 'Examples transferring authority' , ( ) => {
@@ -1022,6 +1047,22 @@ describe('Account Compression', () => {
1022
1047
await execute ( provider , [ replaceIx , replaceBackIx ] , [ payerKeypair ] , true , true ) ;
1023
1048
}
1024
1049
} ) ;
1050
+
1051
+ it ( 'Should fail to append a canopy node for an existing tree' , async ( ) => {
1052
+ [ cmtKeypair , offChainTree ] = await createTreeOnChain (
1053
+ provider ,
1054
+ payerKeypair ,
1055
+ 0 ,
1056
+ { maxBufferSize : 8 , maxDepth : DEPTH } ,
1057
+ DEPTH // Store full tree on chain
1058
+ ) ;
1059
+ cmt = cmtKeypair . publicKey ;
1060
+ const appendIx = createAppendCanopyNodesIx ( cmt , payer , [ crypto . randomBytes ( 32 ) ] , 0 ) ;
1061
+ try {
1062
+ await execute ( provider , [ appendIx ] , [ payerKeypair ] ) ;
1063
+ assert ( false , 'Appending a canopy node for an existing tree should have failed' ) ;
1064
+ } catch { }
1065
+ } ) ;
1025
1066
} ) ;
1026
1067
describe ( `Having created a tree with 8 leaves` , ( ) => {
1027
1068
beforeEach ( async ( ) => {
0 commit comments