Add a test to keep artifact sizes down
This commit is contained in:
parent
7cf60fa927
commit
fa1db64a8e
@ -12,6 +12,8 @@
|
|||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "yarn tsc -b",
|
"build": "yarn tsc -b",
|
||||||
"build:ci": "yarn build",
|
"build:ci": "yarn build",
|
||||||
|
"test": "yarn run_mocha",
|
||||||
|
"run_mocha": "mocha --require source-map-support/register --require make-promises-safe lib/test/**/*_test.js --bail --exit",
|
||||||
"clean": "shx rm -rf lib"
|
"clean": "shx rm -rf lib"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
@ -25,7 +27,12 @@
|
|||||||
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contract-artifacts/README.md",
|
"homepage": "https://github.com/0xProject/0x-monorepo/packages/contract-artifacts/README.md",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"shx": "^0.2.2",
|
"shx": "^0.2.2",
|
||||||
"typescript": "3.0.1"
|
"typescript": "3.0.1",
|
||||||
|
"chai": "^4.0.1",
|
||||||
|
"dirty-chai": "^2.0.1",
|
||||||
|
"make-promises-safe": "^1.1.0",
|
||||||
|
"mocha": "^4.1.0",
|
||||||
|
"lodash": "^4.17.11"
|
||||||
},
|
},
|
||||||
"publishConfig": {
|
"publishConfig": {
|
||||||
"access": "public"
|
"access": "public"
|
||||||
|
35
packages/contract-artifacts/test/contract_artifacts_test.ts
Normal file
35
packages/contract-artifacts/test/contract_artifacts_test.ts
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
import * as chai from 'chai';
|
||||||
|
import * as dirtyChai from 'dirty-chai';
|
||||||
|
import { get } from 'lodash';
|
||||||
|
import 'mocha';
|
||||||
|
|
||||||
|
import * as artifacts from '../src/index';
|
||||||
|
|
||||||
|
chai.use(dirtyChai);
|
||||||
|
|
||||||
|
const expect = chai.expect;
|
||||||
|
|
||||||
|
describe('Contract Artifacts', () => {
|
||||||
|
const forbiddenProperties = [
|
||||||
|
'compilerOutput.evm.bytecode.sourceMap',
|
||||||
|
'compilerOutput.evm.bytecode.opcodes',
|
||||||
|
'sourceCodes',
|
||||||
|
'sources',
|
||||||
|
'compiler',
|
||||||
|
];
|
||||||
|
it('should not include forbidden attributes', () => {
|
||||||
|
const forbiddenPropertiesByArtifact: { [name: string]: string[] } = {};
|
||||||
|
for (const [artifactName, artifact] of Object.entries(artifacts)) {
|
||||||
|
for (const forbiddenProperty of forbiddenProperties) {
|
||||||
|
const rejectedValue = get(artifact, forbiddenProperty);
|
||||||
|
if (rejectedValue) {
|
||||||
|
const previousForbidden = forbiddenPropertiesByArtifact[artifactName];
|
||||||
|
forbiddenPropertiesByArtifact[artifactName] = previousForbidden
|
||||||
|
? [...previousForbidden, forbiddenProperty]
|
||||||
|
: [forbiddenProperty];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
expect(forbiddenPropertiesByArtifact).to.be.eq({});
|
||||||
|
});
|
||||||
|
});
|
@ -5,7 +5,7 @@
|
|||||||
"rootDir": ".",
|
"rootDir": ".",
|
||||||
"resolveJsonModule": true
|
"resolveJsonModule": true
|
||||||
},
|
},
|
||||||
"include": ["./src/**/*"],
|
"include": ["./src/**/*", "./test/**/*"],
|
||||||
"files": [
|
"files": [
|
||||||
"./artifacts/AssetProxyOwner.json",
|
"./artifacts/AssetProxyOwner.json",
|
||||||
"./artifacts/DutchAuction.json",
|
"./artifacts/DutchAuction.json",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user