Skip to content

Commit

Permalink
test(blue-sdk-ethers): add invalid oracle Market test
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax committed Oct 21, 2024
1 parent 29cdf29 commit 4a21aad
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion packages/blue-sdk-ethers/test/e2e/Market.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ import { blueAbi } from "./abis.js";
import { test } from "./setup.js";

const { morpho, adaptiveCurveIrm } = addresses[ChainId.EthMainnet];
const { usdc_wstEth, usdc_idle, eth_wstEth } = markets[ChainId.EthMainnet];
const { usdc_wstEth, usdc_idle, eth_wstEth, crvUsd_stkcvx2BTC } =
markets[ChainId.EthMainnet];

describe("augment/Market", () => {
test("should fetch market data", async ({ wallet }) => {
Expand Down Expand Up @@ -103,4 +104,39 @@ describe("augment/Market", () => {

expect(value).toStrictEqual(expectedData);
});

test("should fetch market with incorrect oracle", async ({
client,
wallet,
}) => {
const params = new MarketParams({
...crvUsd_stkcvx2BTC,
oracle: randomAddress(),
});

const timestamp = (await client.timestamp()) + 3n;

await client.setNextBlockTimestamp({ timestamp });
await client.writeContract({
address: morpho,
abi: blueAbi,
functionName: "createMarket",
args: [{ ...params }],
});

const expectedData = new Market({
params,
totalSupplyAssets: 0n,
totalSupplyShares: 0n,
totalBorrowAssets: 0n,
totalBorrowShares: 0n,
lastUpdate: 1711597274n,
fee: 0n,
rateAtTarget: 1268391679n,
});

const value = await Market.fetch(params.id, wallet);

expect(value).toStrictEqual(expectedData);
});
});

0 comments on commit 4a21aad

Please sign in to comment.