Merge branch 'development' into breakUp0xjs
* development: Fix ganache subprovider config Fix a bug in compiler config precedence Fix linter errors Fix templates Remove unused deployer docs configs Add a legacy endpoint for the deployer Add a check for compiler output Add a comment Put ARTIFACTS_VERSION in a config Improve a comment Remove _applyDefaultsToDeployTxDataAsync Add a HACK comment Fix linter issues Rename deployer to sol-compiler Remove deployer Remove deployer from 0x.js and migrations Configure migrations with a compiler.json Remove deployer from metacoin and contract tests Update wallet footer and add remove token functionality # Conflicts: # .gitignore # packages/0x.js/package.json # packages/0x.js/src/0x.ts # packages/contracts/package.json # packages/contracts/test/multi_sig_with_time_lock.ts # packages/contracts/test/multi_sig_with_time_lock_except_remove_auth_addr.ts # packages/contracts/util/artifacts.ts # packages/deployer/test/deployer_test.ts # packages/migrations/package.json
This commit is contained in:
45
packages/sol-compiler/test/compiler_test.ts
Normal file
45
packages/sol-compiler/test/compiler_test.ts
Normal file
@@ -0,0 +1,45 @@
|
||||
import { DoneCallback } from '@0xproject/types';
|
||||
import * as chai from 'chai';
|
||||
import 'mocha';
|
||||
|
||||
import { Compiler } from '../src/compiler';
|
||||
import { fsWrapper } from '../src/utils/fs_wrapper';
|
||||
import { CompilerOptions, ContractArtifact, ContractNetworkData } from '../src/utils/types';
|
||||
|
||||
import { exchange_binary } from './fixtures/exchange_bin';
|
||||
import { constants } from './util/constants';
|
||||
|
||||
const expect = chai.expect;
|
||||
|
||||
describe('#Compiler', function() {
|
||||
this.timeout(constants.timeoutMs);
|
||||
const artifactsDir = `${__dirname}/fixtures/artifacts`;
|
||||
const contractsDir = `${__dirname}/fixtures/contracts`;
|
||||
const exchangeArtifactPath = `${artifactsDir}/Exchange.json`;
|
||||
const compilerOpts: CompilerOptions = {
|
||||
artifactsDir,
|
||||
contractsDir,
|
||||
contracts: constants.contracts,
|
||||
};
|
||||
const compiler = new Compiler(compilerOpts);
|
||||
beforeEach((done: DoneCallback) => {
|
||||
(async () => {
|
||||
if (fsWrapper.doesPathExistSync(exchangeArtifactPath)) {
|
||||
await fsWrapper.removeFileAsync(exchangeArtifactPath);
|
||||
}
|
||||
await compiler.compileAsync();
|
||||
done();
|
||||
})().catch(done);
|
||||
});
|
||||
it('should create an Exchange artifact with the correct unlinked binary', async () => {
|
||||
const opts = {
|
||||
encoding: 'utf8',
|
||||
};
|
||||
const exchangeArtifactString = await fsWrapper.readFileAsync(exchangeArtifactPath, opts);
|
||||
const exchangeArtifact: ContractArtifact = JSON.parse(exchangeArtifactString);
|
||||
// The last 43 bytes of the binaries are metadata which may not be equivalent
|
||||
const unlinkedBinaryWithoutMetadata = exchangeArtifact.compilerOutput.evm.bytecode.object.slice(2, -86);
|
||||
const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -86);
|
||||
expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata);
|
||||
});
|
||||
});
|
Reference in New Issue
Block a user