* development: Fix lint error Fix documentation links in some READMEs Fix relative link Add step to publishing that upload staging doc jsons, deploys staging website, opens every docs page and asks the dev to confirm that each one renders properly before publishing Fix web3Wrapper build command Add top-level `yarn lerna:stage_docs` to upload docJsons to the staging S3 bucket for all packages with a docs page Added a detailed description of `renameOverloadedMethods` (special thanks to @fabioberger). Updated Javascript styles in the Abi-Gen and Utils packages, around support for function overloading. Updated deployer to accept a list of contract directories as input. Contract directories are namespaced to a void clashes. Also in this commit is a fix for overloading contract functions. Refactor publish script to have it's main execution body be lean and discrete steps # Conflicts: # packages/contracts/package.json # packages/deployer/package.json
88 lines
3.9 KiB
TypeScript
88 lines
3.9 KiB
TypeScript
import * as chai from 'chai';
|
|
import 'mocha';
|
|
|
|
import { Compiler } from '../src/compiler';
|
|
import { Deployer } from '../src/deployer';
|
|
import { fsWrapper } from '../src/utils/fs_wrapper';
|
|
import {
|
|
CompilerOptions,
|
|
ContractArtifact,
|
|
ContractDirectory,
|
|
ContractNetworkData,
|
|
DoneCallback,
|
|
} from '../src/utils/types';
|
|
|
|
import { constructor_args, exchange_binary } from './fixtures/exchange_bin';
|
|
import { constants } from './util/constants';
|
|
import { provider } from './util/provider';
|
|
|
|
const expect = chai.expect;
|
|
|
|
describe('#Deployer', () => {
|
|
const artifactsDir = `${__dirname}/fixtures/artifacts`;
|
|
const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
|
|
const mainContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/main`, namespace: '' };
|
|
const baseContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/base`, namespace: 'base' };
|
|
const contractDirs: Set<ContractDirectory> = new Set();
|
|
contractDirs.add(mainContractDir);
|
|
contractDirs.add(baseContractDir);
|
|
const compilerOpts: CompilerOptions = {
|
|
artifactsDir,
|
|
contractDirs,
|
|
networkId: constants.networkId,
|
|
optimizerEnabled: constants.optimizerEnabled,
|
|
specifiedContracts: new Set(constants.specifiedContracts),
|
|
};
|
|
const compiler = new Compiler(compilerOpts);
|
|
const deployerOpts = {
|
|
artifactsDir,
|
|
networkId: constants.networkId,
|
|
provider,
|
|
defaults: {
|
|
gasPrice: constants.gasPrice,
|
|
},
|
|
};
|
|
const deployer = new Deployer(deployerOpts);
|
|
beforeEach(function(done: DoneCallback) {
|
|
this.timeout(constants.timeoutMs);
|
|
(async () => {
|
|
if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) {
|
|
await fsWrapper.removeFileAsync(exchangeArtifactPath);
|
|
}
|
|
await compiler.compileAsync();
|
|
done();
|
|
})().catch(done);
|
|
});
|
|
describe('#deployAsync', () => {
|
|
it('should deploy the Exchange contract without updating the Exchange artifact', async () => {
|
|
const exchangeConstructorArgs = [constants.zrxTokenAddress, constants.tokenTransferProxyAddress];
|
|
const exchangeContractInstance = await deployer.deployAsync('Exchange', exchangeConstructorArgs);
|
|
const opts = {
|
|
encoding: 'utf8',
|
|
};
|
|
const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts);
|
|
const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString);
|
|
const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId];
|
|
const exchangeAddress = exchangeContractInstance.address;
|
|
expect(exchangeAddress).to.not.equal(undefined);
|
|
expect(exchangeContractData.address).to.equal(undefined);
|
|
expect(exchangeContractData.constructor_args).to.equal(undefined);
|
|
});
|
|
});
|
|
describe('#deployAndSaveAsync', () => {
|
|
it('should save the correct contract address and constructor arguments to the Exchange artifact', async () => {
|
|
const exchangeConstructorArgs = [constants.zrxTokenAddress, constants.tokenTransferProxyAddress];
|
|
const exchangeContractInstance = await deployer.deployAndSaveAsync('Exchange', exchangeConstructorArgs);
|
|
const opts = {
|
|
encoding: 'utf8',
|
|
};
|
|
const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts);
|
|
const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString);
|
|
const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId];
|
|
const exchangeAddress = exchangeContractInstance.address;
|
|
expect(exchangeAddress).to.be.equal(exchangeContractData.address);
|
|
expect(constructor_args).to.be.equal(exchangeContractData.constructor_args);
|
|
});
|
|
});
|
|
});
|