diff --git a/contracts/zero-ex/package.json b/contracts/zero-ex/package.json index ff62c1309b..f66653591e 100644 --- a/contracts/zero-ex/package.json +++ b/contracts/zero-ex/package.json @@ -15,7 +15,6 @@ "build:ts": "tsc -b", "pre_build": "run-s compile contracts:gen generate_contract_wrappers contracts:copy", "test": "yarn run_mocha", - "retest": "yarn run-s run_mocha_fund", "rebuild_and_test": "run-s build test", "test:coverage": "SOLIDITY_COVERAGE=true run-s build run_mocha coverage:report:text coverage:report:lcov", "test:profiler": "SOLIDITY_PROFILER=true run-s build run_mocha profiler:report:html", @@ -45,6 +44,7 @@ "publicInterfaceContracts": "IZeroEx,ZeroEx,FullMigration,InitialMigration,IFlashWallet,IERC20Transformer,IOwnableFeature,ISimpleFunctionRegistryFeature,ITransformERC20Feature,FillQuoteTransformer,PayTakerTransformer,PositiveSlippageFeeTransformer,WethTransformer,OwnableFeature,SimpleFunctionRegistryFeature,TransformERC20Feature,AffiliateFeeTransformer,MetaTransactionsFeature,LogMetadataTransformer,BridgeAdapter,LiquidityProviderFeature,ILiquidityProviderFeature,NativeOrdersFeature,INativeOrdersFeature,FeeCollectorController,FeeCollector,CurveLiquidityProvider,BatchFillNativeOrdersFeature,IBatchFillNativeOrdersFeature,MultiplexFeature,IMultiplexFeature,OtcOrdersFeature,IOtcOrdersFeature", "abis:comment": "This list is auto-generated by contracts-gen. Don't edit manually.", <<<<<<< HEAD +<<<<<<< HEAD <<<<<<< HEAD "abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinClipper|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|MultiplexLiquidityProvider|MultiplexOtc|MultiplexRfq|MultiplexTransformERC20|MultiplexUniswapV2|MultiplexUniswapV3|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV2Factory|TestUniswapV2Pool|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json" ======= @@ -53,6 +53,9 @@ ======= "abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinClipper|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestFundRecoveryFeature|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json" >>>>>>> f299718f7 (added testing for amount -1 transfer and erc-20 token transfer) +======= + "abis": "./test/generated-artifacts/@(AffiliateFeeTransformer|BatchFillNativeOrdersFeature|BootstrapFeature|BridgeAdapter|BridgeProtocols|CurveLiquidityProvider|FeeCollector|FeeCollectorController|FillQuoteTransformer|FixinCommon|FixinEIP712|FixinProtocolFees|FixinReentrancyGuard|FixinTokenSpender|FlashWallet|FullMigration|FundRecoveryFeature|IBatchFillNativeOrdersFeature|IBootstrapFeature|IBridgeAdapter|IERC20Bridge|IERC20Transformer|IFeature|IFlashWallet|IFundRecoveryFeature|ILiquidityProvider|ILiquidityProviderFeature|ILiquidityProviderSandbox|IMetaTransactionsFeature|IMooniswapPool|IMultiplexFeature|INativeOrdersEvents|INativeOrdersFeature|IOtcOrdersFeature|IOwnableFeature|IPancakeSwapFeature|ISimpleFunctionRegistryFeature|IStaking|ITestSimpleFunctionRegistryFeature|ITokenSpenderFeature|ITransformERC20Feature|IUniswapFeature|IUniswapV2Pair|IUniswapV3Feature|IUniswapV3Pool|IZeroEx|InitialMigration|LibBootstrap|LibCommonRichErrors|LibERC20Transformer|LibFeeCollector|LibLiquidityProviderRichErrors|LibMetaTransactionsRichErrors|LibMetaTransactionsStorage|LibMigrate|LibNativeOrder|LibNativeOrdersRichErrors|LibNativeOrdersStorage|LibOtcOrdersStorage|LibOwnableRichErrors|LibOwnableStorage|LibProxyRichErrors|LibProxyStorage|LibReentrancyGuardStorage|LibSignature|LibSignatureRichErrors|LibSimpleFunctionRegistryRichErrors|LibSimpleFunctionRegistryStorage|LibStorage|LibTransformERC20RichErrors|LibTransformERC20Storage|LibWalletRichErrors|LiquidityProviderFeature|LiquidityProviderSandbox|LogMetadataTransformer|MetaTransactionsFeature|MixinBalancer|MixinBalancerV2|MixinBancor|MixinClipper|MixinCoFiX|MixinCryptoCom|MixinCurve|MixinCurveV2|MixinDodo|MixinDodoV2|MixinKyber|MixinKyberDmm|MixinLido|MixinMStable|MixinMakerPSM|MixinMooniswap|MixinNerve|MixinOasis|MixinShell|MixinUniswap|MixinUniswapV2|MixinUniswapV3|MixinZeroExBridge|MooniswapLiquidityProvider|MultiplexFeature|NativeOrdersCancellation|NativeOrdersFeature|NativeOrdersInfo|NativeOrdersProtocolFees|NativeOrdersSettlement|OtcOrdersFeature|OwnableFeature|PancakeSwapFeature|PayTakerTransformer|PermissionlessTransformerDeployer|PositiveSlippageFeeTransformer|SimpleFunctionRegistryFeature|TestBridge|TestCallTarget|TestCurve|TestDelegateCaller|TestFeeCollectorController|TestFillQuoteTransformerBridge|TestFillQuoteTransformerExchange|TestFillQuoteTransformerHost|TestFixinProtocolFees|TestFixinTokenSpender|TestFullMigration|TestInitialMigration|TestLibNativeOrder|TestLibSignature|TestLiquidityProvider|TestMetaTransactionsNativeOrdersFeature|TestMetaTransactionsTransformERC20Feature|TestMigrator|TestMintTokenERC20Transformer|TestMintableERC20Token|TestMooniswap|TestNativeOrdersFeature|TestNoEthRecipient|TestOrderSignerRegistryWithContractWallet|TestPermissionlessTransformerDeployerSuicidal|TestPermissionlessTransformerDeployerTransformer|TestRfqOriginRegistration|TestSimpleFunctionRegistryFeatureImpl1|TestSimpleFunctionRegistryFeatureImpl2|TestStaking|TestTokenSpenderERC20Token|TestTransformERC20|TestTransformerBase|TestTransformerDeployerTransformer|TestTransformerHost|TestUniswapV3Factory|TestUniswapV3Feature|TestUniswapV3Pool|TestWeth|TestWethTransformerHost|TestZeroExFeature|TransformERC20Feature|Transformer|TransformerDeployer|UniswapFeature|UniswapV3Feature|WethTransformer|ZeroEx|ZeroExOptimized).json" +>>>>>>> d079e8396 (fixed formatting and removed unecessary variables and function calls. Also added test that transfers ETH using -1 syntax) }, "repository": { "type": "git", diff --git a/contracts/zero-ex/test/artifacts.ts b/contracts/zero-ex/test/artifacts.ts index 8f1f935716..5e28180e9c 100644 --- a/contracts/zero-ex/test/artifacts.ts +++ b/contracts/zero-ex/test/artifacts.ts @@ -135,7 +135,6 @@ import * as TestFillQuoteTransformerHost from '../test/generated-artifacts/TestF import * as TestFixinProtocolFees from '../test/generated-artifacts/TestFixinProtocolFees.json'; import * as TestFixinTokenSpender from '../test/generated-artifacts/TestFixinTokenSpender.json'; import * as TestFullMigration from '../test/generated-artifacts/TestFullMigration.json'; -import * as TestFundRecoveryFeature from '../test/generated-artifacts/TestFundRecoveryFeature.json'; import * as TestInitialMigration from '../test/generated-artifacts/TestInitialMigration.json'; import * as TestLibNativeOrder from '../test/generated-artifacts/TestLibNativeOrder.json'; import * as TestLibSignature from '../test/generated-artifacts/TestLibSignature.json'; @@ -315,7 +314,6 @@ export const artifacts = { TestFixinProtocolFees: TestFixinProtocolFees as ContractArtifact, TestFixinTokenSpender: TestFixinTokenSpender as ContractArtifact, TestFullMigration: TestFullMigration as ContractArtifact, - TestFundRecoveryFeature: TestFundRecoveryFeature as ContractArtifact, TestInitialMigration: TestInitialMigration as ContractArtifact, TestLibNativeOrder: TestLibNativeOrder as ContractArtifact, TestLibSignature: TestLibSignature as ContractArtifact, diff --git a/contracts/zero-ex/test/features/fund_recovery_tests.ts b/contracts/zero-ex/test/features/fund_recovery_tests.ts index 78db39bae1..77cebf5721 100644 --- a/contracts/zero-ex/test/features/fund_recovery_tests.ts +++ b/contracts/zero-ex/test/features/fund_recovery_tests.ts @@ -1,3 +1,4 @@ +import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20'; import { blockchainTests, constants, @@ -5,99 +6,88 @@ import { randomAddress, } from '@0x/contracts-test-utils'; import { BigNumber, OwnableRevertErrors } from '@0x/utils'; -import { artifacts as erc20Artifacts, DummyERC20TokenContract } from '@0x/contracts-erc20'; -import { IOwnableFeatureContract, IZeroExContract } from '../../src/wrappers'; -import {TestWethContract} from '../wrappers'; +import { Web3Wrapper } from '@0x/web3-wrapper'; import { artifacts } from '../artifacts'; +import { FundRecoveryFeatureContract } from '../generated-wrappers/fund_recovery_feature'; import { abis } from '../utils/abis'; import { fullMigrateAsync } from '../utils/migration'; -import { FundRecoveryFeatureContract } from '../generated-wrappers/fund_recovery_feature'; -import { Web3Wrapper } from '@0x/web3-wrapper'; -import { OnlyOwnerError } from '@0x/utils/lib/src/revert_errors/utils/ownable_revert_errors'; +import { IOwnableFeatureContract, IZeroExContract } from '../../src/wrappers'; - blockchainTests.only('FundRecovery', async env => { - - let owner: string; - let designatedAddress: string; - let testAddress: string; - let zeroEx: IZeroExContract; - let token: DummyERC20TokenContract; - let weth: TestWethContract; - let feature: FundRecoveryFeatureContract; - - before(async () => { - - [owner, designatedAddress, testAddress] = await env.getAccountAddressesAsync(); - zeroEx = await fullMigrateAsync(owner, env.provider, env.txDefaults, {}); - token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( - erc20Artifacts.DummyERC20Token, - env.provider, - env.txDefaults, - erc20Artifacts, - constants.DUMMY_TOKEN_NAME, - constants.DUMMY_TOKEN_SYMBOL, - constants.DUMMY_TOKEN_DECIMALS, - constants.DUMMY_TOKEN_TOTAL_SUPPLY, - ); - await token.setBalance(zeroEx.address, constants.INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync(); - const bal = await token.balanceOf(zeroEx.address).callAsync(); - weth = await TestWethContract.deployFrom0xArtifactAsync( - artifacts.TestWeth, - env.provider, - env.txDefaults, - artifacts, - ); - await weth.mint(zeroEx.address, constants.INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync(); - const balweth = await weth.balanceOf(zeroEx.address).callAsync(); - feature = new FundRecoveryFeatureContract(zeroEx.address, env.provider, env.txDefaults, abis); - const featureImpl = await FundRecoveryFeatureContract.deployFrom0xArtifactAsync( - artifacts.FundRecoveryFeature, - env.provider, - env.txDefaults, - artifacts - ); - await new IOwnableFeatureContract(zeroEx.address, env.provider, env.txDefaults, abis) - .migrate(featureImpl.address, featureImpl.migrate().getABIEncodedTransactionData(), owner) - .awaitTransactionSuccessAsync(); +blockchainTests('FundRecovery', async env => { + let owner: string; + let zeroEx: IZeroExContract; + let token: DummyERC20TokenContract; + before(async () => { + const INITIAL_ERC20_BALANCE = Web3Wrapper.toBaseUnitAmount(new BigNumber(10000), 18); + [owner] = await env.getAccountAddressesAsync(); + zeroEx = await fullMigrateAsync(owner, env.provider, env.txDefaults, {}); + token = await DummyERC20TokenContract.deployFrom0xArtifactAsync( + erc20Artifacts.DummyERC20Token, + env.provider, + env.txDefaults, + erc20Artifacts, + constants.DUMMY_TOKEN_NAME, + constants.DUMMY_TOKEN_SYMBOL, + constants.DUMMY_TOKEN_DECIMALS, + constants.DUMMY_TOKEN_TOTAL_SUPPLY, + ); + await token.setBalance(zeroEx.address, INITIAL_ERC20_BALANCE).awaitTransactionSuccessAsync(); + const featureImpl = await FundRecoveryFeatureContract.deployFrom0xArtifactAsync( + artifacts.FundRecoveryFeature, + env.provider, + env.txDefaults, + artifacts, + ); + await new IOwnableFeatureContract(zeroEx.address, env.provider, env.txDefaults, abis) + .migrate(featureImpl.address, featureImpl.migrate().getABIEncodedTransactionData(), owner) + .awaitTransactionSuccessAsync({from: owner}); + }); + blockchainTests.resets('Should delegatecall `transferTrappedTokensTo` from the exchange proxy', () => { + const ETH_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'; + const recipientAddress = randomAddress(); + it('Tranfers an arbitrary ERC-20 Token', async () => { + const amountOut = Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18); + await zeroEx.transferTrappedTokensTo(token.address, amountOut, recipientAddress).awaitTransactionSuccessAsync({ from: owner }); + const recipientAddressBalanceAferTransfer = await token.balanceOf(recipientAddress).callAsync(); + return expect(recipientAddressBalanceAferTransfer).to.bignumber.equal(amountOut); }); - blockchainTests.resets('Should delegatecall `transferTrappedTokensTo` from the exchange proxy', () => { - const ETH_TOKEN_ADDRESS = '0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE'; - it('Tranfers an arbitrary ERC-20 Token', async () => { - const amountOut = Web3Wrapper.toBaseUnitAmount(new BigNumber(100), 18); - const designatedAddressBalance = await token.balanceOf(designatedAddress).callAsync(); - const epBalance = await token.balanceOf(zeroEx.address).callAsync(); - await zeroEx.transferTrappedTokensTo(token.address, amountOut, designatedAddress).awaitTransactionSuccessAsync({ from: owner }); - const epBalanceNew = await token.balanceOf(zeroEx.address).callAsync(); - const designatedAddressBalanceAferTransfer = await token.balanceOf(designatedAddress).callAsync(); - expect(designatedAddressBalanceAferTransfer).to.bignumber.equal(amountOut); - }); - it('Amount -1 transfers entire balance', async () => { - const designatedAddressBalance = await token.balanceOf(designatedAddress).callAsync(); - const balanceOwner = await token.balanceOf(zeroEx.address).callAsync(); - const tx = await zeroEx.transferTrappedTokensTo(token.address, constants.MAX_UINT256 , designatedAddress).awaitTransactionSuccessAsync({ from: owner }); - const balanceNew = await token.balanceOf(zeroEx.address).callAsync(); - const designatedAddressBalanceAferTransfer = await token.balanceOf(designatedAddress).callAsync(); - expect(balanceNew).to.bignumber.equal(0); - expect(designatedAddressBalanceAferTransfer).to.bignumber.equal(balanceOwner); - }); - it('Transfers ETH ', async () => { - const amountOut = new BigNumber(20); - await env.web3Wrapper.awaitTransactionMinedAsync( - await env.web3Wrapper.sendTransactionAsync( - { - from: owner, - to: zeroEx.address, - value: amountOut - })); - const bal = await env.web3Wrapper.getBalanceInWeiAsync(designatedAddress); - const tx = await zeroEx.transferTrappedTokensTo(ETH_TOKEN_ADDRESS, amountOut , designatedAddress).awaitTransactionSuccessAsync({ from: owner }); - const designatedAddressBalance = await env.web3Wrapper.getBalanceInWeiAsync(designatedAddress); - return expect(designatedAddressBalance).to.bignumber.be.greaterThan(bal); - }); - it('Feature `transferTrappedTokensTo` can only be called by owner', async () => { - const notOwner = randomAddress(); - - return expect(zeroEx.transferTrappedTokensTo(ETH_TOKEN_ADDRESS, constants.MAX_UINT256 , designatedAddress).awaitTransactionSuccessAsync({ from: notOwner })).to.revertWith(new OnlyOwnerError(notOwner,owner)); - }); + it('Amount -1 transfers entire balance of ERC-20', async () => { + const balanceOwner = await token.balanceOf(zeroEx.address).callAsync(); + await zeroEx.transferTrappedTokensTo(token.address, constants.MAX_UINT256 , recipientAddress).awaitTransactionSuccessAsync({ from: owner }); + const recipientAddressBalanceAferTransfer = await token.balanceOf(recipientAddress).callAsync(); + return expect(recipientAddressBalanceAferTransfer).to.bignumber.equal(balanceOwner); + }); + it('Amount -1 transfers entire balance of ETH', async () => { + const amountOut = new BigNumber(20); + await env.web3Wrapper.awaitTransactionMinedAsync( + await env.web3Wrapper.sendTransactionAsync( + { + from: owner, + to: zeroEx.address, + value: amountOut, + })); + const balanceOwner = await env.web3Wrapper.getBalanceInWeiAsync(zeroEx.address); + await zeroEx.transferTrappedTokensTo(ETH_TOKEN_ADDRESS, constants.MAX_UINT256 , recipientAddress).awaitTransactionSuccessAsync({ from: owner }); + const recipientAddressBalanceAferTransfer = await env.web3Wrapper.getBalanceInWeiAsync(recipientAddress); + return expect(recipientAddressBalanceAferTransfer).to.bignumber.equal(balanceOwner); + }); + it('Transfers ETH ', async () => { + const amountOut = new BigNumber(20); + await env.web3Wrapper.awaitTransactionMinedAsync( + await env.web3Wrapper.sendTransactionAsync( + { + from: owner, + to: zeroEx.address, + value: amountOut, + })); + const bal = await env.web3Wrapper.getBalanceInWeiAsync(recipientAddress); + await zeroEx.transferTrappedTokensTo(ETH_TOKEN_ADDRESS, amountOut , recipientAddress).awaitTransactionSuccessAsync({ from: owner }); + const recipientAddressBalance = await env.web3Wrapper.getBalanceInWeiAsync(recipientAddress); + return expect(recipientAddressBalance).to.bignumber.be.equal(bal.plus(amountOut)); + }); + it('Feature `transferTrappedTokensTo` can only be called by owner', async () => { + const notOwner = randomAddress(); + return expect(zeroEx.transferTrappedTokensTo(ETH_TOKEN_ADDRESS, constants.MAX_UINT256 , recipientAddress).awaitTransactionSuccessAsync({ from: notOwner })).to.revertWith(new OwnableRevertErrors.OnlyOwnerError(notOwner, owner)); }); }); +}); diff --git a/contracts/zero-ex/test/wrappers.ts b/contracts/zero-ex/test/wrappers.ts index 865b38971b..1a7c95b6d3 100644 --- a/contracts/zero-ex/test/wrappers.ts +++ b/contracts/zero-ex/test/wrappers.ts @@ -133,7 +133,6 @@ export * from '../test/generated-wrappers/test_fill_quote_transformer_host'; export * from '../test/generated-wrappers/test_fixin_protocol_fees'; export * from '../test/generated-wrappers/test_fixin_token_spender'; export * from '../test/generated-wrappers/test_full_migration'; -export * from '../test/generated-wrappers/test_fund_recovery_feature'; export * from '../test/generated-wrappers/test_initial_migration'; export * from '../test/generated-wrappers/test_lib_native_order'; export * from '../test/generated-wrappers/test_lib_signature'; diff --git a/contracts/zero-ex/tsconfig.json b/contracts/zero-ex/tsconfig.json index 299010124f..0ceda48b4a 100644 --- a/contracts/zero-ex/tsconfig.json +++ b/contracts/zero-ex/tsconfig.json @@ -166,7 +166,6 @@ "test/generated-artifacts/TestFixinProtocolFees.json", "test/generated-artifacts/TestFixinTokenSpender.json", "test/generated-artifacts/TestFullMigration.json", - "test/generated-artifacts/TestFundRecoveryFeature.json", "test/generated-artifacts/TestInitialMigration.json", "test/generated-artifacts/TestLibNativeOrder.json", "test/generated-artifacts/TestLibSignature.json",