Skip to content

Commit

Permalink
added options to check contract size in ci/cd pipeline
Browse files Browse the repository at this point in the history
  • Loading branch information
daniel-iobuilders committed Jun 18, 2020
1 parent dfaf19a commit 1ae7574
Show file tree
Hide file tree
Showing 5 changed files with 352 additions and 18 deletions.
2 changes: 1 addition & 1 deletion .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ module.exports = {
},
rules: {
}
};
}
28 changes: 26 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,32 @@ The command can be executed without any arguments to display the size of **all**
truffle run contract-size
```

To show only certain contracts one or more contract names can be given as arguments
To show only certain contracts one or more contract names can be given as arguments to the contracts option:

```bash
truffle run contract-size ExampleContract1 ExampleContract2
truffle run contract-size --contracts ExampleContract1 ExampleContract2
```

### Check maximum contract sizes

The plugin can be used to check that the smart contracts aren't bigger than the allowed maximum contract size of the Ethereum Mainnet (24 kb). For example this can be used, to make a CI/CD pipeline fail, if a contract is bigger than allowed.

```bash
truffle run contract-size --checkMaxSize
```

If another size limit than the default one should be checked, it can be given as argument to the option. For example to set the maximum to 48 kb the following command can be used:

```bash
truffle run contract-size --checkMaxSize 48
```

If one or more of the contracts are bigger than the maximum size, an error message will de displayed, and the exit status will be 1.

### Ignore mocks

Mock contracts are used to improve the testing of smart contracts. As they are only used during testing and will not be deployed, it can be useful to ignore when calculating the contract sizes. When the option is used, all contract which names are ending with `Mock` will be ignored. This can especially be useful in combination with the `--checkMaxSize` option.

```bash
truffle run contract-size --ignoreMocks
```
264 changes: 263 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "truffle-contract-size",
"version": "1.0.1",
"version": "2.0.0",
"description": "Displays the size of a truffle contracts in kilobytes",
"main": "src/index.js",
"scripts": {
Expand All @@ -26,7 +26,8 @@
},
"homepage": "https://github.com/IoBuilders/truffle-contract-size#readme",
"dependencies": {
"cli-table": "^0.3.1"
"cli-table": "^0.3.1",
"yargs": "^15.3.1"
},
"devDependencies": {
"eslint": "^6.1.0",
Expand Down
Loading

0 comments on commit 1ae7574

Please sign in to comment.