Add mainnet config tests

This commit is contained in:
Amir Bandeali
2019-12-05 13:08:02 -08:00
parent c0c6154ec1
commit 0e59bd0bf3
4 changed files with 226 additions and 8 deletions

View File

@@ -52,6 +52,7 @@
"devDependencies": {
"@0x/abi-gen": "^5.0.1",
"@0x/contract-addresses": "^4.0.0",
"@0x/contract-wrappers": "^13.1.0",
"@0x/contracts-coordinator": "^3.0.1",
"@0x/contracts-dev-utils": "^1.0.1",
"@0x/contracts-exchange-forwarder": "^4.0.1",

View File

@@ -0,0 +1,200 @@
import { ERC20ProxyContract, MultiAssetProxyContract } from '@0x/contracts-asset-proxy';
import { StakingProxyContract, ZrxVaultContract } from '@0x/contracts-staking';
import { blockchainTests, describe, expect } from '@0x/contracts-test-utils';
import { AssetProxyId } from '@0x/types';
import { BigNumber } from '@0x/utils';
import { contractAddresses, contractWrappers } from './mainnet_fork_utils';
blockchainTests.resets.fork('Mainnet configs tests', env => {
describe('Exchange', () => {
it('should be owned by the ZeroExGovernor ', async () => {
const owner = await contractWrappers.exchange.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('ERC20Proxy should be registered', async () => {
const erc20Proxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.ERC20).callAsync();
expect(erc20Proxy).to.eq(contractAddresses.erc20Proxy);
});
it('ERC721Proxy should be registered', async () => {
const erc721Proxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.ERC721).callAsync();
expect(erc721Proxy).to.eq(contractAddresses.erc721Proxy);
});
it('ERC1155Proxy should be registered', async () => {
const erc1155Proxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.ERC1155).callAsync();
expect(erc1155Proxy).to.eq(contractAddresses.erc1155Proxy);
});
it('ERC20BridgeProxy should be registered', async () => {
const erc20BridgeProxy = await contractWrappers.exchange
.getAssetProxy(AssetProxyId.ERC20Bridge)
.callAsync();
expect(erc20BridgeProxy).to.eq(contractAddresses.erc20BridgeProxy);
});
it('MultiAssetProxy should be registered', async () => {
const multiAssetProxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.MultiAsset).callAsync();
expect(multiAssetProxy).to.eq(contractAddresses.multiAssetProxy);
});
it('StaticCallProxy should be registered', async () => {
const staticCallProxy = await contractWrappers.exchange.getAssetProxy(AssetProxyId.StaticCall).callAsync();
expect(staticCallProxy).to.eq(contractAddresses.staticCallProxy);
});
it('StakingProxy should be attached', async () => {
const stakingProxy = await contractWrappers.exchange.protocolFeeCollector().callAsync();
expect(stakingProxy).to.eq(contractAddresses.stakingProxy);
});
it('should have the correct protocol fee multiplier', async () => {
const protocolFeeMultiplier = await contractWrappers.exchange.protocolFeeMultiplier().callAsync();
expect(protocolFeeMultiplier).to.bignumber.eq(150000);
});
});
describe('ERC20Proxy', () => {
const erc20Proxy = new ERC20ProxyContract(contractAddresses.erc20Proxy, env.provider);
it('should be owned by the ZeroExGovernor ', async () => {
const owner = await erc20Proxy.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('should have the correct authorized addresses', async () => {
const authorizedAddresses = await erc20Proxy.getAuthorizedAddresses().callAsync();
expect(authorizedAddresses.length).to.eq(4);
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
expect(authorizedAddresses.includes(contractAddresses.zrxVault), 'ZrxVault');
});
});
describe('ERC721Proxy', () => {
const erc721Proxy = new ERC20ProxyContract(contractAddresses.erc721Proxy, env.provider);
it('should be owned by the ZeroExGovernor ', async () => {
const owner = await erc721Proxy.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('should have the correct authorized addresses', async () => {
const authorizedAddresses = await erc721Proxy.getAuthorizedAddresses().callAsync();
expect(authorizedAddresses.length).to.eq(3);
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
});
});
describe('ERC1155Proxy', () => {
const erc1155Proxy = new ERC20ProxyContract(contractAddresses.erc1155Proxy, env.provider);
it('should be owned by the ZeroExGovernor ', async () => {
const owner = await erc1155Proxy.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('should have the correct authorized addresses', async () => {
const authorizedAddresses = await erc1155Proxy.getAuthorizedAddresses().callAsync();
expect(authorizedAddresses.length).to.eq(3);
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
});
});
describe('ERC20BridgeProxy', () => {
const erc20BridgeProxy = new ERC20ProxyContract(contractAddresses.erc20BridgeProxy, env.provider);
it('should be owned by the ZeroExGovernor ', async () => {
const owner = await erc20BridgeProxy.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('should have the correct authorized addresses', async () => {
const authorizedAddresses = await erc20BridgeProxy.getAuthorizedAddresses().callAsync();
expect(authorizedAddresses.length).to.eq(2);
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
expect(authorizedAddresses.includes(contractAddresses.multiAssetProxy), 'MultiAssetProxy');
});
});
describe('MultiAssetProxy', () => {
const multiAssetProxy = new MultiAssetProxyContract(contractAddresses.multiAssetProxy, env.provider);
it('should be owned by the ZeroExGovernor ', async () => {
const owner = await multiAssetProxy.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('should have the correct authorized addresses', async () => {
const authorizedAddresses = await multiAssetProxy.getAuthorizedAddresses().callAsync();
expect(authorizedAddresses.length).to.eq(2);
expect(authorizedAddresses.includes(contractAddresses.exchangeV2), 'ExchangeV2');
expect(authorizedAddresses.includes(contractAddresses.exchange), 'Exchange');
});
it('ERC20Proxy should be registered', async () => {
const erc20Proxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC20).callAsync();
expect(erc20Proxy).to.eq(contractAddresses.erc20Proxy);
});
it('ERC721Proxy should be registered', async () => {
const erc721Proxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC721).callAsync();
expect(erc721Proxy).to.eq(contractAddresses.erc721Proxy);
});
it('ERC1155Proxy should be registered', async () => {
const erc1155Proxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC1155).callAsync();
expect(erc1155Proxy).to.eq(contractAddresses.erc1155Proxy);
});
it('ERC20BridgeProxy should be registered', async () => {
const erc20BridgeProxy = await multiAssetProxy.getAssetProxy(AssetProxyId.ERC20Bridge).callAsync();
expect(erc20BridgeProxy).to.eq(contractAddresses.erc20BridgeProxy);
});
it('StaticCallProxy should be registered', async () => {
const staticCallProxy = await multiAssetProxy.getAssetProxy(AssetProxyId.StaticCall).callAsync();
expect(staticCallProxy).to.eq(contractAddresses.staticCallProxy);
});
});
describe('StakingProxy', () => {
const stakingProxy = new StakingProxyContract(contractAddresses.stakingProxy, env.provider);
it('should be owned by ZeroExGovernor', async () => {
const owner = await stakingProxy.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('Staking contract should be attached', async () => {
const staking = await stakingProxy.stakingContract().callAsync();
expect(staking).to.eq(contractAddresses.staking);
});
it('Exchange should be registered', async () => {
const isRegistered = await contractWrappers.staking.validExchanges(contractAddresses.exchange).callAsync();
expect(isRegistered).to.be.true();
});
it('ZrxVault should be set', async () => {
const zrxVault = await contractWrappers.staking.getZrxVault().callAsync();
expect(zrxVault).to.eq(contractAddresses.zrxVault);
});
it('WETH should be set', async () => {
const weth = await contractWrappers.staking.getWethContract().callAsync();
expect(weth).to.eq(contractAddresses.etherToken);
});
it('should have the correct authorized addresses', async () => {
const authorizedAddresses = await stakingProxy.getAuthorizedAddresses().callAsync();
expect(authorizedAddresses.length).to.eq(1);
expect(authorizedAddresses.includes(contractAddresses.zeroExGovernor), 'ZeroExGovernor');
});
it('should have the correct params set', async () => {
const params = await contractWrappers.staking.getParams().callAsync();
const epochDurationInSeconds = 10 * 24 * 60 * 60;
const rewardDelegatedStakeWeight = 10 ** 6 * 0.9;
const mimimumPoolStake = new BigNumber(10).pow(18).times(100);
const cobbDouglasAlphaNumerator = 2;
const cobbDouglasAlphaDenominator = 3;
expect(params[0]).to.bignumber.eq(epochDurationInSeconds, 'epochDurationInSeconds');
expect(params[1]).to.bignumber.eq(rewardDelegatedStakeWeight, 'rewardDelegatedStakeWeight');
expect(params[2]).to.bignumber.eq(mimimumPoolStake, 'mimimumPoolStake');
expect(params[3]).to.bignumber.eq(cobbDouglasAlphaNumerator, 'cobbDouglasAlphaNumerator');
expect(params[4]).to.bignumber.eq(cobbDouglasAlphaDenominator, 'cobbDouglasAlphaDenominator');
});
});
describe('ZrxVault', () => {
const zrxVault = new ZrxVaultContract(contractAddresses.zrxVault, env.provider);
it('should be owned by ZeroExGovernor', async () => {
const owner = await zrxVault.owner().callAsync();
expect(owner).to.eq(contractAddresses.zeroExGovernor);
});
it('should have the correct authorized addresses', async () => {
const authorizedAddresses = await zrxVault.getAuthorizedAddresses().callAsync();
expect(authorizedAddresses.length).to.eq(1);
expect(authorizedAddresses.includes(contractAddresses.zeroExGovernor), 'ZeroExGovernor');
});
it('ERC20Proxy should be set', async () => {
const erc20Proxy = await zrxVault.zrxAssetProxy().callAsync();
expect(erc20Proxy).to.eq(contractAddresses.erc20Proxy);
});
it('StakingProxy should be set', async () => {
const stakingProxy = await zrxVault.stakingProxyAddress().callAsync();
expect(stakingProxy).to.eq(contractAddresses.stakingProxy);
});
});
});

View File

@@ -0,0 +1,9 @@
import { getContractAddressesForChainOrThrow } from '@0x/contract-addresses';
import { ContractWrappers } from '@0x/contract-wrappers';
import { provider } from '@0x/contracts-test-utils';
const chainId = 1;
const contractAddresses = getContractAddressesForChainOrThrow(chainId);
const contractWrappers = new ContractWrappers(provider, { chainId, contractAddresses });
export { contractAddresses, contractWrappers };

View File

@@ -669,7 +669,8 @@
"@0x/assert@^2.2.0-beta.2", "@0x/assert@^2.2.0-beta.3":
version "2.2.0-beta.3"
resolved "https://registry.yarnpkg.com/@0x/assert/-/assert-2.2.0-beta.3.tgz#8fb95c265000532cd8dced44d44d29ca544b2bfc"
resolved "https://registry.npmjs.org/@0x/assert/-/assert-2.2.0-beta.3.tgz#8fb95c265000532cd8dced44d44d29ca544b2bfc"
integrity sha512-ShENc8QJU4ur/5TkRl3l7J3Yt7WaxHAbuoTRm/djcA0iwYyUVlP5yN9Ab9ua+VLizQQTNw1n+kF1mJWg5lQXuA==
dependencies:
"@0x/json-schemas" "^4.1.0-beta.3"
"@0x/typescript-typings" "^4.4.0-beta.2"
@@ -723,7 +724,8 @@
"@0x/contract-wrappers@^12.2.0-beta.4":
version "12.2.0-beta.4"
resolved "https://registry.yarnpkg.com/@0x/contract-wrappers/-/contract-wrappers-12.2.0-beta.4.tgz#7a7301dd50c28887879df4d385e80a49e040748d"
resolved "https://registry.npmjs.org/@0x/contract-wrappers/-/contract-wrappers-12.2.0-beta.4.tgz#7a7301dd50c28887879df4d385e80a49e040748d"
integrity sha512-JVoYG3Rd430fZw9ogBSqeLOaJXkqp9N7g614X5/bzzuG/dSDdwXl48X02m66aGFWcNofx/iMsT4tpOZrJ2bDBg==
dependencies:
"@0x/assert" "^2.2.0-beta.3"
"@0x/base-contract" "^5.5.0-beta.4"
@@ -790,7 +792,8 @@
"@0x/json-schemas@^4.1.0-beta.2", "@0x/json-schemas@^4.1.0-beta.3":
version "4.1.0-beta.3"
resolved "https://registry.yarnpkg.com/@0x/json-schemas/-/json-schemas-4.1.0-beta.3.tgz#af70a35691108ea162140640bae93a7fc84ca6ee"
resolved "https://registry.npmjs.org/@0x/json-schemas/-/json-schemas-4.1.0-beta.3.tgz#af70a35691108ea162140640bae93a7fc84ca6ee"
integrity sha512-vcgzSeaOXiUQ4KjqdLTTBHbkWnp4IE7cXbUblRy8Y0XYPQsPywhs9mtjY4lBVNmm1DDpLhreo1mwrvPS3HW5YA==
dependencies:
"@0x/typescript-typings" "^4.4.0-beta.2"
"@types/node" "*"
@@ -903,7 +906,8 @@
"@0x/types@^2.5.0-beta.2", "@0x/types@^2.5.0-beta.3":
version "2.5.0-beta.3"
resolved "https://registry.yarnpkg.com/@0x/types/-/types-2.5.0-beta.3.tgz#e010e9dbf62e37e59177c1d6df8d1acf3a9ea1b4"
resolved "https://registry.npmjs.org/@0x/types/-/types-2.5.0-beta.3.tgz#e010e9dbf62e37e59177c1d6df8d1acf3a9ea1b4"
integrity sha512-5wJs4/EZGPcU6W5IZ87zuya9vQUPD4DchyP29bXyguGHg9dOxuUOF4WauJZExWlPCS7eivviiUHpZD9DZhni+w==
dependencies:
"@types/node" "*"
bignumber.js "~9.0.0"
@@ -911,7 +915,8 @@
"@0x/typescript-typings@4.4.0-beta.2", "@0x/typescript-typings@^4.4.0-beta.2":
version "4.4.0-beta.2"
resolved "https://registry.yarnpkg.com/@0x/typescript-typings/-/typescript-typings-4.4.0-beta.2.tgz#67c621252f162914186b8f684ac5e306206c1cf2"
resolved "https://registry.npmjs.org/@0x/typescript-typings/-/typescript-typings-4.4.0-beta.2.tgz#67c621252f162914186b8f684ac5e306206c1cf2"
integrity sha512-Fq2nOKvopdLMEjuPiKqomGog06bxAXGjqnodCwv9OKr11V5W1twFTUM3c1TENfHeGvcqf1aMl1hsH3fuVP61jg==
dependencies:
"@types/bn.js" "^4.11.0"
"@types/react" "*"
@@ -967,7 +972,8 @@
"@0x/utils@^4.6.0-beta.2", "@0x/utils@^4.6.0-beta.3":
version "4.6.0-beta.3"
resolved "https://registry.yarnpkg.com/@0x/utils/-/utils-4.6.0-beta.3.tgz#d40278916d98c48ea05821ae4987c88f032c7bff"
resolved "https://registry.npmjs.org/@0x/utils/-/utils-4.6.0-beta.3.tgz#d40278916d98c48ea05821ae4987c88f032c7bff"
integrity sha512-aPIUgfhaDhwgddJAlIQJ2Ki87A60ovatBLCjareLUbsQSvFS5i3iujUBQHgFxZAv9tgl35fyg2ISEJ1YkQyubA==
dependencies:
"@0x/types" "^2.5.0-beta.3"
"@0x/typescript-typings" "^4.4.0-beta.2"
@@ -1014,7 +1020,8 @@
"@0x/web3-wrapper@^6.1.0-beta.2", "@0x/web3-wrapper@^6.1.0-beta.3":
version "6.1.0-beta.3"
resolved "https://registry.yarnpkg.com/@0x/web3-wrapper/-/web3-wrapper-6.1.0-beta.3.tgz#82161147e9283391e0c7cd6027c971749c5a2f77"
resolved "https://registry.npmjs.org/@0x/web3-wrapper/-/web3-wrapper-6.1.0-beta.3.tgz#82161147e9283391e0c7cd6027c971749c5a2f77"
integrity sha512-mc8120n8w88gICbDm8pkmC83Ul3RgE4BGsjY5BRBFefmKbv/XLeBZiWdhsaWYmkk8v4f+ZxAQ+HHTBDsRH87Og==
dependencies:
"@0x/assert" "^2.2.0-beta.3"
"@0x/json-schemas" "^4.1.0-beta.3"
@@ -6749,7 +6756,8 @@ ethereum-types@^2.1.6:
ethereum-types@^2.2.0-beta.2:
version "2.2.0-beta.2"
resolved "https://registry.yarnpkg.com/ethereum-types/-/ethereum-types-2.2.0-beta.2.tgz#0b446842474c2afacd351258ed4a2d0841f2608f"
resolved "https://registry.npmjs.org/ethereum-types/-/ethereum-types-2.2.0-beta.2.tgz#0b446842474c2afacd351258ed4a2d0841f2608f"
integrity sha512-5ANYHI/InHqf4Nt8oYrpvcph9/D6gi3sbM7Rlr8r0QjXb2mqocqEvOH460Zkf1robc7WDqurp9baeMy+um8kww==
dependencies:
"@types/node" "*"
bignumber.js "~9.0.0"