@0x:contracts-integrations Fixed package after rebase

This commit is contained in:
Alex Towle 2019-10-22 13:15:01 -07:00
parent f5a6b84fa3
commit 3a1fc9ee5f
4 changed files with 7 additions and 186 deletions

View File

@ -2,7 +2,7 @@ import { DummyERC20TokenContract, WETH9Contract } from '@0x/contracts-erc20';
import { constants } from '@0x/contracts-test-utils'; import { constants } from '@0x/contracts-test-utils';
import { BigNumber } from '@0x/utils'; import { BigNumber } from '@0x/utils';
import { DeploymentManager } from '../deployment/deployment_mananger'; import { DeploymentManager } from '../utils/deployment_manager';
export type Constructor<T = {}> = new (...args: any[]) => T; export type Constructor<T = {}> = new (...args: any[]) => T;

View File

@ -2,11 +2,7 @@ import { Authorizable, Ownable } from '@0x/contracts-exchange';
import { constants as stakingConstants } from '@0x/contracts-staking'; import { constants as stakingConstants } from '@0x/contracts-staking';
import { blockchainTests, expect } from '@0x/contracts-test-utils'; import { blockchainTests, expect } from '@0x/contracts-test-utils';
<<<<<<< HEAD:contracts/integrations/test/utils/deployment_manager_test.ts
import { DeploymentManager } from './deployment_mananger';
=======
import { DeploymentManager } from '../utils/deployment_manager'; import { DeploymentManager } from '../utils/deployment_manager';
>>>>>>> `@0x:contracts-integrations` Added unit tests for FunctionAssertion:contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts
blockchainTests('Deployment Manager', env => { blockchainTests('Deployment Manager', env => {
let owner: string; let owner: string;

View File

@ -1,181 +0,0 @@
import { Authorizable, Ownable } from '@0x/contracts-exchange';
import { constants as stakingConstants } from '@0x/contracts-staking';
import { blockchainTests, expect } from '@0x/contracts-test-utils';
<<<<<<< HEAD:contracts/integrations/test/utils/deployment_manager_test.ts
import { DeploymentManager } from './deployment_mananger';
=======
import { DeploymentManager } from '../utils/deployment_manager';
>>>>>>> `@0x:contracts-integrations` Added unit tests for FunctionAssertion:contracts/integrations/test/framework-unit-tests/deployment_manager_test.ts
blockchainTests('Deployment Manager', env => {
let owner: string;
let deploymentManager: DeploymentManager;
before(async () => {
[owner] = await env.getAccountAddressesAsync();
deploymentManager = await DeploymentManager.deployAsync(env);
});
async function batchAssertAuthoritiesAsync(
authorities: string[],
authorizedContracts: Authorizable[],
): Promise<void> {
for (const authorized of authorizedContracts) {
expect(await authorized.getAuthorizedAddresses.callAsync()).to.be.deep.eq(authorities);
}
}
async function batchAssertAuthorizedAsync(
authorizedAddress: string,
authorizedContracts: Authorizable[],
): Promise<void> {
for (const authorized of authorizedContracts) {
expect(await authorized.authorized.callAsync(authorizedAddress)).to.be.true();
}
}
async function batchAssertOwnerAsync(ownerAddress: string, owners: Ownable[]): Promise<void> {
for (const ownerContract of owners) {
expect(await ownerContract.owner.callAsync()).to.be.eq(ownerAddress);
}
}
describe('asset proxy owner', () => {
it('should be owned by `owner`', async () => {
// Ensure that the owners of the asset proxy only contain the owner.
const owners = await deploymentManager.governor.getOwners.callAsync();
expect(owners).to.be.deep.eq([owner]);
});
});
describe('asset proxies', () => {
it('should be owned be the asset proxy owner', async () => {
await batchAssertOwnerAsync(deploymentManager.governor.address, [
deploymentManager.assetProxies.erc1155Proxy,
deploymentManager.assetProxies.erc20Proxy,
deploymentManager.assetProxies.erc721Proxy,
deploymentManager.assetProxies.multiAssetProxy,
]);
});
it('should have authorized the multi-asset proxy', async () => {
await batchAssertAuthorizedAsync(deploymentManager.assetProxies.multiAssetProxy.address, [
deploymentManager.assetProxies.erc1155Proxy,
deploymentManager.assetProxies.erc20Proxy,
deploymentManager.assetProxies.erc721Proxy,
]);
});
it('should have authorized the exchange', async () => {
await batchAssertAuthorizedAsync(deploymentManager.exchange.address, [
deploymentManager.assetProxies.erc1155Proxy,
deploymentManager.assetProxies.erc20Proxy,
deploymentManager.assetProxies.erc721Proxy,
deploymentManager.assetProxies.multiAssetProxy,
]);
});
it('should have the correct authorities list', async () => {
// The multi-asset proxy should only have the exchange in the authorities list.
const authorities = await deploymentManager.assetProxies.multiAssetProxy.getAuthorizedAddresses.callAsync();
expect(authorities).to.be.deep.eq([deploymentManager.exchange.address]);
// The other asset proxies should have the exchange and the multi-asset proxy in their
// authorities list.
await batchAssertAuthoritiesAsync(
[deploymentManager.assetProxies.multiAssetProxy.address, deploymentManager.exchange.address],
[
deploymentManager.assetProxies.erc1155Proxy,
deploymentManager.assetProxies.erc20Proxy,
deploymentManager.assetProxies.erc721Proxy,
],
);
});
});
describe('exchange', () => {
it('should be owned by the asset proxy owner', async () => {
const exchangeOwner = await deploymentManager.exchange.owner.callAsync();
expect(exchangeOwner).to.be.eq(deploymentManager.governor.address);
});
/*
TODO(jalextowle): This test should be enabled once the Exchange is
made an Authorizable contract.
it('should have authorized the asset proxy owner', async () => {
const isAuthorized = await deploymentManager.exchange.owner.callAsync(
deploymentManager.governor.address,
);
expect(isAuthorized).to.be.true();
});
*/
it('should have registered the staking proxy', async () => {
const feeCollector = await deploymentManager.exchange.protocolFeeCollector.callAsync();
expect(feeCollector).to.be.eq(deploymentManager.staking.stakingProxy.address);
});
it('should have set the protocol fee multiplier', async () => {
const feeMultiplier = await deploymentManager.exchange.protocolFeeMultiplier.callAsync();
expect(feeMultiplier).bignumber.to.be.eq(DeploymentManager.protocolFeeMultiplier);
});
});
describe('staking', () => {
it('should be owned by the asset proxy owner', async () => {
const stakingOwner = await deploymentManager.staking.stakingProxy.owner.callAsync();
expect(stakingOwner).to.be.eq(deploymentManager.governor.address);
});
it('should have authorized the asset proxy owner in the staking proxy', async () => {
const isAuthorized = await deploymentManager.staking.stakingProxy.authorized.callAsync(
deploymentManager.governor.address,
);
expect(isAuthorized).to.be.true();
});
it('should have registered the exchange in the staking proxy', async () => {
const isValid = await deploymentManager.staking.stakingProxy.validExchanges.callAsync(
deploymentManager.exchange.address,
);
expect(isValid).to.be.true();
});
it('should have registered the read-only proxy in the staking proxy', async () => {
const readOnlyProxy = await deploymentManager.staking.stakingProxy.readOnlyProxy.callAsync();
expect(readOnlyProxy).to.be.eq(deploymentManager.staking.readOnlyProxy.address);
});
it('should have registered the staking contract in the staking proxy', async () => {
const stakingContract = await deploymentManager.staking.stakingProxy.stakingContract.callAsync();
expect(stakingContract).to.be.eq(deploymentManager.staking.stakingLogic.address);
});
it('should have registered the weth contract in the staking contract', async () => {
const weth = await deploymentManager.staking.stakingWrapper.testWethAddress.callAsync();
expect(weth).to.be.eq(deploymentManager.tokens.weth.address);
});
it('should have registered the zrx vault in the staking contract', async () => {
const zrxVault = await deploymentManager.staking.stakingWrapper.testZrxVaultAddress.callAsync();
expect(zrxVault).to.be.eq(deploymentManager.staking.zrxVault.address);
});
it('should have registered the staking proxy in the zrx vault', async () => {
const stakingProxy = await deploymentManager.staking.zrxVault.stakingProxyAddress.callAsync();
expect(stakingProxy).to.be.eq(deploymentManager.staking.stakingProxy.address);
});
it('should have correctly set the params', async () => {
const params = await deploymentManager.staking.stakingWrapper.getParams.callAsync();
expect(params).to.be.deep.eq([
stakingConstants.DEFAULT_PARAMS.epochDurationInSeconds,
stakingConstants.DEFAULT_PARAMS.rewardDelegatedStakeWeight,
stakingConstants.DEFAULT_PARAMS.minimumPoolStake,
stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaNumerator,
stakingConstants.DEFAULT_PARAMS.cobbDouglasAlphaDenominator,
]);
});
});
});

View File

@ -14,6 +14,12 @@ export interface Condition {
after: (beforeInfo: any, result: Result, ...args: any[]) => Promise<any>; after: (beforeInfo: any, result: Result, ...args: any[]) => Promise<any>;
} }
export interface Result {
data?: any;
receipt?: TransactionReceiptWithDecodedLogs;
success: boolean;
}
export class FunctionAssertion { export class FunctionAssertion {
// A before and an after assertion that will be called around the wrapper function. // A before and an after assertion that will be called around the wrapper function.
public condition: Condition; public condition: Condition;