diff options
author | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-08 21:42:07 +0800 |
---|---|---|
committer | Leonid Logvinov <logvinov.leon@gmail.com> | 2018-05-10 23:47:38 +0800 |
commit | a6f72de09d7b2c9738b78d2097baa9906838fbe9 (patch) | |
tree | 17126a5b45dabf2c7410d25668c68ce3d78284f0 /packages/sol-compiler/test/compiler_test.ts | |
parent | 96037aed5231aa9344e5037aa6cff3d01f4abdae (diff) | |
download | dexon-sol-tools-a6f72de09d7b2c9738b78d2097baa9906838fbe9.tar dexon-sol-tools-a6f72de09d7b2c9738b78d2097baa9906838fbe9.tar.gz dexon-sol-tools-a6f72de09d7b2c9738b78d2097baa9906838fbe9.tar.bz2 dexon-sol-tools-a6f72de09d7b2c9738b78d2097baa9906838fbe9.tar.lz dexon-sol-tools-a6f72de09d7b2c9738b78d2097baa9906838fbe9.tar.xz dexon-sol-tools-a6f72de09d7b2c9738b78d2097baa9906838fbe9.tar.zst dexon-sol-tools-a6f72de09d7b2c9738b78d2097baa9906838fbe9.zip |
Rename deployer to sol-compiler
Diffstat (limited to 'packages/sol-compiler/test/compiler_test.ts')
-rw-r--r-- | packages/sol-compiler/test/compiler_test.ts | 44 |
1 files changed, 44 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..9baf433d4 --- /dev/null +++ b/packages/sol-compiler/test/compiler_test.ts @@ -0,0 +1,44 @@ +import * as chai from 'chai'; +import 'mocha'; + +import { Compiler } from '../src/compiler'; +import { fsWrapper } from '../src/utils/fs_wrapper'; +import { CompilerOptions, ContractArtifact, ContractNetworkData, DoneCallback } 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(0, -86); + const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -86); + expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata); + }); +}); |