aboutsummaryrefslogtreecommitdiffstats
path: root/packages/deployer/test/compiler_test.ts
diff options
context:
space:
mode:
authorFabio Berger <me@fabioberger.com>2018-03-28 02:16:13 +0800
committerFabio Berger <me@fabioberger.com>2018-03-28 02:16:13 +0800
commit005376276098a4e6cb832eaf5b5dbc07118e1f50 (patch)
tree543a431a5fd2a17f3b3582cfb0910f8c85357ac1 /packages/deployer/test/compiler_test.ts
parenteb89ef79eba3d044e10b8e52e20927bb88241ac2 (diff)
parent066d13f5b7260d28b13195c4f9aed48b4ae96cc3 (diff)
downloaddexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.gz
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.bz2
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.lz
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.xz
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.tar.zst
dexon-sol-tools-005376276098a4e6cb832eaf5b5dbc07118e1f50.zip
merge developmentx
Diffstat (limited to 'packages/deployer/test/compiler_test.ts')
-rw-r--r--packages/deployer/test/compiler_test.ts47
1 files changed, 47 insertions, 0 deletions
diff --git a/packages/deployer/test/compiler_test.ts b/packages/deployer/test/compiler_test.ts
new file mode 100644
index 000000000..b03ae7935
--- /dev/null
+++ b/packages/deployer/test/compiler_test.ts
@@ -0,0 +1,47 @@
+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,
+ networkId: constants.networkId,
+ optimizerEnabled: constants.optimizerEnabled,
+ specifiedContracts: new Set(constants.specifiedContracts),
+ };
+ 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);
+ const exchangeContractData: ContractNetworkData = exchangeArtifact.networks[constants.networkId];
+ // The last 43 bytes of the binaries are metadata which may not be equivalent
+ const unlinkedBinaryWithoutMetadata = exchangeContractData.bytecode.slice(0, -86);
+ const exchangeBinaryWithoutMetadata = exchange_binary.slice(0, -86);
+ expect(unlinkedBinaryWithoutMetadata).to.equal(exchangeBinaryWithoutMetadata);
+ });
+});