Skip to content

Commit 2e823e2

Browse files
authored
Merge pull request #1000 from KyberNetwork/duc/add_untest_event
add test for missing event
2 parents bc805fa + 49ce397 commit 2e823e2

File tree

3 files changed

+29
-6
lines changed

3 files changed

+29
-6
lines changed

test/sol6/kyberDao.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -387,9 +387,10 @@ contract('KyberDao', function(accounts) {
387387

388388
let link = web3.utils.fromAscii("https://kyberswap.com");
389389
await updateCurrentBlockAndTimestamp();
390+
let options = [1,2,3,4]
390391
let txResult = await submitNewCampaign(kyberDao,
391392
0, currentBlock + 2, currentBlock + 2 + minCampPeriod,
392-
minPercentageInPrecision, cInPrecision, tInPrecision, [1, 2, 3, 4], link, {from: daoOperator}
393+
minPercentageInPrecision, cInPrecision, tInPrecision, options, link, {from: daoOperator}
393394
);
394395
expectEvent(txResult, 'NewCampaignCreated', {
395396
campaignType: new BN(0),
@@ -401,6 +402,14 @@ contract('KyberDao', function(accounts) {
401402
tInPrecision: new BN(tInPrecision),
402403
link: link
403404
});
405+
let eventLogs;
406+
for (let i = 0; i < txResult.logs.length; i++) {
407+
if (txResult.logs[i].event == 'NewCampaignCreated') {
408+
eventLogs = txResult.logs[i];
409+
break;
410+
}
411+
}
412+
Helper.assertEqualArray(eventLogs.args.options, options);
404413

405414
await Helper.setNextBlockTimestamp(blockToTimestamp(currentBlock + 2));
406415
// vote for first campaign

test/sol6/kyberFeeHandler.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,13 @@ contract('KyberFeeHandler', function(accounts) {
470470
it("should have updated BRR if expiryTimestamp == 2 ** 64 - 1", async() => {
471471
let maxExpiryTimestamp = new BN(2).pow(new BN(64)).sub(new BN(1));
472472
await mockKyberDao.setMockEpochAndExpiryTimestamp(defaultEpoch, maxExpiryTimestamp);
473-
await feeHandler.getBRR();
473+
let txResult = await feeHandler.getBRR();
474+
expectEvent(txResult, "BRRUpdated", {
475+
rewardBps: rewardInBPS,
476+
rebateBps: rebateInBPS,
477+
epoch: epoch,
478+
expiryTimestamp: maxExpiryTimestamp,
479+
})
474480
let result = await feeHandler.readBRRData();
475481
Helper.assertEqual(result.expiryTimestamp, maxExpiryTimestamp, "expiry timestamp was not updated");
476482
});

test/sol6/withdrawableNoModifiers.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ let initialEtherBalance = new BN(10);
1414
let etherWithdrawAmt = new BN(3);
1515

1616
const {zeroBN} = require("../helper.js");
17-
const { expectRevert } = require('@openzeppelin/test-helpers');
17+
const { expectRevert, expectEvent } = require('@openzeppelin/test-helpers');
1818

1919
contract('WithdrawableNoModifiers', function(accounts) {
2020
before("should init globals, deploy test token", async function () {
@@ -37,7 +37,12 @@ contract('WithdrawableNoModifiers', function(accounts) {
3737
Helper.assertEqual(admin, rxAdmin, "wrong admin " + rxAdmin.toString());
3838

3939
// withdraw the tokens from withdrawableInst
40-
await withdrawableInst.withdrawToken(token.address, tokenWithdrawAmt, user, {from: admin});
40+
let txResult = await withdrawableInst.withdrawToken(token.address, tokenWithdrawAmt, user, {from: admin});
41+
expectEvent(txResult, "TokenWithdraw", {
42+
token: token.address,
43+
amount: tokenWithdrawAmt,
44+
sendTo: user,
45+
})
4146

4247
balance = await token.balanceOf(withdrawableInst.address);
4348
Helper.assertEqual(balance, initialTokenBalance.sub(tokenWithdrawAmt), "unexpected balance in withdrawble contract.");
@@ -76,8 +81,11 @@ contract('WithdrawableNoModifiers', function(accounts) {
7681

7782
it("should test withdraw ether success for admin.", async function () {
7883
// withdraw the ether from withdrawableInst
79-
await withdrawableInst.withdrawEther(etherWithdrawAmt, user, {from: admin});
80-
84+
let txResult = await withdrawableInst.withdrawEther(etherWithdrawAmt, user, {from: admin});
85+
expectEvent(txResult, "EtherWithdraw", {
86+
amount: etherWithdrawAmt,
87+
sendTo: user,
88+
})
8189
let balance = await Helper.getBalancePromise(withdrawableInst.address);
8290
Helper.assertEqual(balance, initialEtherBalance.sub(etherWithdrawAmt), "unexpected balance in withdrawble contract.");
8391
});

0 commit comments

Comments
 (0)