diff options
author | Alex Browne <stephenalexbrowne@gmail.com> | 2018-08-14 09:42:09 +0800 |
---|---|---|
committer | Alex Browne <stephenalexbrowne@gmail.com> | 2018-08-14 09:42:09 +0800 |
commit | 88766a02c7e6688e72d5c4c69ce68028b322f154 (patch) | |
tree | fa06552a80249e7998691b64df6b3b2827f9f947 /packages/sol-compiler/test/compiler_test.ts | |
parent | 8162394797342cef268cc8072fc860326974e269 (diff) | |
parent | fadd292ecf367e42154856509d0ea0c20b23f2f1 (diff) | |
download | dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.gz dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.bz2 dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.lz dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.xz dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.tar.zst dexon-0x-contracts-88766a02c7e6688e72d5c4c69ce68028b322f154.zip |
Merge branch 'development'
Diffstat (limited to 'packages/sol-compiler/test/compiler_test.ts')
-rw-r--r-- | packages/sol-compiler/test/compiler_test.ts | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/packages/sol-compiler/test/compiler_test.ts b/packages/sol-compiler/test/compiler_test.ts new file mode 100644 index 000000000..c9e141ee9 --- /dev/null +++ b/packages/sol-compiler/test/compiler_test.ts @@ -0,0 +1,50 @@ +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 } from '../src/utils/types'; + +import { exchange_binary } from './fixtures/exchange_bin'; +import { constants } from './util/constants'; + +const expect = chai.expect; + +describe('#Compiler', function(): void { + this.timeout(constants.timeoutMs); // tslint:disable-line:no-invalid-this + 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 metadataByteLength = 43; + const metadataHexLength = metadataByteLength * 2; + const unlinkedBinaryWithoutMetadata = exchangeArtifact.compilerOutput.evm.bytecode.object.slice( + 2, + -metadataHexLength, + ); + const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -metadataHexLength); + expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata); + }); +}); |