Skip to content

Commit

Permalink
feat: add tests for this instruction and setMaxLatency
Browse files Browse the repository at this point in the history
  • Loading branch information
ali-bahjati committed Aug 27, 2024
1 parent 337bc21 commit a0389e6
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions src/__tests__/Anchor.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})

0 comments on commit a0389e6

Please sign in to comment.