Skip to content

Commit

Permalink
Update assertEventEmission method
Browse files Browse the repository at this point in the history
  • Loading branch information
jwheur committed Jun 25, 2019
1 parent f7820f8 commit 94f7de0
Show file tree
Hide file tree
Showing 20 changed files with 64 additions and 59 deletions.
2 changes: 1 addition & 1 deletion contracts/NukeCoin.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
*Submitted for verification at Etherscan.io on 2019-06-05
*/

pragma solidity ^0.5.0;
pragma solidity ^0.4.25;

interface IERC20 {
function totalSupply() external view returns (uint256);
Expand Down
2 changes: 1 addition & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion test/TestAirDropper/sendEther.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ contract('Test createSwap', async (accounts) => {
contract('test event emission', async () => {
it('emits a SendEther event', async () => {
const result = await airDropper.sendEther(id, receiver, 1000)
assertEventEmission(result.receipt.rawLogs, [
assertEventEmission(result, [
{
eventType: 'SendEther',
args: {
Expand Down
4 changes: 2 additions & 2 deletions test/TestAtomicBroker/cancelSwap.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ contract('Test cancelSwap', async (accounts) => {
await increaseEvmTime(700)
const result = await cancelSwap(atomicBroker, { ...swapParams, cancelFeeAmount: 2 })

assertEventEmission(result.receipt.rawLogs, [
assertEventEmission(result, [
{
eventType: 'BalanceDecrease',
args: {
Expand Down Expand Up @@ -204,7 +204,7 @@ contract('Test cancelSwap', async (accounts) => {
await increaseEvmTime(700)
const result = await cancelSwap(atomicBroker, { ...swapParams, cancelFeeAmount: 5 })

assertEventEmission(result.receipt.rawLogs, [
assertEventEmission(result, [
{
eventType: 'BalanceDecrease',
args: {
Expand Down
4 changes: 2 additions & 2 deletions test/TestAtomicBroker/createSwap.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ contract('Test createSwap', async (accounts) => {
it('emits BalanceDecrease, BalanceIncrease, CreateSwap events', async () => {
const swapParams = await getSampleSwapParams({ maker, taker, token })
const result = await createSwap(atomicBroker, swapParams)
assertEventEmission(result.receipt.rawLogs, [
assertEventEmission(result, [
{
eventType: 'BalanceDecrease',
args: {
Expand Down Expand Up @@ -69,7 +69,7 @@ contract('Test createSwap', async (accounts) => {
swapParams.feeAsset = secondToken.address
swapParams.feeAmount = 9
const result = await createSwap(atomicBroker, swapParams)
assertEventEmission(result.receipt.rawLogs, [
assertEventEmission(result, [
{
eventType: 'BalanceDecrease',
args: {
Expand Down
4 changes: 2 additions & 2 deletions test/TestAtomicBroker/executeSwap.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract('Test executeSwap', async (accounts) => {
contract('test event emission', async () => {
it('emits BalanceDecrease, BalanceIncrease, BalanceDecrease, BalanceIncrease, ExecuteSwap events', async () => {
const result = await executeSwap(atomicBroker, swapParams)
assertEventEmission(result.receipt.rawLogs, [
assertEventEmission(result, [
{
eventType: 'BalanceDecrease',
args: {
Expand Down Expand Up @@ -144,7 +144,7 @@ contract('Test executeSwap', async (accounts) => {
contract('test event emission', async () => {
it('emits BalanceDecrease, BalanceIncrease, BalanceDecrease, BalanceIncrease, ExecuteSwap events', async () => {
const result = await executeSwap(atomicBroker, swapParams)
assertEventEmission(result.receipt.rawLogs, [
assertEventEmission(result, [
{
eventType: 'BalanceDecrease',
args: {
Expand Down
4 changes: 2 additions & 2 deletions test/TestBroker/announceCancel.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ contract('Test announceCancel', async () => {

contract('test event emission', async () => {
it('emits CancelAnnounce event', async () => {
const { receipt: { rawLogs: logs } } = await broker.announceCancel(sampleOfferHash, { from: user })
assertEventEmission(logs, [{
const result = await broker.announceCancel(sampleOfferHash, { from: user })
assertEventEmission(result, [{
eventType: 'CancelAnnounce',
args: {
user: user,
Expand Down
12 changes: 6 additions & 6 deletions test/TestBroker/cancel.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,8 @@ contract('Test cancel', async () => {
await makeOffer(broker, params)
const offerHash = getOfferHash(params)
const { v, r, s } = await signCancel({ offerParams: params, feeAsset: ETHER_ADDR, feeAmount: 0 })
const { receipt: { rawLogs: logs } } = await broker.cancel(offerHash, params.offerAmount, ETHER_ADDR, 0, v, r, s, { from: coordinator })
assertEventEmission(logs, [{
const result = await broker.cancel(offerHash, params.offerAmount, ETHER_ADDR, 0, v, r, s, { from: coordinator })
assertEventEmission(result, [{
eventType: 'BalanceIncrease',
args: {
user: user,
Expand All @@ -62,7 +62,7 @@ contract('Test cancel', async () => {
await makeOffer(broker, params)
const offerHash = getOfferHash(params)
const { v, r, s } = await signCancel({ offerParams: params, feeAsset: ETHER_ADDR, feeAmount: 2 })
const { receipt: { rawLogs: logs } } = await broker.cancel(offerHash, params.offerAmount, ETHER_ADDR, 2, v, r, s, { from: coordinator })
const result = await broker.cancel(offerHash, params.offerAmount, ETHER_ADDR, 2, v, r, s, { from: coordinator })
const expectedEvents = [
{
eventType: 'BalanceIncrease',
Expand Down Expand Up @@ -90,7 +90,7 @@ contract('Test cancel', async () => {
}
}
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
})
})

Expand All @@ -100,7 +100,7 @@ contract('Test cancel', async () => {
await makeOffer(broker, params)
const offerHash = getOfferHash(params)
const { v, r, s } = await signCancel({ offerParams: params, feeAsset: token.address, feeAmount: 7 })
const { receipt: { rawLogs: logs } } = await broker.cancel(offerHash, params.offerAmount, token.address, 7, v, r, s, { from: coordinator })
const result = await broker.cancel(offerHash, params.offerAmount, token.address, 7, v, r, s, { from: coordinator })
const expectedEvents = [
{
eventType: 'BalanceIncrease',
Expand Down Expand Up @@ -137,7 +137,7 @@ contract('Test cancel', async () => {
}
}
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
})
})
})
Expand Down
5 changes: 3 additions & 2 deletions test/TestBroker/depositERC20.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,9 @@ contract('Test depositERC20', async () => {
contract('test event emission', async () => {
it('emits BalanceIncrease event', async () => {
await token.approve.sendTransaction(broker.address, 42, { from: user })
const receipt = await broker.depositERC20(user, token.address, 20, { from: coordinator })
assertEventEmission(receipt.logs, [{
const result = await broker.depositERC20(user, token.address, 20, { from: coordinator })
result.receipt.logs = result.logs
assertEventEmission(result, [{
eventType: 'BalanceIncrease',
args: {
user: user,
Expand Down
4 changes: 2 additions & 2 deletions test/TestBroker/depositEther.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ contract('Test depositEther', async () => {
contract('test event emission', async () => {
it('emits BalanceIncrease event', async () => {
const amount = web3.utils.toWei('1', 'ether')
const { receipt: { rawLogs: logs } } = await broker.depositEther({ from: user, value: amount })
assertEventEmission(logs, [{
const result = await broker.depositEther({ from: user, value: amount })
assertEventEmission(result, [{
eventType: 'BalanceIncrease',
args: {
user: user,
Expand Down
4 changes: 2 additions & 2 deletions test/TestBroker/emergencyCancel.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ contract('Test emergencyCancel', async () => {
await broker.setState.sendTransaction(1)

const offerHash = getOfferHash(params)
const { receipt: { rawLogs: logs } } = await broker.emergencyCancel(offerHash, params.offerAmount, { from: coordinator })
assertEventEmission(logs, [{
const result = await broker.emergencyCancel(offerHash, params.offerAmount, { from: coordinator })
assertEventEmission(result, [{
eventType: 'BalanceIncrease',
args: {
user: user,
Expand Down
4 changes: 2 additions & 2 deletions test/TestBroker/emergencyWithdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ contract('Test emergencyWithdraw', async () => {
contract('test event emission', async () => {
it('emits BalanceDecrease event', async () => {
await broker.setState.sendTransaction(1)
const { receipt: { rawLogs: logs } } = await broker.emergencyWithdraw(user, ETHER_ADDR, initialEtherBalance)
assertEventEmission(logs, [{
const result = await broker.emergencyWithdraw(user, ETHER_ADDR, initialEtherBalance)
assertEventEmission(result, [{
eventType: 'BalanceDecrease',
args: {
user: user,
Expand Down
4 changes: 2 additions & 2 deletions test/TestBroker/fastCancel.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ contract('Test fastCancel', async () => {
contract('test event emission', async () => {
it('emits BalanceIncrease and Cancel events', async () => {
await broker.announceCancel.sendTransaction(sampleOfferHash, { from: user })
const { receipt: { rawLogs: logs } } = await broker.fastCancel(sampleOfferHash, sampleOffer.offerAmount)
assertEventEmission(logs, [{
const result = await broker.fastCancel(sampleOfferHash, sampleOffer.offerAmount)
assertEventEmission(result, [{
eventType: 'BalanceIncrease',
args: {
user: user,
Expand Down
12 changes: 6 additions & 6 deletions test/TestBroker/fillOffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ contract('Test fillOffer', async () => {
// amountToTakeAfterFees: 3 ETH - 1 ETH = 2 ETH
const signature = await signFillOffer(fillParams)
const { v, r, s } = signature
const { receipt: { rawLogs: logs } } = await broker.fillOffer(fillParams.filler, fillParams.offerHash, fillParams.amountToTake,
const result = await broker.fillOffer(fillParams.filler, fillParams.offerHash, fillParams.amountToTake,
fillParams.feeAsset, fillParams.feeAmount, fillParams.nonce, v, r, s)
const offer = await fetchOffer(broker, fillParams.offerHash)

Expand Down Expand Up @@ -269,7 +269,7 @@ contract('Test fillOffer', async () => {
}
}
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
})
})

Expand All @@ -292,7 +292,7 @@ contract('Test fillOffer', async () => {
// amountToTakeAfterFees: 3 ETH
const signature = await signFillOffer(fillParams)
const { v, r, s } = signature
const { receipt: { rawLogs: logs } } = await broker.fillOffer(fillParams.filler, fillParams.offerHash, fillParams.amountToTake,
const result = await broker.fillOffer(fillParams.filler, fillParams.offerHash, fillParams.amountToTake,
fillParams.feeAsset, fillParams.feeAmount, fillParams.nonce, v, r, s)
const offer = await fetchOffer(broker, fillParams.offerHash)

Expand Down Expand Up @@ -358,7 +358,7 @@ contract('Test fillOffer', async () => {
}
}
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
})
})

Expand All @@ -380,7 +380,7 @@ contract('Test fillOffer', async () => {
// amountToTakeAfterFees: 3 ETH
const signature = await signFillOffer(fillParams)
const { v, r, s } = signature
const { receipt: { rawLogs: logs } } = await broker.fillOffer(fillParams.filler, fillParams.offerHash, fillParams.amountToTake,
const result = await broker.fillOffer(fillParams.filler, fillParams.offerHash, fillParams.amountToTake,
fillParams.feeAsset, fillParams.feeAmount, fillParams.nonce, v, r, s)
const offer = await fetchOffer(broker, fillParams.offerHash)

Expand Down Expand Up @@ -446,7 +446,7 @@ contract('Test fillOffer', async () => {
}
}
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
})
})
})
Expand Down
12 changes: 6 additions & 6 deletions test/TestBroker/makeOffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ contract('Test makeOffer', async () => {
const offerHash = getOfferHash(params)
const signature = await signMakeOffer(params)
const { v, r, s } = signature
const { receipt: { rawLogs: logs } } = await broker.makeOffer(params.maker, params.offerAsset, params.wantAsset,
const result = await broker.makeOffer(params.maker, params.offerAsset, params.wantAsset,
params.offerAmount, params.wantAmount, params.feeAsset, params.feeAmount, params.nonce, v, r, s)
assertEventEmission(logs, [{
assertEventEmission(result, [{
eventType: 'BalanceDecrease',
args: {
user: user,
Expand Down Expand Up @@ -66,7 +66,7 @@ contract('Test makeOffer', async () => {
const offerHash = getOfferHash(params)
const signature = await signMakeOffer(params)
const { v, r, s } = signature
const { receipt: { rawLogs: logs } } = await broker.makeOffer(params.maker, params.offerAsset, params.wantAsset,
const result = await broker.makeOffer(params.maker, params.offerAsset, params.wantAsset,
params.offerAmount, params.wantAmount, params.feeAsset, params.feeAmount, params.nonce, v, r, s)
const expectedEvents = [
{
Expand Down Expand Up @@ -95,7 +95,7 @@ contract('Test makeOffer', async () => {
}
}
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
})
})

Expand All @@ -109,7 +109,7 @@ contract('Test makeOffer', async () => {
const offerHash = getOfferHash(params)
const signature = await signMakeOffer(params)
const { v, r, s } = signature
const { receipt: { rawLogs: logs } } = await broker.makeOffer(params.maker, params.offerAsset, params.wantAsset,
const result = await broker.makeOffer(params.maker, params.offerAsset, params.wantAsset,
params.offerAmount, params.wantAmount, params.feeAsset, params.feeAmount, params.nonce, v, r, s)
const expectedEvents = [
{
Expand Down Expand Up @@ -147,7 +147,7 @@ contract('Test makeOffer', async () => {
}
}
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
})

})
Expand Down
4 changes: 2 additions & 2 deletions test/TestBroker/slowCancel.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ contract('Test slowCancel', async () => {
it('emits BalanceIncrease and Cancel events', async () => {
await broker.announceCancel.sendTransaction(sampleOfferHash, { from: user })
await increaseEvmTime(announceDelay)
const { receipt: { rawLogs: logs } } = await broker.slowCancel(sampleOfferHash)
assertEventEmission(logs, [{
const result = await broker.slowCancel(sampleOfferHash)
assertEventEmission(result, [{
eventType: 'BalanceIncrease',
args: {
user: user,
Expand Down
8 changes: 4 additions & 4 deletions test/TestBroker/slowWithdraw.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ contract('Test announceWithdraw + slowWithdraw', async () => {
})

it('emits WithdrawAnnounce and BalanceDecrease event', async () => {
const r1 = await broker.announceWithdraw(ETHER_ADDR, ethersDeposited, { from: user })
assertEventEmission(r1.logs, [{
const result1 = await broker.announceWithdraw(ETHER_ADDR, ethersDeposited, { from: user })
assertEventEmission(result1, [{
eventType: 'WithdrawAnnounce',
args: {
user: user,
Expand All @@ -36,8 +36,8 @@ contract('Test announceWithdraw + slowWithdraw', async () => {

await increaseEvmTime(announceDelay)

const r2 = await broker.slowWithdraw(user, ETHER_ADDR, ethersDeposited, { from: user })
assertEventEmission(r2.logs, [{
const result2 = await broker.slowWithdraw(user, ETHER_ADDR, ethersDeposited, { from: user })
assertEventEmission(result2, [{
eventType: 'BalanceDecrease',
args: {
user: user,
Expand Down
12 changes: 6 additions & 6 deletions test/TestBroker/spendFrom.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,8 +80,8 @@ contract('Broker', function ([coordinator, notOwner, spender, from, to]) {
})

it('emits an approval event', async function () {
const { receipt: { rawLogs: logs } } = await this.broker.approveSpender(spender, { from })
assertEventEmission(logs, [{
const result = await this.broker.approveSpender(spender, { from })
assertEventEmission(result, [{
eventType: 'SpenderApprove',
args: {
user: from,
Expand Down Expand Up @@ -119,8 +119,8 @@ contract('Broker', function ([coordinator, notOwner, spender, from, to]) {
})

it('emits a rescind event', async function () {
const { receipt: { rawLogs: logs } } = await this.broker.rescindApproval(spender, { from })
assertEventEmission(logs, [{
const result = await this.broker.rescindApproval(spender, { from })
assertEventEmission(result, [{
eventType: 'SpenderRescind',
args: {
user: from,
Expand Down Expand Up @@ -185,7 +185,7 @@ contract('Broker', function ([coordinator, notOwner, spender, from, to]) {
});

it('emits increase and decrease balance event', async function () {
const { receipt: { rawLogs: logs } } = await this.broker.spendFrom(from, to, amount, ETHER_ADDR, decreaseReason, increaseReason, { from: spender });
const result = await this.broker.spendFrom(from, to, amount, ETHER_ADDR, decreaseReason, increaseReason, { from: spender });
const expectedEvents = [
{
eventType: 'BalanceDecrease',
Expand All @@ -206,7 +206,7 @@ contract('Broker', function ([coordinator, notOwner, spender, from, to]) {
}
},
]
assertEventEmission(logs, expectedEvents)
assertEventEmission(result, expectedEvents)
});
});

Expand Down
Loading

0 comments on commit 94f7de0

Please sign in to comment.