Skip to content

Conversation

@juangm
Copy link
Contributor

@juangm juangm commented Jul 17, 2025

No description provided.

@juangm juangm requested a review from cesarenaldi July 17, 2025 14:08
@juangm juangm self-assigned this Jul 17, 2025
describe('When supplying assets in an available market', () => {
// Hardcoded market info for now
const marketInfo = {
address: '0x87870Bca3F3fD6335C3F4ce8392D69350B4fA4E2',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's move this to a test-utils const.

And let's query the reserve:

const result = await reserve(client, {
  chainId: ETHEREUM_FORK_ID,
  market: <new const name>,
  underlyingToken: WETH_ADDRESS
})

Comment on lines 76 to 78
if (supplyInfo.value[0]?.balance.amount.value === bigDecimal('0')) {
throw new Error('User does not have supply to withdraw');
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not an expect(...)?

"new:package": "NODE_OPTIONS='--import tsx' plop --plopfile=plopfile.ts",
"prepublish": "pnpm run build",
"test:client": "vitest --project client",
"test:client:local": "ENVIRONMENT=local vitest --project client",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is doable with a simple ENVIRONMENT=local in front of any of the commands. I am not sure if we should have these scripts proliferating.

import { supply, withdraw } from './transactions';
import { userSupplies } from './user';

const supplyAndGetUserSupplies = async (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a good idea.

To make these 2 helpers self contained I suggest we make the signature self-contained so it's not possible to user them wrong.

I can explain quick in an huddle.

nit: use traditional function declaration which are named and provide better insights in stacktraces.

expect.objectContaining({
balance: expect.objectContaining({
amount: expect.objectContaining({
value: expect.any(String),
Copy link
Contributor

@cesarenaldi cesarenaldi Jul 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you try expect.closeTo here so we don't need the manual handling after?

https://jestjs.io/docs/expect#expectclosetonumber-numdigits

);
}

export async function getReserveInfo(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ReserveInfo is a very specific type. This function returns a Reserve, the naming could be misleading.

I suggest:

fetchReserve

The second argument seems not used, let's keep interface surfaces to a minimal until we need to add more. Less is better.

vitest.setup.ts Outdated
expect.extend(matchers);

expect.extend({
toBeNumericStringCloseTo(received: string, expected: number, precision = 2) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
toBeNumericStringCloseTo(received: string, expected: number, precision = 2) {
toBeBigDecimalCloseTo(received: string, expected: number | string, precision = 2) {

@cesarenaldi cesarenaldi merged commit d66a378 into main Jul 21, 2025
1 check passed
@juangm juangm deleted the juan/supply-tests branch July 21, 2025 17:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants