Skip to content

Commit

Permalink
test UpdateOracle and RemoveOracle
Browse files Browse the repository at this point in the history
  • Loading branch information
canonbrother committed Nov 1, 2024
1 parent d5557e2 commit 3d23870
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions apps/whale-api/src/module.api/__defid__/oracles.defid.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,3 +214,43 @@ it('should get oracles by owner address', async () => {
expect(toCompare).toStrictEqual(oracle)
}
})

it('test UpdateOracle and RemoveOracle', async () => {
const { data: oraclesBefore } = await controller.list()

const before = oraclesBefore[0]
const oracleId = before.id
const address = before.ownerAddress

{
await client.oracle.updateOracle(oracleId, address, {
priceFeeds: [
{ token: 'TD', currency: 'USD' }
],
weightage: 3
})
await container.generate(1)
const height = await app.getBlockCount()
await container.generate(1)
await app.waitForBlockHeight(height)
}

const { data: oracles } = await controller.list()
const after = oracles.find((oracle) => oracle.id === oracleId)
expect(after?.id).toStrictEqual(before.id)
expect(after?.priceFeeds).toStrictEqual([{ token: 'TD', currency: 'USD' }])
expect(after?.weightage).toStrictEqual(3)

{
await client.oracle.removeOracle(oracleId)
await container.generate(1)
const height = await app.getBlockCount()
await container.generate(1)
await app.waitForBlockHeight(height)
}

const { data: oraclesFinal } = await controller.list()
expect(oraclesFinal.length).toStrictEqual(oraclesBefore.length - 1)
const removed = oraclesFinal.find((oracle) => oracle.id === oracleId)
expect(removed).toBeUndefined()
})

0 comments on commit 3d23870

Please sign in to comment.