Skip to content

Commit

Permalink
test: fixed type errors
Browse files Browse the repository at this point in the history
  • Loading branch information
0x31 committed Oct 30, 2019
1 parent a36a8cf commit 84e4e6d
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
3 changes: 2 additions & 1 deletion test/DarknodePayment.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BN from "bn.js";

import { config } from "../migrations/networks";
import {
CycleChangerInstance, DarknodePaymentInstance, DarknodePaymentStoreInstance,
DarknodeRegistryInstance, DarknodeSlasherInstance, ERC20Instance, RenTokenInstance,
Expand All @@ -16,6 +15,8 @@ const DarknodeRegistry = artifacts.require("DarknodeRegistry");
const SelfDestructingToken = artifacts.require("SelfDestructingToken");
const DarknodeSlasher = artifacts.require("DarknodeSlasher");

const { config } = require("../migrations/networks");

contract("DarknodePayment", (accounts: string[]) => {

let store: DarknodePaymentStoreInstance;
Expand Down
9 changes: 5 additions & 4 deletions test/DarknodeRegistry.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import BN from "bn.js";

import { config } from "../migrations/networks";
import {
DarknodeRegistryInstance, DarknodeRegistryStoreInstance, DarknodeSlasherInstance,
RenTokenInstance,
Expand All @@ -14,6 +13,8 @@ const DarknodeRegistryStore = artifacts.require("DarknodeRegistryStore");
const DarknodeRegistry = artifacts.require("DarknodeRegistry");
const DarknodeSlasher = artifacts.require("DarknodeSlasher");

const { config } = require("../migrations/networks");

contract("DarknodeRegistry", (accounts: string[]) => {

let ren: RenTokenInstance;
Expand Down Expand Up @@ -631,8 +632,8 @@ contract("DarknodeRegistry", (accounts: string[]) => {
});

describe("when darknode payment is not set", async () => {
let newDNRstore;
let newDNR;
let newDNRstore: DarknodeRegistryStoreInstance;
let newDNR: DarknodeRegistryInstance;

before(async () => {
// Deploy a new DNR and DNR store
Expand All @@ -657,7 +658,7 @@ contract("DarknodeRegistry", (accounts: string[]) => {
});

it("cannot slash", async () => {
(await newDNR.owner()).should.equal(accounts[0]);
(await newDNR.owner.call()).should.equal(accounts[0]);
const newSlasher = accounts[0];
await newDNR.updateSlasher(newSlasher);
await waitForEpoch(newDNR);
Expand Down
4 changes: 2 additions & 2 deletions test/Shifter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ contract("Shifter", ([owner, feeRecipient, user, malicious]) => {
const removeFee = (value: number | BN, bips: number | BN) =>
new BN(value).sub(new BN(value).mul(new BN(bips)).div(new BN(10000)));

const mintTest = async (shifter: ShifterInstance, value: number | BN, shiftID = undefined) => {
const mintTest = async (shifter: ShifterInstance, value: number | BN, shiftID?: string) => {
const nHash = randomBytes(32);
const pHash = randomBytes(32);

Expand Down Expand Up @@ -80,7 +80,7 @@ contract("Shifter", ([owner, feeRecipient, user, malicious]) => {
return [pHash, nHash];
};

const burnTest = async (shifter: ShifterInstance, value: number | BN, btcAddress?: string, shiftID = undefined) => {
const burnTest = async (shifter: ShifterInstance, value: number | BN, btcAddress?: string, shiftID?: string) => {
// Note: we don't use `||` because we want to pass in `""`
btcAddress = btcAddress !== undefined ? btcAddress : randomBytes(35);

Expand Down
18 changes: 9 additions & 9 deletions test/helper/logs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,10 @@ chai.use(function (newChai: any, utils: any): void {
utils.flag(this, property, true);
});

const override = function (fn) {
const override = function (fn: any) {
// tslint:disable-next-line:variable-name
return function (_super) {
return function (value, ...args) {
return function (_super: any) {
return function (value: any, ...args: any[]) {
if (utils.flag(this, property)) {
const expected = value;
const actual = getLogsFromTx(this._obj);
Expand Down Expand Up @@ -80,22 +80,22 @@ chai.use(function (newChai: any, utils: any): void {
// skip if the property is from prototype
if (!expectedLog.args.hasOwnProperty(arg)) { continue; }

const expectedArg = expectedLog.args[arg];
const actualArg = actualLog.args[arg];
const expectedArg = (expectedLog.args as any)[arg];
const actualArg = (actualLog.args as any)[arg];

let sameValues: boolean;
if (BN.isBN(expectedArg) || expectedArg.isBigNumber) {
sameValues = (new BigNumber(expectedArg).eq(new BigNumber(actualArg)));
} else {
sameValues = (expectedArg === actualLog.args[arg]);
sameValues = (expectedArg === (actualLog.args as any)[arg]);
}

this.assert(
sameValues,
`expected ${arg} to be #{exp} instead of #{act} in log ${expectedLog.event}`,
`expected ${arg} to be different from #{exp} in log ${expectedLog.event}`,
expectedLog.args[arg],
actualLog.args[arg],
(expectedLog.args as any)[arg],
(actualLog.args as any)[arg],
);
}
}
Expand Down Expand Up @@ -134,7 +134,7 @@ export const getLogsFromTx = (tx: TransactionReceipt): Log[] => {
if (!logItem.args.hasOwnProperty(arg)) { continue; }

if (isNaN(parseInt(arg, 10)) && arg !== "__length__") {
args[arg] = logItem.args[arg];
(args as any)[arg] = (logItem.args as any)[arg];
}
}
return {
Expand Down
4 changes: 2 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,11 @@
"chai"
],
"module": "commonjs",
"noImplicitAny": false,
"noImplicitAny": true,
"noImplicitReturns": true,
"removeComments": true,
"preserveConstEnums": true,
"sourceMap": true,
"esModuleInterop": true
}
}
}

0 comments on commit 84e4e6d

Please sign in to comment.