diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-08-10 04:17:25 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-08-10 05:07:27 +0800 |
commit | 1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98 (patch) | |
tree | 9c7a18ff6016343f0371d3700badd944d62bc343 /packages/contracts/test/forwarder/forwarder.ts | |
parent | b9d8d2d5e3e7aa5f14ae2fd2019460890497bb7e (diff) | |
download | dexon-sol-tools-1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98.tar dexon-sol-tools-1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98.tar.gz dexon-sol-tools-1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98.tar.bz2 dexon-sol-tools-1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98.tar.lz dexon-sol-tools-1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98.tar.xz dexon-sol-tools-1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98.tar.zst dexon-sol-tools-1b5c5e7a3ba17ca72ea700cd2a1884130e13fc98.zip |
Change withdrawERC20 => withdrawAsset, reuse transfer logic
Diffstat (limited to 'packages/contracts/test/forwarder/forwarder.ts')
-rw-r--r-- | packages/contracts/test/forwarder/forwarder.ts | 23 |
1 files changed, 22 insertions, 1 deletions
diff --git a/packages/contracts/test/forwarder/forwarder.ts b/packages/contracts/test/forwarder/forwarder.ts index cd7ae59c2..28ffdeabe 100644 --- a/packages/contracts/test/forwarder/forwarder.ts +++ b/packages/contracts/test/forwarder/forwarder.ts @@ -36,6 +36,7 @@ describe(ContractName.Forwarder, () => { let feeRecipientAddress: string; let otherAddress: string; let defaultMakerAssetAddress: string; + let zrxAssetData: string; let weth: DummyERC20TokenContract; let zrxToken: DummyERC20TokenContract; @@ -90,7 +91,7 @@ describe(ContractName.Forwarder, () => { erc20Wrapper.addDummyTokenContract(weth); const wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address); - const zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); + zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, provider, @@ -970,6 +971,26 @@ describe(ContractName.Forwarder, () => { ); }); }); + describe('withdrawAsset', () => { + it('should allow owner to withdraw ERC20 tokens', async () => { + const zrxWithdrawAmount = erc20Balances[forwarderContract.address][zrxToken.address]; + await forwarderWrapper.withdrawAssetAsync(zrxAssetData, zrxWithdrawAmount, { from: owner }); + const newBalances = await erc20Wrapper.getBalancesAsync(); + expect(newBalances[owner][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[owner][zrxToken.address].plus(zrxWithdrawAmount), + ); + expect(newBalances[forwarderContract.address][zrxToken.address]).to.be.bignumber.equal( + erc20Balances[forwarderContract.address][zrxToken.address].minus(zrxWithdrawAmount), + ); + }); + it('should revert if not called by owner', async () => { + const zrxWithdrawAmount = erc20Balances[forwarderContract.address][zrxToken.address]; + await expectTransactionFailedAsync( + forwarderWrapper.withdrawAssetAsync(zrxAssetData, zrxWithdrawAmount, { from: makerAddress }), + RevertReason.OnlyContractOwner, + ); + }); + }); }); // tslint:disable:max-file-line-count // tslint:enable:no-unnecessary-type-assertion |