diff options
author | Jacob Evans <dekz@dekz.net> | 2018-04-12 08:20:52 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2018-04-12 08:20:52 +0800 |
commit | be73084e04264d44cfbd7cf6b8ba3a993368133d (patch) | |
tree | 68fc540971871fd99d0977957ac20132d6efed60 /packages/deployer/test | |
parent | 63b941fbaf08167234cf7871e874c1a96e4347fa (diff) | |
parent | 5eb90697c824f1c98467cdb6cd71dbb94ff70805 (diff) | |
download | dexon-sol-tools-be73084e04264d44cfbd7cf6b8ba3a993368133d.tar dexon-sol-tools-be73084e04264d44cfbd7cf6b8ba3a993368133d.tar.gz dexon-sol-tools-be73084e04264d44cfbd7cf6b8ba3a993368133d.tar.bz2 dexon-sol-tools-be73084e04264d44cfbd7cf6b8ba3a993368133d.tar.lz dexon-sol-tools-be73084e04264d44cfbd7cf6b8ba3a993368133d.tar.xz dexon-sol-tools-be73084e04264d44cfbd7cf6b8ba3a993368133d.tar.zst dexon-sol-tools-be73084e04264d44cfbd7cf6b8ba3a993368133d.zip |
Merge branch 'development' into feature/subproviders/mnemonic-wallet-subprovider
Diffstat (limited to 'packages/deployer/test')
-rw-r--r-- | packages/deployer/test/compiler_test.ts | 16 | ||||
-rw-r--r-- | packages/deployer/test/compiler_utils_test.ts | 22 | ||||
-rw-r--r-- | packages/deployer/test/deployer_test.ts | 19 | ||||
-rw-r--r-- | packages/deployer/test/fixtures/contracts/main/Exchange.sol (renamed from packages/deployer/test/fixtures/contracts/Exchange.sol) | 6 | ||||
-rw-r--r-- | packages/deployer/test/fixtures/contracts/main/TokenTransferProxy.sol (renamed from packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol) | 6 | ||||
-rw-r--r-- | packages/deployer/test/util/constants.ts | 1 | ||||
-rw-r--r-- | packages/deployer/test/util/provider.ts | 9 |
7 files changed, 57 insertions, 22 deletions
diff --git a/packages/deployer/test/compiler_test.ts b/packages/deployer/test/compiler_test.ts index b03ae7935..817a3b3f9 100644 --- a/packages/deployer/test/compiler_test.ts +++ b/packages/deployer/test/compiler_test.ts @@ -3,7 +3,13 @@ import 'mocha'; import { Compiler } from '../src/compiler'; import { fsWrapper } from '../src/utils/fs_wrapper'; -import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types'; +import { + CompilerOptions, + ContractArtifact, + ContractDirectory, + ContractNetworkData, + DoneCallback, +} from '../src/utils/types'; import { exchange_binary } from './fixtures/exchange_bin'; import { constants } from './util/constants'; @@ -13,11 +19,15 @@ const expect = chai.expect; describe('#Compiler', function() { this.timeout(constants.timeoutMs); const artifactsDir = `${__dirname}/fixtures/artifacts`; - const contractsDir = `${__dirname}/fixtures/contracts`; + const mainContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/main`, namespace: 'main' }; + const baseContractDir: ContractDirectory = { path: `${__dirname}/fixtures/contracts/base`, namespace: 'base' }; + const contractDirs: Set<ContractDirectory> = new Set(); + contractDirs.add(mainContractDir); + contractDirs.add(baseContractDir); const exchangeArtifactPath = `${artifactsDir}/Exchange.json`; const compilerOpts: CompilerOptions = { artifactsDir, - contractsDir, + contractDirs, networkId: constants.networkId, optimizerEnabled: constants.optimizerEnabled, specifiedContracts: new Set(constants.specifiedContracts), diff --git a/packages/deployer/test/compiler_utils_test.ts b/packages/deployer/test/compiler_utils_test.ts index 246304858..5377d3308 100644 --- a/packages/deployer/test/compiler_utils_test.ts +++ b/packages/deployer/test/compiler_utils_test.ts @@ -47,28 +47,34 @@ describe('Compiler utils', () => { }); describe('#parseDependencies', () => { it('correctly parses Exchange dependencies', async () => { - const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/Exchange.sol`, { + const exchangeSource = await fsWrapper.readFileAsync(`${__dirname}/fixtures/contracts/main/Exchange.sol`, { encoding: 'utf8', }); - expect(parseDependencies(exchangeSource)).to.be.deep.equal([ - 'TokenTransferProxy.sol', - 'Token.sol', - 'SafeMath.sol', + const sourceFileId = '/main/Exchange.sol'; + expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([ + '/main/TokenTransferProxy.sol', + '/base/Token.sol', + '/base/SafeMath.sol', ]); }); it('correctly parses TokenTransferProxy dependencies', async () => { const exchangeSource = await fsWrapper.readFileAsync( - `${__dirname}/fixtures/contracts/TokenTransferProxy.sol`, + `${__dirname}/fixtures/contracts/main/TokenTransferProxy.sol`, { encoding: 'utf8', }, ); - expect(parseDependencies(exchangeSource)).to.be.deep.equal(['Token.sol', 'Ownable.sol']); + const sourceFileId = '/main/TokenTransferProxy.sol'; + expect(parseDependencies(exchangeSource, sourceFileId)).to.be.deep.equal([ + '/base/Token.sol', + '/base/Ownable.sol', + ]); }); // TODO: For now that doesn't work. This will work after we switch to a grammar-based parser it.skip('correctly parses commented out dependencies', async () => { const contractWithCommentedOutDependencies = `// import "./TokenTransferProxy.sol";`; - expect(parseDependencies(contractWithCommentedOutDependencies)).to.be.deep.equal([]); + const sourceFileId = '/main/TokenTransferProxy.sol'; + expect(parseDependencies(contractWithCommentedOutDependencies, sourceFileId)).to.be.deep.equal([]); }); }); }); diff --git a/packages/deployer/test/deployer_test.ts b/packages/deployer/test/deployer_test.ts index 9c34d74aa..a213932f9 100644 --- a/packages/deployer/test/deployer_test.ts +++ b/packages/deployer/test/deployer_test.ts @@ -4,20 +4,31 @@ import 'mocha'; import { Compiler } from '../src/compiler'; import { Deployer } from '../src/deployer'; import { fsWrapper } from '../src/utils/fs_wrapper'; -import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } from '../src/utils/types'; +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 contractsDir = `${__dirname}/fixtures/contracts`; 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, - contractsDir, + contractDirs, networkId: constants.networkId, optimizerEnabled: constants.optimizerEnabled, specifiedContracts: new Set(constants.specifiedContracts), @@ -26,7 +37,7 @@ describe('#Deployer', () => { const deployerOpts = { artifactsDir, networkId: constants.networkId, - jsonrpcUrl: constants.jsonrpcUrl, + provider, defaults: { gasPrice: constants.gasPrice, }, diff --git a/packages/deployer/test/fixtures/contracts/Exchange.sol b/packages/deployer/test/fixtures/contracts/main/Exchange.sol index 1b6819700..ea9ca3afa 100644 --- a/packages/deployer/test/fixtures/contracts/Exchange.sol +++ b/packages/deployer/test/fixtures/contracts/main/Exchange.sol @@ -1,6 +1,6 @@ /* - Copyright 2017 ZeroEx Intl. + Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -19,8 +19,8 @@ pragma solidity 0.4.14; import "./TokenTransferProxy.sol"; -import "./base/Token.sol"; -import "./base/SafeMath.sol"; +import "/base/Token.sol"; +import "/base/SafeMath.sol"; /// @title Exchange - Facilitates exchange of ERC20 tokens. /// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com> diff --git a/packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol b/packages/deployer/test/fixtures/contracts/main/TokenTransferProxy.sol index 90c8e7d66..99d16cb57 100644 --- a/packages/deployer/test/fixtures/contracts/TokenTransferProxy.sol +++ b/packages/deployer/test/fixtures/contracts/main/TokenTransferProxy.sol @@ -1,6 +1,6 @@ /* - Copyright 2017 ZeroEx Intl. + Copyright 2018 ZeroEx Intl. Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -18,8 +18,8 @@ pragma solidity 0.4.14; -import "./base/Token.sol"; -import "./base/Ownable.sol"; +import "/base/Token.sol"; +import "/base/Ownable.sol"; /// @title TokenTransferProxy - Transfers tokens on behalf of contracts that have been approved via decentralized governance. /// @author Amir Bandeali - <amir@0xProject.com>, Will Warren - <will@0xProject.com> diff --git a/packages/deployer/test/util/constants.ts b/packages/deployer/test/util/constants.ts index 5385b8d17..b93081a80 100644 --- a/packages/deployer/test/util/constants.ts +++ b/packages/deployer/test/util/constants.ts @@ -2,7 +2,6 @@ import { BigNumber } from '@0xproject/utils'; export const constants = { networkId: 0, - jsonrpcUrl: 'http://localhost:8545', optimizerEnabled: false, gasPrice: new BigNumber(20000000000), timeoutMs: 30000, diff --git a/packages/deployer/test/util/provider.ts b/packages/deployer/test/util/provider.ts new file mode 100644 index 000000000..e0fcb362a --- /dev/null +++ b/packages/deployer/test/util/provider.ts @@ -0,0 +1,9 @@ +import { web3Factory } from '@0xproject/dev-utils'; +import { Provider } from '@0xproject/types'; +import * as Web3 from 'web3'; + +const providerConfigs = { shouldUseInProcessGanache: true }; +const web3Instance = web3Factory.create(providerConfigs); +const provider: Provider = web3Instance.currentProvider; + +export { provider }; |