Skip to content

Commit e3bd593

Browse files
committed
Bye bye Truffle; Hello Saddle 🐎 (#511)
This patch adds Saddle, replacing Truffle as our Solidity framework. The [Saddle](https://github.com/compound-finance/saddle) framework lets us quickly run tests and coverage and improves the overall performance interacting with our contracts.
1 parent bfc2914 commit e3bd593

File tree

138 files changed

+9646
-9572
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

138 files changed

+9646
-9572
lines changed

.circleci/config.yml

+61-53
Original file line numberDiff line numberDiff line change
@@ -22,16 +22,14 @@ jobs:
2222
keys:
2323
- v2-scenario/dependencies-{{ checksum "scenario/package.json" }}
2424
- v2-scenario/dependencies-
25+
- restore_cache:
26+
keys:
27+
- v2-solcache
28+
- restore_cache:
29+
keys:
30+
- v2-scencache
2531
- run: yarn install
2632
- run: cd scenario && yarn install
27-
- run:
28-
name: Ganache
29-
command: script/ganache
30-
background: true
31-
- run: |
32-
while ! nc -z localhost 8545; do
33-
sleep 0.1 # wait for ganache to start
34-
done
3533
- save_cache:
3634
paths:
3735
- node_modules
@@ -43,50 +41,47 @@ jobs:
4341
- attach_workspace:
4442
at: ~/repo
4543
- run: mkdir ~/junit
46-
- run: MOCHA_FILE=~/junit/test-results.xml script/test
44+
- run: ./script/build_scenarios
45+
- run:
46+
shell: /bin/bash -eox pipefail -O globstar
47+
name: yarn test
48+
command: JEST_JUNIT_OUTPUT_DIR=~/junit JEST_JUNIT_OUTPUT_NAME=test-results.xml yarn test $(circleci tests glob 'tests/**/**Test.js' | circleci tests split --split-by=timings)
49+
- save_cache:
50+
paths:
51+
- .build
52+
- .solcache
53+
key: v2-solcache
54+
- save_cache:
55+
paths:
56+
- scenario/.tsbuilt
57+
- .scencache
58+
key: v2-scencache
4759
- store_test_results:
4860
path: ~/junit
4961
- store_artifacts:
5062
path: ~/junit
51-
parallelism: 4
63+
parallelism: 3
64+
resource_class: large
5265

53-
mocha_coverage:
54-
parallelism: 5
66+
verify:
5567
docker:
56-
- image: circleci/node:11
68+
- image: compoundfinance/alpine-java-z3:latest
5769
working_directory: ~/repo
5870
steps:
5971
- checkout
60-
- restore_cache:
61-
keys:
62-
- v2-dependencies-{{ checksum "package.json" }}
63-
- v2-dependencies-
64-
- run: yarn install
65-
- save_cache:
66-
paths:
67-
- node_modules
68-
key: v2-dependencies-{{ checksum "package.json" }}
6972
- attach_workspace:
7073
at: ~/repo
71-
- run:
72-
command: yarn run coverage mocha
73-
no_output_timeout: 20m
74-
- store_artifacts:
75-
path: ~/repo/coverage.json
76-
destination: coverage.json
77-
- store_artifacts:
78-
path: ~/repo/coverage
79-
destination: coverage
80-
- codecov/upload
74+
- run: script/verify
75+
parallelism: 2
8176

82-
scenario_coverage:
77+
coverage:
8378
docker:
8479
- image: circleci/node:11
8580
working_directory: ~/repo
8681
steps:
8782
- run:
8883
|
89-
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.8/solc-static-linux -O /usr/local/bin/solc
84+
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.12/solc-static-linux -O /usr/local/bin/solc
9085
sudo chmod +x /usr/local/bin/solc
9186
- checkout
9287
- restore_cache:
@@ -97,10 +92,12 @@ jobs:
9792
keys:
9893
- v2-scenario/dependencies-{{ checksum "scenario/package.json" }}
9994
- v2-scenario/dependencies-
100-
- run:
101-
|
102-
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.12/solc-static-linux -O /usr/local/bin/solc
103-
sudo chmod +x /usr/local/bin/solc
95+
- restore_cache:
96+
keys:
97+
- v2-solcache
98+
- restore_cache:
99+
keys:
100+
- v2-scencache
104101
- run: yarn install
105102
- run: cd scenario && yarn install
106103
- save_cache:
@@ -113,21 +110,38 @@ jobs:
113110
key: v2-scenario-dependencies-{{ checksum "scenario/package.json" }}
114111
- attach_workspace:
115112
at: ~/repo
113+
- run: mkdir ~/junit
114+
- run: ./script/build_scenarios
116115
- run:
117-
command: yarn run coverage scenario
118-
no_output_timeout: 20m
116+
shell: /bin/bash -eox pipefail -O globstar
117+
name: yarn test
118+
command: JEST_JUNIT_OUTPUT_DIR=~/junit JEST_JUNIT_OUTPUT_NAME=test-results.xml script/coverage $(circleci tests glob 'tests/**/**Test.js' | circleci tests split --split-by=timings) -- --maxWorkers=4
119+
- save_cache:
120+
paths:
121+
- .build
122+
- .solcachecov
123+
key: v2-solcache
124+
- save_cache:
125+
paths:
126+
- scenario/.tsbuilt
127+
- .scencache
128+
key: v2-scencache
129+
- store_test_results:
130+
path: ~/junit
119131
- store_artifacts:
120-
path: ~/repo/coverage.json
121-
destination: coverage.json
132+
path: ~/repo/coverage/coverage-final.json
133+
destination: coverage-final.json
122134
- store_artifacts:
123-
path: ~/repo/coverage
135+
path: ~/repo/coverage/lcov-report
124136
destination: coverage
125-
- codecov/upload
137+
- codecov/upload:
138+
file: ~/repo/coverage/coverage-final.json
139+
parallelism: 10
140+
resource_class: large
126141

127142
lint:
128143
docker:
129144
- image: circleci/node:11
130-
- image: trufflesuite/ganache-cli:v6.7.0
131145
working_directory: ~/repo
132146
steps:
133147
- checkout
@@ -149,12 +163,6 @@ workflows:
149163
build-test-and-deploy:
150164
jobs:
151165
- test
152-
- mocha_coverage:
153-
filters:
154-
branches:
155-
only: /^(master|(.*-cov(er(age)?)?))$/
156-
- scenario_coverage:
157-
filters:
158-
branches:
159-
only: /^(master|(.*-cov(er(age)?)?))$/
166+
- coverage
160167
- lint
168+
- verify

.gitignore

+8-1
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,11 @@ scTopics
2626
test-results.xml
2727
.tsbuilt
2828
yarn-error.log
29-
scenario/build/webpack.js
29+
scenario/build/webpack.js
30+
.scencache
31+
.solcache
32+
.solcachecov
33+
scenario/.tscache
34+
tests/scenarios/
35+
junit.xml
36+
.build

README.md

-12
Original file line numberDiff line numberDiff line change
@@ -107,18 +107,6 @@ Deployment
107107

108108
The easiest way to deploy some Erc20 tokens, cTokens and a Comptroller is through scenario scripts.
109109

110-
# run ganache locally
111-
script/ganache # or `ganache-cli`
112-
113-
# ensure development files don't exist as
114-
# new ganache instances invalidate old deployed contracts
115-
rm networks/development*
116-
117-
# run deployment script
118-
yarn run deploy -v
119-
120-
After that, you'll have a full set of contracts deployed locally. Look in `networks/development.json` for the addresses for those deployed contracts. You can use the `yarn run console` command above to interact with the contracts (or the scenario REPL, if you prefer).
121-
122110
Testing
123111
-------
124112
Mocha contract tests are defined under the [test directory](https://github.com/compound-finance/compound-protocol/tree/master/test). To run the tests run:

jest.config.js

+188
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,188 @@
1+
// For a detailed explanation regarding each configuration property, visit:
2+
// https://jestjs.io/docs/en/configuration.html
3+
4+
module.exports = {
5+
// All imported modules in your tests should be mocked automatically
6+
// automock: false,
7+
8+
// Stop running tests after `n` failures
9+
// bail: 0,
10+
11+
// Respect "browser" field in package.json when resolving modules
12+
// browser: false,
13+
14+
// The directory where Jest should store its cached dependency information
15+
// cacheDirectory: "/private/var/folders/jz/z56b1n2902584b4zplqztm3m0000gn/T/jest_dx",
16+
17+
// Automatically clear mock calls and instances between every test
18+
// clearMocks: false,
19+
20+
// Indicates whether the coverage information should be collected while executing the test
21+
// collectCoverage: false,
22+
23+
// An array of glob patterns indicating a set of files for which coverage information should be collected
24+
// collectCoverageFrom: null,
25+
26+
// The directory where Jest should output its coverage files
27+
// coverageDirectory: null,
28+
29+
// An array of regexp pattern strings used to skip coverage collection
30+
// coveragePathIgnorePatterns: [
31+
// "/node_modules/"
32+
// ],
33+
34+
// A list of reporter names that Jest uses when writing coverage reports
35+
// coverageReporters: [
36+
// "json",
37+
// "text",
38+
// "lcov",
39+
// "clover"
40+
// ],
41+
42+
// An object that configures minimum threshold enforcement for coverage results
43+
// coverageThreshold: null,
44+
45+
// A path to a custom dependency extractor
46+
// dependencyExtractor: null,
47+
48+
// Make calling deprecated APIs throw helpful error messages
49+
// errorOnDeprecated: false,
50+
51+
// Force coverage collection from ignored files using an array of glob patterns
52+
// forceCoverageMatch: [],
53+
54+
// A path to a module which exports an async function that is triggered once before all test suites
55+
// globalSetup: null,
56+
57+
// A path to a module which exports an async function that is triggered once after all test suites
58+
// globalTeardown: null,
59+
60+
// A set of global variables that need to be available in all test environments
61+
// globals: {},
62+
63+
// An array of directory names to be searched recursively up from the requiring module's location
64+
// moduleDirectories: [
65+
// "node_modules"
66+
// ],
67+
68+
// An array of file extensions your modules use
69+
// moduleFileExtensions: [
70+
// "js",
71+
// "json",
72+
// "jsx",
73+
// "ts",
74+
// "tsx",
75+
// "node"
76+
// ],
77+
78+
// A map from regular expressions to module names that allow to stub out resources with a single module
79+
// moduleNameMapper: {},
80+
81+
// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
82+
// modulePathIgnorePatterns: [],
83+
84+
// Activates notifications for test results
85+
// notify: false,
86+
87+
// An enum that specifies notification mode. Requires { notify: true }
88+
// notifyMode: "failure-change",
89+
90+
// A preset that is used as a base for Jest's configuration
91+
// preset: null,
92+
93+
// Run tests from one or more projects
94+
// projects: null,
95+
96+
// Use this configuration option to add custom reporters to Jest
97+
reporters: ["default", "jest-junit"],
98+
99+
// Automatically reset mock state between every test
100+
// resetMocks: false,
101+
102+
// Reset the module registry before running each individual test
103+
// resetModules: false,
104+
105+
// A path to a custom resolver
106+
// resolver: null,
107+
108+
// Automatically restore mock state between every test
109+
// restoreMocks: false,
110+
111+
// The root directory that Jest should scan for tests and modules within
112+
// rootDir: null,
113+
114+
// A list of paths to directories that Jest should use to search for files in
115+
// roots: [
116+
// "<rootDir>"
117+
// ],
118+
119+
// Allows you to use a custom runner instead of Jest's default test runner
120+
// runner: "jest-runner",
121+
122+
// The paths to modules that run some code to configure or set up the testing environment before each test
123+
// setupFiles: [],
124+
125+
// A list of paths to modules that run some code to configure or set up the testing framework before each test
126+
setupFilesAfterEnv: [
127+
"<rootDir>/tests/Matchers.js",
128+
"<rootDir>/tests/Jest.js"
129+
],
130+
131+
// A list of paths to snapshot serializer modules Jest should use for snapshot testing
132+
// snapshotSerializers: [],
133+
134+
// The test environment that will be used for testing
135+
testEnvironment: "node",
136+
137+
// Options that will be passed to the testEnvironment
138+
// testEnvironmentOptions: {},
139+
140+
// Adds a location field to test results
141+
// testLocationInResults: false,
142+
143+
// The glob patterns Jest uses to detect test files
144+
// testMatch: [
145+
// "**/__tests__/**/*.[jt]s?(x)",
146+
// "**/?(*.)+(spec|test).[tj]s?(x)"
147+
// ],
148+
149+
// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
150+
// testPathIgnorePatterns: [
151+
// "/node_modules/"
152+
// ],
153+
154+
// The regexp pattern or array of patterns that Jest uses to detect test files
155+
// testRegex: [],
156+
157+
// This option allows the use of a custom results processor
158+
// testResultsProcessor: null,
159+
160+
// This option allows use of a custom test runner
161+
// testRunner: "jasmine2",
162+
163+
// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
164+
// testURL: "http://localhost",
165+
166+
// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
167+
// timers: "real",
168+
169+
// A map from regular expressions to paths to transformers
170+
// transform: null,
171+
172+
// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
173+
// transformIgnorePatterns: [
174+
// "/node_modules/"
175+
// ],
176+
177+
// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
178+
// unmockedModulePathPatterns: undefined,
179+
180+
// Indicates whether each individual test should be reported during the run
181+
// verbose: null,
182+
183+
// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
184+
// watchPathIgnorePatterns: [],
185+
186+
// Whether to use watchman for file crawling
187+
// watchman: true,
188+
};

0 commit comments

Comments
 (0)