Skip to content

Commit

Permalink
chore: Add build check and fixes to tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrantuk committed Jul 26, 2024
1 parent baa4dfc commit fd6891a
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 9 deletions.
17 changes: 13 additions & 4 deletions typescript/.eslintrc.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,15 @@
module.exports = {
root: true,
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: ['eslint:recommended', 'plugin:@typescript-eslint/recommended', 'prettier'],
root: true,
overrides: [
{
files: ['src/**/*.ts', 'test/**/*.ts'],
parser: '@typescript-eslint/parser',
plugins: ['@typescript-eslint', 'prettier'],
extends: [
'eslint:recommended',
'plugin:@typescript-eslint/recommended',
'prettier',
],
},
],
};
1 change: 1 addition & 0 deletions typescript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
],
"scripts": {
"build": "tsup",
"build:test": "npx tsup ./test",
"format": "prettier --config .prettierrc 'src/**/*.ts' --write",
"lint": "dpdm -T ./src && eslint ./src --ext .ts",
"lint:fix": "eslint ./src --ext .ts --fix",
Expand Down
2 changes: 2 additions & 0 deletions typescript/test/adds.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ describe('addLiqudity tests', () => {
async ({ test, inputAmountsRaw, bptOutRaw, kind }) => {
const pool = testData.pools.get(test);
if (!pool) throw new Error('No pool data');
if (pool.poolType === 'Buffer')
throw Error('Buffer pools do not support addLiquidity');
// console.log("Input Amounts: ", inputAmountsRaw);
// console.log("BptOut: ", bptOutRaw);
const vault = new Vault();
Expand Down
9 changes: 4 additions & 5 deletions typescript/test/customPool.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// pnpm test -- customPool.test.ts
import { describe, expect, test } from 'vitest';
import { MaxSwapParams, Vault, type PoolBase } from '../src';
import { Vault, type PoolBase } from '../src';

describe('custom pool tests', () => {
test('should pick up new pool', () => {
Expand All @@ -26,6 +26,7 @@ describe('custom pool tests', () => {
tokenRates: [1000000000000000000n, 1000000000000000000n],
totalSupply: 1736721048412749353n,
randoms: [77n, 88n],
aggregateSwapFee: 0n,
};

const calculatedAmount = vault.swap(
Expand All @@ -44,13 +45,11 @@ describe('custom pool tests', () => {
class CustomPool implements PoolBase {
public randoms: bigint[];

constructor(poolState: {
randoms: bigint[];
}) {
constructor(poolState: { randoms: bigint[] }) {
this.randoms = poolState.randoms;
}

getMaxSwapAmount(_maxSwapParams: MaxSwapParams): bigint {
getMaxSwapAmount(): bigint {
return 1n;
}

Expand Down
2 changes: 2 additions & 0 deletions typescript/test/remove.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ describe('removeLiqudity tests', () => {
async ({ test, bptInRaw, amountsOutRaw, kind }) => {
const pool = testData.pools.get(test);
if (!pool) throw new Error('No pool data');
if (pool.poolType === 'Buffer')
throw Error('Buffer pools do not support removeLiquidity');
const vault = new Vault();

const calculatedAmounts = vault.removeLiquidity(
Expand Down
2 changes: 2 additions & 0 deletions typescript/test/utils/readTestData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ function mapPool(
weights: (
pool as TransformBigintToString<WeightedPool>
).weights.map((w) => BigInt(w)),
aggregateSwapFee: BigInt(pool.aggregateSwapFee ?? '0'),
};
}
if (pool.poolType === 'Stable') {
Expand All @@ -164,6 +165,7 @@ function mapPool(
tokenRates: pool.tokenRates.map((r) => BigInt(r)),
totalSupply: BigInt(pool.totalSupply),
amp: BigInt((pool as TransformBigintToString<StablePool>).amp),
aggregateSwapFee: BigInt(pool.aggregateSwapFee ?? '0'),
};
}
if (pool.poolType === 'Buffer') {
Expand Down

0 comments on commit fd6891a

Please sign in to comment.