From 6d6efadf39007a9dde3a4b2e8156deda63ef201d Mon Sep 17 00:00:00 2001 From: techvoyagerX Date: Mon, 23 Sep 2024 05:24:23 -0400 Subject: [PATCH] fix: separate PDA handling for multiple token programs in escrow tests --- tests/escrow/tests/escrow.ts | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/tests/escrow/tests/escrow.ts b/tests/escrow/tests/escrow.ts index 2b1c8f392a..8a7d1481fc 100644 --- a/tests/escrow/tests/escrow.ts +++ b/tests/escrow/tests/escrow.ts @@ -116,6 +116,16 @@ describe("escrow", () => { }); it("Initialize escrow", async () => { + const [escrowPda, _nonce] = await PublicKey.findProgramAddress( + [ + Buffer.from(anchor.utils.bytes.utf8.encode("escrow")), + tokenProgramIdA.toBuffer(), + ], + program.programId + ); + + pda = escrowPda; + await program.rpc.initializeEscrow( new BN(initializerAmount), new BN(takerAmount), @@ -132,14 +142,6 @@ describe("escrow", () => { } ); - // Get the PDA that is assigned authority to token account. - const [_pda, _nonce] = await PublicKey.findProgramAddress( - [Buffer.from(anchor.utils.bytes.utf8.encode("escrow"))], - program.programId - ); - - pda = _pda; - let _initializerTokenAccountA = await mintA.getAccountInfo( initializerTokenAccountA ); @@ -230,6 +232,16 @@ describe("escrow", () => { initializerAmount ); + const [escrowPda, _nonce] = await PublicKey.findProgramAddress( + [ + Buffer.from(anchor.utils.bytes.utf8.encode("escrow")), + tokenProgramIdA.toBuffer(), + ], + program.programId + ); + + pda = escrowPda; + await program.rpc.initializeEscrow( new BN(initializerAmount), new BN(takerAmount),