From a0389e6e512e2cb6e00ee32ba250762a9c40c411 Mon Sep 17 00:00:00 2001 From: Ali Behjati Date: Tue, 27 Aug 2024 12:47:39 +0200 Subject: [PATCH] feat: add tests for this instruction and setMaxLatency --- src/__tests__/Anchor.test.ts | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/__tests__/Anchor.test.ts b/src/__tests__/Anchor.test.ts index d639aca..2d5508c 100644 --- a/src/__tests__/Anchor.test.ts +++ b/src/__tests__/Anchor.test.ts @@ -203,5 +203,27 @@ test('Anchor', (done) => { expect(decoded?.data.securityAuthority.equals(new PublicKey(8))).toBeTruthy() }) + pythOracle.methods + .setMaxLatency(1, [0,0,0]) + .accounts({ fundingAccount: PublicKey.unique(), priceAccount: PublicKey.unique() }) + .instruction() + .then((instruction) => { + expect(instruction.data).toStrictEqual(Buffer.from([2, 0, 0, 0, 18, 0, 0, 0, 1, 0, 0, 0])) + const decoded = pythOracleCoder().instruction.decode(instruction.data) + expect(decoded?.name).toBe('setMaxLatency') + expect(decoded?.data.maxLatency === 1).toBeTruthy() + }) + + pythOracle.methods + .initPriceFeedIndex() + .accounts({ fundingAccount: PublicKey.unique(), priceAccount: PublicKey.unique(), permissionsAccount: PublicKey.unique() }) + .instruction() + .then((instruction) => { + expect(instruction.data).toStrictEqual(Buffer.from([2, 0, 0, 0, 19, 0, 0, 0])) + const decoded = pythOracleCoder().instruction.decode(instruction.data) + expect(decoded?.name).toBe('initPriceFeedIndex') + expect(decoded?.data).toStrictEqual({}) + }) + done() })