Skip to content

Commit

Permalink
Merge branch 'next' into feat/add-graphql-errors-codes
Browse files Browse the repository at this point in the history
  • Loading branch information
Rubilmax authored Oct 24, 2024
2 parents 163b99e + 0cb3217 commit 05bd401
Show file tree
Hide file tree
Showing 9 changed files with 24 additions and 55 deletions.
13 changes: 2 additions & 11 deletions packages/blue-sdk-ethers/test/e2e/Market.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,11 +76,6 @@ describe("augment/Market", () => {
functionName: "enableIrm",
args: [params.irm],
});

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

await client.setNextBlockTimestamp({ timestamp });

await client.writeContract({
address: morpho,
abi: blueAbi,
Expand All @@ -94,7 +89,7 @@ describe("augment/Market", () => {
totalSupplyShares: 0n,
totalBorrowAssets: 0n,
totalBorrowShares: 0n,
lastUpdate: BigInt(timestamp),
lastUpdate: await client.timestamp(),
fee: 0n,
price: 1160095030000000000000000000000000000n,
rateAtTarget: undefined,
Expand All @@ -113,10 +108,6 @@ describe("augment/Market", () => {
...crvUsd_stkcvx2BTC,
oracle: randomAddress(),
});

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

await client.setNextBlockTimestamp({ timestamp });
await client.writeContract({
address: morpho,
abi: blueAbi,
Expand All @@ -130,7 +121,7 @@ describe("augment/Market", () => {
totalSupplyShares: 0n,
totalBorrowAssets: 0n,
totalBorrowShares: 0n,
lastUpdate: 1711597274n,
lastUpdate: 1711597272n,
fee: 0n,
rateAtTarget: 1268391679n,
});
Expand Down
13 changes: 2 additions & 11 deletions packages/blue-sdk-viem/test/Market.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,11 +75,6 @@ describe("augment/Market", () => {
functionName: "enableIrm",
args: [params.irm],
});

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

await client.setNextBlockTimestamp({ timestamp });

await client.writeContract({
address: morpho,
abi: blueAbi,
Expand All @@ -93,7 +88,7 @@ describe("augment/Market", () => {
totalSupplyShares: 0n,
totalBorrowAssets: 0n,
totalBorrowShares: 0n,
lastUpdate: BigInt(timestamp),
lastUpdate: await client.timestamp(),
fee: 0n,
price: 1160095030000000000000000000000000000n,
rateAtTarget: undefined,
Expand All @@ -109,10 +104,6 @@ describe("augment/Market", () => {
...crvUsd_stkcvx2BTC,
oracle: randomAddress(),
});

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

await client.setNextBlockTimestamp({ timestamp });
await client.writeContract({
address: morpho,
abi: blueAbi,
Expand All @@ -126,7 +117,7 @@ describe("augment/Market", () => {
totalSupplyShares: 0n,
totalBorrowAssets: 0n,
totalBorrowShares: 0n,
lastUpdate: 1711597274n,
lastUpdate: 1711597272n,
fee: 0n,
rateAtTarget: 1268391679n,
});
Expand Down
4 changes: 3 additions & 1 deletion packages/blue-sdk/test/e2e/Market.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,8 +98,10 @@ describe("Market", () => {
collateral,
})!;

client.transport.tracer.next = false;

await expect(
client.estimateContractGas({
client.writeContract({
abi: blueAbi,
address: morpho,
functionName: "borrow",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -823,8 +823,8 @@ describe("erc4626-1inch", () => {
});

expect(format.number.of(decimalBalance, decimals)).toBeCloseTo(
7369.26594494,
8,
7369.265945,
6,
);
},
);
Expand Down Expand Up @@ -956,8 +956,8 @@ describe("erc4626-1inch", () => {
});

expect(format.number.of(decimalBalance, decimals)).toBeCloseTo(
7325.59189336,
8,
7325.591893,
6,
);
},
);
Expand Down Expand Up @@ -1403,8 +1403,8 @@ describe("erc4626-1inch", () => {
});

expect(format.number.of(decimalBalance, decimals)).toBeCloseTo(
11652.93471896,
8,
11652.934719,
6,
);
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -411,9 +411,6 @@ describe("useSimulationState", () => {

expect(data0).toBe(steps[0]);

await client.setNextBlockTimestamp({
timestamp: data0.block.timestamp + 1n,
});
await client.approve({
address: usdc,
args: [morpho, amount],
Expand All @@ -432,9 +429,6 @@ describe("useSimulationState", () => {
expect(data1).toStrictEqual(step1);

await client.setBalance({ address: morpho, value: parseEther("1") });
await client.setNextBlockTimestamp({
timestamp: data1.block.timestamp + 1n,
});
await client.writeContract({
account: morpho,
address: usdc,
Expand Down
2 changes: 1 addition & 1 deletion packages/test-viem/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"build": "tsc"
},
"dependencies": {
"viem-tracer": "^1.2.0"
"viem-tracer": "^1.3.1"
},
"peerDependencies": {
"@morpho-org/test": "workspace:^",
Expand Down
12 changes: 0 additions & 12 deletions packages/test-viem/src/anvil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,12 +44,6 @@ export type AnvilTestClient<chain extends Chain = Chain> = Client<
DealActions &
PublicActions<TracedTransport<HttpTransport>, chain, HDAccount> &
WalletActions<chain, HDAccount> & {
tracing: {
txs: boolean;
calls: boolean;
nextCall: boolean;
};

timestamp(): Promise<bigint>;

approve(args: ApproveParameters<chain>): Promise<WriteContractReturnType>;
Expand Down Expand Up @@ -129,12 +123,6 @@ export const createAnvilTestClient = <chain extends Chain>(
let automine: boolean;

return {
tracing: {
txs: true,
calls: false,
nextCall: false,
},

async timestamp() {
const latestBlock = await client.getBlock();

Expand Down
7 changes: 5 additions & 2 deletions packages/test-viem/src/vitest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,12 @@ export const createViemTest = <chain extends Chain>(
client: async ({}, use) => {
const { rpcUrl, stop } = await spawnAnvil(parameters);

let client: AnvilTestClient<chain>;
const client = createAnvilTestClient(http(rpcUrl), chain);

await use((client = createAnvilTestClient(http(rpcUrl), chain)));
// Make block timestamp 100% predictable.
await client.setBlockTimestampInterval({ interval: 1 });

await use(client);

await stop();
},
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 05bd401

Please sign in to comment.