Skip to content

Commit

Permalink
test: Fix undefined tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
johngrantuk committed Oct 18, 2023
1 parent 3dc7efd commit 3c232b0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 12 deletions.
9 changes: 5 additions & 4 deletions test/weightedExit.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ describe('weighted exit test', () => {
expect(queryResult.bptIn.amount).to.eq(bptIn.amount);

// We only expect single asset to have a value for exit
expect(queryResult.tokenOutIndex).to.be.toBeDefined;
expect(queryResult.tokenOutIndex !== undefined).toEqual(true);
queryResult.amountsOut.forEach((a, i) => {
if (i === queryResult.tokenOutIndex)
expect(a.amount > 0n).to.be.true;
Expand Down Expand Up @@ -146,8 +146,8 @@ describe('weighted exit test', () => {
// Query should use correct BPT amount
expect(queryResult.bptIn.amount).to.eq(bptIn.amount);

expect(queryResult.tokenOutIndex === undefined).toEqual(true);
// We expect all assets to have a value for exit
expect(queryResult.tokenOutIndex).to.be.undefined;
queryResult.amountsOut.forEach((a) => {
expect(a.amount > 0n).to.be.true;
});
Expand Down Expand Up @@ -184,8 +184,8 @@ describe('weighted exit test', () => {
// We expect a BPT input amount > 0
expect(queryResult.bptIn.amount > 0n).to.be.true;

expect(queryResult.tokenOutIndex === undefined).toEqual(true);
// We expect assets to have same amount out as user defined
expect(queryResult.tokenOutIndex).to.be.undefined;
queryResult.amountsOut.forEach((a, i) => {
expect(a.amount).to.eq(amountsOut[i].amount);
});
Expand Down Expand Up @@ -219,8 +219,9 @@ describe('weighted exit test', () => {
// Query should use correct BPT amount
expect(queryResult.bptIn.amount).to.eq(bptIn.amount);

expect(queryResult.tokenOutIndex === undefined).toEqual(true);

// We expect all assets to have a value for exit
expect(queryResult.tokenOutIndex).to.be.undefined;
queryResult.amountsOut.forEach((a) => {
expect(a.amount > 0n).to.be.true;
});
Expand Down
16 changes: 8 additions & 8 deletions test/weightedJoin.integration.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,10 +128,10 @@ describe('weighted join test', () => {

// Query should use same amountsIn as user sets
expect(queryResult.amountsIn).to.deep.eq(amountsIn);
expect(queryResult.tokenInIndex).to.be.undefined;
expect(queryResult.tokenInIndex === undefined).toEqual(true);

// Should be no native value
expect(value).toBeUndefined;
expect(value === undefined).toEqual(true);

// Expect some bpt amount
expect(queryResult.bptOut.amount > 0n).to.be.true;
Expand Down Expand Up @@ -174,7 +174,8 @@ describe('weighted join test', () => {
expect(queryResult.amountsIn.map((a) => a.amount)).to.deep.eq(
amountsIn.map((a) => a.amount),
);
expect(queryResult.tokenInIndex).to.be.undefined;
expect(queryResult.tokenInIndex === undefined).toEqual(true);

// Should have native value equal to input amount
expect(value).eq(amountsIn[0].amount);

Expand Down Expand Up @@ -213,15 +214,15 @@ describe('weighted join test', () => {
expect(queryResult.bptOut.amount).to.deep.eq(bptOut.amount);

// We only expect single asset to have a value for amount in
expect(queryResult.tokenInIndex).toBeDefined;
expect(queryResult.tokenInIndex !== undefined).toEqual(true);
queryResult.amountsIn.forEach((a, i) => {
if (i === queryResult.tokenInIndex)
expect(a.amount > 0n).to.be.true;
else expect(a.amount === 0n).to.be.true;
});

// Should be no native value
expect(value).toBeUndefined;
expect(value === undefined).toEqual(true);

// Confirm slippage - only to amount in not bpt out
const expectedMaxAmountsIn = queryResult.amountsIn.map((a) =>
Expand Down Expand Up @@ -251,15 +252,14 @@ describe('weighted join test', () => {
// Query should use same bpt out as user sets
expect(queryResult.bptOut.amount).to.deep.eq(bptOut.amount);

expect(queryResult.tokenInIndex === undefined).toEqual(true);
// Expect all assets to have a value for amount in
expect(queryResult.tokenInIndex).toBeDefined;
queryResult.amountsIn.forEach((a) => {
expect(a.amount > 0n).to.be.true;
});
expect(queryResult.tokenInIndex).toBeUndefined;

// Should be no native value
expect(value).toBeUndefined;
expect(value === undefined).toEqual(true);

// Confirm slippage - only to amount in not bpt out
const expectedMaxAmountsIn = queryResult.amountsIn.map((a) =>
Expand Down

0 comments on commit 3c232b0

Please sign in to comment.