aboutsummaryrefslogtreecommitdiffstats
path: root/packages/contracts/test/exchange/core.ts
diff options
context:
space:
mode:
authorAmir Bandeali <abandeali1@gmail.com>2018-08-28 07:34:42 +0800
committerAmir Bandeali <abandeali1@gmail.com>2018-08-31 00:26:44 +0800
commitafa2dd73743398f3973ab7de5a7a0d4c18acc5a5 (patch)
tree5f0b503014d2afef8986ce8ccfe786a620eec967 /packages/contracts/test/exchange/core.ts
parentd80701c2779512324c7a9bef2a87b6f63239d281 (diff)
downloaddexon-0x-contracts-afa2dd73743398f3973ab7de5a7a0d4c18acc5a5.tar.gz
dexon-0x-contracts-afa2dd73743398f3973ab7de5a7a0d4c18acc5a5.tar.zst
dexon-0x-contracts-afa2dd73743398f3973ab7de5a7a0d4c18acc5a5.zip
Add test for fillOrder and dispatchTransferFrom where maker == taker
Diffstat (limited to 'packages/contracts/test/exchange/core.ts')
-rw-r--r--packages/contracts/test/exchange/core.ts39
1 files changed, 38 insertions, 1 deletions
diff --git a/packages/contracts/test/exchange/core.ts b/packages/contracts/test/exchange/core.ts
index 3bb71b58f..acb99eed1 100644
--- a/packages/contracts/test/exchange/core.ts
+++ b/packages/contracts/test/exchange/core.ts
@@ -8,7 +8,10 @@ import { LogWithDecodedArgs } from 'ethereum-types';
import ethUtil = require('ethereumjs-util');
import * as _ from 'lodash';
-import { DummyERC20TokenContract } from '../../generated_contract_wrappers/dummy_erc20_token';
+import {
+ DummyERC20TokenContract,
+ DummyERC20TokenTransferEventArgs,
+} from '../../generated_contract_wrappers/dummy_erc20_token';
import { DummyERC721TokenContract } from '../../generated_contract_wrappers/dummy_erc721_token';
import { DummyNoReturnERC20TokenContract } from '../../generated_contract_wrappers/dummy_no_return_erc20_token';
import { ERC20ProxyContract } from '../../generated_contract_wrappers/erc20_proxy';
@@ -243,6 +246,40 @@ describe('Exchange core', () => {
RevertReason.ValidatorError,
);
});
+
+ it('should not emit transfer events for transfers where from == to', async () => {
+ const txReceipt = await exchangeWrapper.fillOrderAsync(signedOrder, makerAddress);
+ const logs = txReceipt.logs;
+ const transferLogs = _.filter(
+ logs,
+ log => (log as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).event === 'Transfer',
+ );
+ expect(transferLogs.length).to.be.equal(2);
+ expect((transferLogs[0] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).address).to.be.equal(
+ zrxToken.address,
+ );
+ expect((transferLogs[0] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).args._from).to.be.equal(
+ makerAddress,
+ );
+ expect((transferLogs[0] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).args._to).to.be.equal(
+ feeRecipientAddress,
+ );
+ expect(
+ (transferLogs[0] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).args._value,
+ ).to.be.bignumber.equal(signedOrder.makerFee);
+ expect((transferLogs[1] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).address).to.be.equal(
+ zrxToken.address,
+ );
+ expect((transferLogs[1] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).args._from).to.be.equal(
+ makerAddress,
+ );
+ expect((transferLogs[1] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).args._to).to.be.equal(
+ feeRecipientAddress,
+ );
+ expect(
+ (transferLogs[1] as LogWithDecodedArgs<DummyERC20TokenTransferEventArgs>).args._value,
+ ).to.be.bignumber.equal(signedOrder.takerFee);
+ });
});
describe('Testing exchange of ERC20 tokens with no return values', () => {