diff options
author | Amir Bandeali <abandeali1@gmail.com> | 2018-09-04 11:35:00 +0800 |
---|---|---|
committer | Amir Bandeali <abandeali1@gmail.com> | 2018-09-04 11:35:00 +0800 |
commit | cb4fcf4de7b9decad05536f2edf1c1ffd8666a72 (patch) | |
tree | 9dabe3fdf180fe808ace6a739662944dfff98739 /packages/contracts/test | |
parent | 675964dc5c6c44eb07023fd036857ecd3f14dcf3 (diff) | |
download | dexon-sol-tools-cb4fcf4de7b9decad05536f2edf1c1ffd8666a72.tar dexon-sol-tools-cb4fcf4de7b9decad05536f2edf1c1ffd8666a72.tar.gz dexon-sol-tools-cb4fcf4de7b9decad05536f2edf1c1ffd8666a72.tar.bz2 dexon-sol-tools-cb4fcf4de7b9decad05536f2edf1c1ffd8666a72.tar.lz dexon-sol-tools-cb4fcf4de7b9decad05536f2edf1c1ffd8666a72.tar.xz dexon-sol-tools-cb4fcf4de7b9decad05536f2edf1c1ffd8666a72.tar.zst dexon-sol-tools-cb4fcf4de7b9decad05536f2edf1c1ffd8666a72.zip |
Revert in Forwarder constructor if ERC20 proxy isn't registered
Diffstat (limited to 'packages/contracts/test')
-rw-r--r-- | packages/contracts/test/extensions/forwarder.ts | 33 |
1 files changed, 29 insertions, 4 deletions
diff --git a/packages/contracts/test/extensions/forwarder.ts b/packages/contracts/test/extensions/forwarder.ts index 18101d684..8424d01fd 100644 --- a/packages/contracts/test/extensions/forwarder.ts +++ b/packages/contracts/test/extensions/forwarder.ts @@ -12,7 +12,11 @@ import { ExchangeContract } from '../../generated_contract_wrappers/exchange'; import { ForwarderContract } from '../../generated_contract_wrappers/forwarder'; import { WETH9Contract } from '../../generated_contract_wrappers/weth9'; import { artifacts } from '../utils/artifacts'; -import { expectTransactionFailedAsync } from '../utils/assertions'; +import { + expectContractCreationFailedAsync, + expectTransactionFailedAsync, + sendTransactionResult, +} from '../utils/assertions'; import { chaiSetup } from '../utils/chai_setup'; import { constants } from '../utils/constants'; import { ERC20Wrapper } from '../utils/erc20_wrapper'; @@ -37,6 +41,7 @@ describe(ContractName.Forwarder, () => { let otherAddress: string; let defaultMakerAssetAddress: string; let zrxAssetData: string; + let wethAssetData: string; let weth: DummyERC20TokenContract; let zrxToken: DummyERC20TokenContract; @@ -90,7 +95,7 @@ describe(ContractName.Forwarder, () => { weth = new DummyERC20TokenContract(wethContract.abi, wethContract.address, provider); erc20Wrapper.addDummyTokenContract(weth); - const wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address); + wethAssetData = assetDataUtils.encodeERC20AssetData(wethContract.address); zrxAssetData = assetDataUtils.encodeERC20AssetData(zrxToken.address); const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( artifacts.Exchange, @@ -98,8 +103,7 @@ describe(ContractName.Forwarder, () => { txDefaults, zrxAssetData, ); - const exchangeContract = new ExchangeContract(exchangeInstance.abi, exchangeInstance.address, provider); - exchangeWrapper = new ExchangeWrapper(exchangeContract, provider); + exchangeWrapper = new ExchangeWrapper(exchangeInstance, provider); await exchangeWrapper.registerAssetProxyAsync(erc20Proxy.address, owner); await exchangeWrapper.registerAssetProxyAsync(erc721Proxy.address, owner); @@ -162,6 +166,27 @@ describe(ContractName.Forwarder, () => { await blockchainLifecycle.revertAsync(); }); + describe('constructor', () => { + it('should revert if assetProxy is unregistered', async () => { + const exchangeInstance = await ExchangeContract.deployFrom0xArtifactAsync( + artifacts.Exchange, + provider, + txDefaults, + zrxAssetData, + ); + return expectContractCreationFailedAsync( + (ForwarderContract.deployFrom0xArtifactAsync( + artifacts.Forwarder, + provider, + txDefaults, + exchangeInstance.address, + zrxAssetData, + wethAssetData, + ) as any) as sendTransactionResult, + RevertReason.UnregisteredAssetProxy, + ); + }); + }); describe('marketSellOrdersWithEth without extra fees', () => { it('should fill a single order', async () => { const ordersWithoutFee = [orderWithoutFee]; |