Skip to content

Commit

Permalink
test: minor updates to tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Chris-Hibbert committed Aug 19, 2024
1 parent cbb5b55 commit 694bed1
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 14 deletions.
18 changes: 10 additions & 8 deletions packages/inter-protocol/test/auction/sortedOffers.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,10 @@ import {
ratiosSame,
makeRatioFromAmounts,
quantize,
subtractRatios,
} from '@agoric/zoe/src/contractSupport/index.js';
import { setup } from '@agoric/zoe/test/unitTests/setupBasicMints.js';
import { AmountMath } from '@agoric/ertp';
import {
fromPriceOfferKey,
toPriceOfferKey,
Expand Down Expand Up @@ -65,6 +67,10 @@ test('toKey discount', t => {
t.true(keyD26 > keyD25);
});

const ratiosEqual = (t, left, right) => {
t.true(AmountMath.isEmpty(subtractRatios(left, right).numerator));
};

test('fromKey Price', t => {
const { moola, moolaKit, simoleans, simoleanKit } = setup();
const { brand: moolaBrand } = moolaKit;
Expand All @@ -81,12 +87,7 @@ test('fromKey Price', t => {
t.true(
ratiosSame(priceAOut, makeRatioFromAmounts(moola(40n * N), simoleans(N))),
);
t.true(
ratiosSame(
priceBOut,
quantize(makeRatioFromAmounts(moola(40n), simoleans(1000n)), N),
),
);
ratiosEqual(t, priceBOut, makeRatioFromAmounts(moola(40n), simoleans(1000n)));
t.is(timeA, DEC25);
t.is(timeB, DEC25);
});
Expand All @@ -104,8 +105,9 @@ test('fromKey discount', t => {

const [discountAOut, timeA] = fromScaledRateOfferKey(keyA25, moolaBrand, 9);
const [discountBOut, timeB] = fromScaledRateOfferKey(keyB25, moolaBrand, 9);
t.deepEqual(quantize(discountAOut, 10000n), quantize(fivePercent, 10000n));
t.deepEqual(
ratiosEqual(t, discountAOut, fivePercent);
ratiosEqual(
t,
quantize(discountBOut, 10000n),
quantize(fivePointFivePercent, 10000n),
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,11 +72,11 @@ Generated by [AVA](https://avajs.dev).
compoundedInterest: {
denominator: {
brand: Object @Alleged: IST brand {},
value: 100000000000000000000n,
value: 857701650301172500n,
},
numerator: {
brand: Object @Alleged: IST brand {},
value: 101967213114754098360n,
value: 874574469651359500n,
},
},
interestRate: {
Expand Down Expand Up @@ -387,11 +387,11 @@ Generated by [AVA](https://avajs.dev).
interest: {
denominator: {
brand: Object @Alleged: IST brand {},
value: 100000000000000000000n,
value: 857701650301172500n,
},
numerator: {
brand: Object @Alleged: IST brand {},
value: 101967213114754098360n,
value: 874574469651359500n,
},
},
},
Expand All @@ -413,11 +413,11 @@ Generated by [AVA](https://avajs.dev).
interest: {
denominator: {
brand: Object @Alleged: IST brand {},
value: 100000000000000000000n,
value: 857701650301172500n,
},
numerator: {
brand: Object @Alleged: IST brand {},
value: 101967213114754098360n,
value: 874574469651359500n,
},
},
},
Expand Down
Binary file not shown.

0 comments on commit 694bed1

Please sign in to comment.