Skip to content
This repository has been archived by the owner on Sep 28, 2022. It is now read-only.

Commit

Permalink
fix liquidations tests
Browse files Browse the repository at this point in the history
  • Loading branch information
b-pmcg committed Nov 15, 2021
1 parent 5b6baef commit 3200731
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 14 deletions.
3 changes: 1 addition & 2 deletions packages/dai-plugin-liquidations/contracts/abis/Clipper.json
Original file line number Diff line number Diff line change
Expand Up @@ -456,8 +456,7 @@
"name": "upchost",
"outputs": [],
"stateMutability": "nonpayable",
"type": "function",
"constant": true
"type": "function"
},
{
"inputs": [],
Expand Down
15 changes: 9 additions & 6 deletions packages/dai-plugin-liquidations/src/LiquidationService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,13 @@ import { PublicService } from '@makerdao/services-core';
import {
bytes32ToNumber,
numberToBytes32
} from '@makerdao/dai/src/utils/conversion';
} from '../../dai/src/utils/conversion';
// import {
// bytes32ToNumber,
// numberToBytes32
// } from '@makerdao/dai/src/utils/conversion';
import assert from 'assert';
import { utils } from 'ethers';
import tracksTransactions from './utils/tracksTransactions';
const MAINNET_SERVER_URL = 'https://api.makerdao.com/graphql';
//const LOCAL_URL = 'http://localhost:3001/graphql';
Expand All @@ -15,11 +20,9 @@ export const RAY = new BigNumber('1e27');

export const nullBytes = '0x';

export const stringToBytes = str => {
assert(!!str, 'argument is falsy');
assert(typeof str === 'string', 'argument is not a string');
return '0x' + Buffer.from(str).toString('hex');
};
export function stringToBytes(str) {
return utils.formatBytes32String(str);
}

//hard-coded for now, but can get from pips, which you can get from ilk registry
const medianizers = {
Expand Down
12 changes: 7 additions & 5 deletions packages/dai-plugin-liquidations/test/LiquidationService.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { takeSnapshot, restoreSnapshot } from '@makerdao/test-helpers';
import Maker from '@makerdao/dai';
import { McdPlugin, YFI } from '@makerdao/dai-plugin-mcd';
// import Maker from '@makerdao/dai/';
import Maker from '../../dai/src';
// import { McdPlugin, YFI } from '@makerdao/dai-plugin-mcd';
import { McdPlugin, YFI } from '../../dai-plugin-mcd/src';
import BigNumber from 'bignumber.js';
import liquidationPlugin from '../src';
import LiquidationService, {
Expand Down Expand Up @@ -145,11 +147,11 @@ describe('LiquidationService', () => {
test('can get status from on chain', async () => {
const { needsRedo, price, lot, tab } = await service.getStatus(ilk, 1);

const collateralAmount = new BigNumber(lot).div(WAD);
const daiNeeded = new BigNumber(tab).div(RAD);
const collateralAmount = new BigNumber(lot._hex).div(WAD);
const daiNeeded = new BigNumber(tab._hex).div(RAD);

expect(collateralAmount.gt(0)).toBe(true);
expect(new BigNumber(price).div(RAY).toString()).toEqual('19500');
expect(new BigNumber(price._hex).div(RAY).toString()).toEqual('19500');
expect(daiNeeded.toNumber()).toBeCloseTo(1000);
expect(needsRedo).toEqual(false);
});
Expand Down
3 changes: 2 additions & 1 deletion packages/dai-plugin-liquidations/test/utils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DAI } from '@makerdao/dai-plugin-mcd';
// import { DAI } from '@makerdao/dai-plugin-mcd';
import { DAI } from '../../dai-plugin-mcd/src';
import { mineBlocks } from '../../test-helpers/src';
import BigNumber from 'bignumber.js';
import { stringToBytes } from '../src/LiquidationService';
Expand Down

0 comments on commit 3200731

Please sign in to comment.