88 CompressedAccountWithMerkleContext ,
99 confirmTx ,
1010 createRpc ,
11- defaultTestStateTreeAccounts ,
1211 deriveAddressV2 ,
1312 deriveAddressSeedV2 ,
1413 batchAddressTree ,
@@ -18,6 +17,8 @@ import {
1817 SystemAccountMetaConfig ,
1918 featureFlags ,
2019 VERSION ,
20+ selectStateTreeInfo ,
21+ TreeInfo ,
2122} from " @lightprotocol/stateless.js" ;
2223import * as assert from " assert" ;
2324
@@ -49,7 +50,8 @@ describe("test-anchor-close", () => {
4950 await rpc .requestAirdrop (signer .publicKey , lamports );
5051 await sleep (2000 );
5152
52- const outputStateTree = defaultTestStateTreeAccounts ().merkleTree ;
53+ const stateTreeInfos = await rpc .getStateTreeInfos ();
54+ const stateTreeInfo = selectStateTreeInfo (stateTreeInfos );
5355 const addressTree = new web3 .PublicKey (batchAddressTree );
5456
5557 const messageSeed = new TextEncoder ().encode (" message" );
@@ -65,7 +67,7 @@ describe("test-anchor-close", () => {
6567 addressTree ,
6668 address ,
6769 closeProgram ,
68- outputStateTree ,
70+ stateTreeInfo ,
6971 signer ,
7072 " Hello, compressed world!" ,
7173 );
@@ -88,7 +90,7 @@ describe("test-anchor-close", () => {
8890 rpc ,
8991 compressedAccount ,
9092 closeProgram ,
91- outputStateTree ,
93+ stateTreeInfo ,
9294 signer ,
9395 " Hello, compressed world!" ,
9496 );
@@ -115,7 +117,7 @@ async function createCompressedAccount(
115117 addressTree : anchor .web3 .PublicKey ,
116118 address : anchor .web3 .PublicKey ,
117119 program : anchor .Program <Close >,
118- outputStateTree : anchor . web3 . PublicKey ,
120+ stateTreeInfo : TreeInfo ,
119121 signer : anchor .web3 .Keypair ,
120122 message : string ,
121123) {
@@ -142,7 +144,7 @@ async function createCompressedAccount(
142144 addressQueuePubkeyIndex ,
143145 };
144146 const outputStateTreeIndex =
145- remainingAccounts .insertOrGet (outputStateTree );
147+ remainingAccounts .insertOrGet (stateTreeInfo . queue );
146148
147149 let proof = {
148150 0 : proofRpcResult .compressedProof ,
@@ -171,7 +173,7 @@ async function closeCompressedAccount(
171173 rpc : Rpc ,
172174 compressedAccount : CompressedAccountWithMerkleContext ,
173175 program : anchor .Program <Close >,
174- outputStateTree : anchor . web3 . PublicKey ,
176+ stateTreeInfo : TreeInfo ,
175177 signer : anchor .web3 .Keypair ,
176178 message : string ,
177179) {
@@ -197,7 +199,7 @@ async function closeCompressedAccount(
197199 compressedAccount .treeInfo .queue ,
198200 );
199201 const outputStateTreeIndex =
200- remainingAccounts .insertOrGet (outputStateTree );
202+ remainingAccounts .insertOrGet (stateTreeInfo . queue );
201203
202204 const coder = new anchor .BorshCoder (closeIdl as anchor .Idl );
203205 const currentAccount = coder .types .decode (
@@ -210,7 +212,7 @@ async function closeCompressedAccount(
210212 merkleTreePubkeyIndex ,
211213 queuePubkeyIndex ,
212214 leafIndex: compressedAccount .leafIndex ,
213- proveByIndex: false ,
215+ proveByIndex: true ,
214216 rootIndex: proofRpcResult .rootIndices [0 ],
215217 },
216218 address: compressedAccount .address ,
0 commit comments