Skip to content

Commit

Permalink
test: fix linting errors
Browse files Browse the repository at this point in the history
  • Loading branch information
vinceau committed Oct 3, 2019
1 parent 6606f4c commit 4ef8c37
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 21 deletions.
26 changes: 14 additions & 12 deletions test/DarknodePayment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@ import BN from "bn.js";

import { config } from "../migrations/networks";
import {
CycleChangerInstance, DarknodePaymentInstance, DarknodePaymentStoreInstance,
DarknodeRegistryInstance, ERC20Instance, RenTokenInstance, DarknodeSlasherInstance,
} from "../types/truffle-contracts";
CycleChangerInstance, DarknodePaymentInstance, DarknodePaymentStoreInstance, DarknodeRegistryInstance,
DarknodeSlasherInstance, ERC20Instance, RenTokenInstance } from "../types/truffle-contracts";
import {
ETHEREUM_TOKEN_ADDRESS, MINIMUM_BOND, NULL, PUBK, waitForEpoch,
} from "./helper/testUtils";
Expand Down Expand Up @@ -257,7 +256,6 @@ contract("DarknodePayment", (accounts: string[]) => {
// sanity check that the reward pool is also zero
(await fetchRewardPool(dai.address)).should.bignumber.equal(new BN(0));


// amount we're going to top up
const amount = new BN("100000000000000000");
await depositDai(amount);
Expand Down Expand Up @@ -378,7 +376,7 @@ contract("DarknodePayment", (accounts: string[]) => {
// We should only have one darknode
(new BN(await dnr.numDarknodesPreviousEpoch())).should.bignumber.equal(1);
// Register the darknodes
for (let i = startDarknode; i < startDarknode+numDarknodes; i++) {
for (let i = startDarknode; i < startDarknode + numDarknodes; i++) {
await registerDarknode(i);
}
await waitForEpoch(dnr);
Expand All @@ -392,7 +390,7 @@ contract("DarknodePayment", (accounts: string[]) => {
// since darknode has not been around for a full epoch
await tick(accounts[i]).should.be.rejectedWith(/cannot claim for this epoch/);
}

const rewards = new BN("300000000000000000");
await depositDai(rewards);

Expand Down Expand Up @@ -597,8 +595,10 @@ contract("DarknodePayment", (accounts: string[]) => {

describe("when updating cycle changer", async () => {
it("cannot update cycleChanger if unauthorized", async () => {
await dnp.updateCycleChanger(accounts[2], { from: accounts[2] }).should.be.rejectedWith(/Ownable: caller is not the owner./);
await dnp.updateCycleChanger(accounts[3], { from: accounts[3] }).should.be.rejectedWith(/Ownable: caller is not the owner./);
await dnp.updateCycleChanger(accounts[2], { from: accounts[2] })
.should.be.rejectedWith(/Ownable: caller is not the owner./);
await dnp.updateCycleChanger(accounts[3], { from: accounts[3] })
.should.be.rejectedWith(/Ownable: caller is not the owner./);
});

it("cannot update cycleChanger to an invalid address", async () => {
Expand All @@ -616,7 +616,8 @@ contract("DarknodePayment", (accounts: string[]) => {

describe("when forwarding funds", async () => {
it("cannot forward the ethereum address", async () => {
await dnp.forward("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE").should.eventually.be.rejectedWith(/not erc20/);
await dnp.forward("0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE")
.should.eventually.be.rejectedWith(/not erc20/);
});

it("cannot forward when there's no funds", async () => {
Expand Down Expand Up @@ -647,7 +648,8 @@ contract("DarknodePayment", (accounts: string[]) => {

describe("when changing payout percent", async () => {
it("cannot change payout percent unless authorized", async () => {
await dnp.updatePayoutPercentage(new BN(10), { from: accounts[2] }).should.be.rejectedWith(/Ownable: caller is not the owner./);
await dnp.updatePayoutPercentage(new BN(10), { from: accounts[2] })
.should.be.rejectedWith(/Ownable: caller is not the owner./);
});

it("cannot change payout percent to an invalid percent", async () => {
Expand Down Expand Up @@ -745,7 +747,7 @@ contract("DarknodePayment", (accounts: string[]) => {

const asRewardPoolBalance = async (amount: BN | string | number): Promise<BN> => {
const balance = new BN(amount);
const payoutPercent = new BN(await dnp.currentCyclePayoutPercent());
const payoutPercent = new BN(await dnp.currentCyclePayoutPercent());
const rewardPool = balance.div(new BN(100)).mul(payoutPercent);
return rewardPool;
};
Expand All @@ -767,5 +769,5 @@ contract("DarknodePayment", (accounts: string[]) => {
new BN(await dnp.nextCyclePayoutPercent()).should.bignumber.equal(p);
await waitForEpoch(dnr);
new BN(await dnp.currentCyclePayoutPercent()).should.bignumber.equal(p);
}
};
});
10 changes: 5 additions & 5 deletions test/DarknodeRegistry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -483,7 +483,7 @@ contract("DarknodeRegistry", (accounts: string[]) => {

it("cannot slash with an invalid percent", async () => {
// [ACTION] Update slasher address
const newSlasher = accounts[0]
const newSlasher = accounts[0];
await dnr.updateSlasher(newSlasher);
await waitForEpoch(dnr);
(await dnr.slasher()).should.equal(newSlasher);
Expand Down Expand Up @@ -630,7 +630,6 @@ contract("DarknodeRegistry", (accounts: string[]) => {
await dnr.claimStoreOwnership();
});


describe("when darknode payment is not set", async () => {
let newDNRstore;
let newDNR;
Expand All @@ -644,7 +643,7 @@ contract("DarknodeRegistry", (accounts: string[]) => {
newDNRstore.address,
config.MINIMUM_BOND,
config.MINIMUM_POD_SIZE,
config.MINIMUM_EPOCH_INTERVAL_SECONDS
config.MINIMUM_EPOCH_INTERVAL_SECONDS,
);
// Initiate ownership transfer of DNR store
await newDNRstore.transferOwnership(newDNR.address);
Expand All @@ -659,7 +658,7 @@ contract("DarknodeRegistry", (accounts: string[]) => {

it("cannot slash", async () => {
(await newDNR.owner()).should.equal(accounts[0]);
const newSlasher = accounts[0]
const newSlasher = accounts[0];
await newDNR.updateSlasher(newSlasher);
await waitForEpoch(newDNR);
(await newDNR.slasher()).should.equal(newSlasher);
Expand All @@ -670,7 +669,8 @@ contract("DarknodeRegistry", (accounts: string[]) => {
}
await ren.approve(newDNR.address, MINIMUM_BOND, { from: accounts[8] });
await newDNR.register(ID("8"), PUBK("8"), { from: accounts[8] });
await newDNR.slash(ID("8"), newSlasher, new BN(10)).should.eventually.be.rejectedWith(/invalid payment address/);
await newDNR.slash(ID("8"), newSlasher, new BN(10))
.should.eventually.be.rejectedWith(/invalid payment address/);
});
});

Expand Down
4 changes: 2 additions & 2 deletions test/helper/testUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,13 @@ export const randomAddress = (): string => {

const increaseTimeHelper = async (seconds: number) => {
await new Promise((resolve, reject) => {
web3.currentProvider.send(
return web3.currentProvider.send(
{ jsonrpc: "2.0", method: "evm_increaseTime", params: [seconds], id: 0 } as any,
((err: Error) => {
if (err) {
reject(err);
}
web3.currentProvider.send({
return web3.currentProvider.send({
jsonrpc: "2.0",
method: "evm_mine",
params: [],
Expand Down
5 changes: 3 additions & 2 deletions tslint.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"no-non-null-assertion": true,
"no-unused-expression": false,
"one-variable-per-declaration": false,
"space-before-function-paren": false
"space-before-function-paren": false,
"no-floating-promises": true
}
}
}

0 comments on commit 4ef8c37

Please sign in to comment.