Skip to content

Commit

Permalink
Bye bye Truffle; Hello Saddle 🐎 (#511)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
hayesgm committed Jan 16, 2020
1 parent bfc2914 commit e3bd593
Show file tree
Hide file tree
Showing 138 changed files with 9,646 additions and 9,572 deletions.
114 changes: 61 additions & 53 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,14 @@ jobs:
keys:
- v2-scenario/dependencies-{{ checksum "scenario/package.json" }}
- v2-scenario/dependencies-
- restore_cache:
keys:
- v2-solcache
- restore_cache:
keys:
- v2-scencache
- run: yarn install
- run: cd scenario && yarn install
- run:
name: Ganache
command: script/ganache
background: true
- run: |
while ! nc -z localhost 8545; do
sleep 0.1 # wait for ganache to start
done
- save_cache:
paths:
- node_modules
Expand All @@ -43,50 +41,47 @@ jobs:
- attach_workspace:
at: ~/repo
- run: mkdir ~/junit
- run: MOCHA_FILE=~/junit/test-results.xml script/test
- run: ./script/build_scenarios
- run:
shell: /bin/bash -eox pipefail -O globstar
name: yarn test
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)
- save_cache:
paths:
- .build
- .solcache
key: v2-solcache
- save_cache:
paths:
- scenario/.tsbuilt
- .scencache
key: v2-scencache
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/junit
parallelism: 4
parallelism: 3
resource_class: large

mocha_coverage:
parallelism: 5
verify:
docker:
- image: circleci/node:11
- image: compoundfinance/alpine-java-z3:latest
working_directory: ~/repo
steps:
- checkout
- restore_cache:
keys:
- v2-dependencies-{{ checksum "package.json" }}
- v2-dependencies-
- run: yarn install
- save_cache:
paths:
- node_modules
key: v2-dependencies-{{ checksum "package.json" }}
- attach_workspace:
at: ~/repo
- run:
command: yarn run coverage mocha
no_output_timeout: 20m
- store_artifacts:
path: ~/repo/coverage.json
destination: coverage.json
- store_artifacts:
path: ~/repo/coverage
destination: coverage
- codecov/upload
- run: script/verify
parallelism: 2

scenario_coverage:
coverage:
docker:
- image: circleci/node:11
working_directory: ~/repo
steps:
- run:
|
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.8/solc-static-linux -O /usr/local/bin/solc
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.12/solc-static-linux -O /usr/local/bin/solc
sudo chmod +x /usr/local/bin/solc
- checkout
- restore_cache:
Expand All @@ -97,10 +92,12 @@ jobs:
keys:
- v2-scenario/dependencies-{{ checksum "scenario/package.json" }}
- v2-scenario/dependencies-
- run:
|
sudo wget https://github.com/ethereum/solidity/releases/download/v0.5.12/solc-static-linux -O /usr/local/bin/solc
sudo chmod +x /usr/local/bin/solc
- restore_cache:
keys:
- v2-solcache
- restore_cache:
keys:
- v2-scencache
- run: yarn install
- run: cd scenario && yarn install
- save_cache:
Expand All @@ -113,21 +110,38 @@ jobs:
key: v2-scenario-dependencies-{{ checksum "scenario/package.json" }}
- attach_workspace:
at: ~/repo
- run: mkdir ~/junit
- run: ./script/build_scenarios
- run:
command: yarn run coverage scenario
no_output_timeout: 20m
shell: /bin/bash -eox pipefail -O globstar
name: yarn test
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
- save_cache:
paths:
- .build
- .solcachecov
key: v2-solcache
- save_cache:
paths:
- scenario/.tsbuilt
- .scencache
key: v2-scencache
- store_test_results:
path: ~/junit
- store_artifacts:
path: ~/repo/coverage.json
destination: coverage.json
path: ~/repo/coverage/coverage-final.json
destination: coverage-final.json
- store_artifacts:
path: ~/repo/coverage
path: ~/repo/coverage/lcov-report
destination: coverage
- codecov/upload
- codecov/upload:
file: ~/repo/coverage/coverage-final.json
parallelism: 10
resource_class: large

lint:
docker:
- image: circleci/node:11
- image: trufflesuite/ganache-cli:v6.7.0
working_directory: ~/repo
steps:
- checkout
Expand All @@ -149,12 +163,6 @@ workflows:
build-test-and-deploy:
jobs:
- test
- mocha_coverage:
filters:
branches:
only: /^(master|(.*-cov(er(age)?)?))$/
- scenario_coverage:
filters:
branches:
only: /^(master|(.*-cov(er(age)?)?))$/
- coverage
- lint
- verify
9 changes: 8 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,4 +26,11 @@ scTopics
test-results.xml
.tsbuilt
yarn-error.log
scenario/build/webpack.js
scenario/build/webpack.js
.scencache
.solcache
.solcachecov
scenario/.tscache
tests/scenarios/
junit.xml
.build
12 changes: 0 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,18 +107,6 @@ Deployment

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

# run ganache locally
script/ganache # or `ganache-cli`

# ensure development files don't exist as
# new ganache instances invalidate old deployed contracts
rm networks/development*

# run deployment script
yarn run deploy -v

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).

Testing
-------
Mocha contract tests are defined under the [test directory](https://github.com/compound-finance/compound-protocol/tree/master/test). To run the tests run:
Expand Down
188 changes: 188 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,188 @@
// For a detailed explanation regarding each configuration property, visit:
// https://jestjs.io/docs/en/configuration.html

module.exports = {
// All imported modules in your tests should be mocked automatically
// automock: false,

// Stop running tests after `n` failures
// bail: 0,

// Respect "browser" field in package.json when resolving modules
// browser: false,

// The directory where Jest should store its cached dependency information
// cacheDirectory: "/private/var/folders/jz/z56b1n2902584b4zplqztm3m0000gn/T/jest_dx",

// Automatically clear mock calls and instances between every test
// clearMocks: false,

// Indicates whether the coverage information should be collected while executing the test
// collectCoverage: false,

// An array of glob patterns indicating a set of files for which coverage information should be collected
// collectCoverageFrom: null,

// The directory where Jest should output its coverage files
// coverageDirectory: null,

// An array of regexp pattern strings used to skip coverage collection
// coveragePathIgnorePatterns: [
// "/node_modules/"
// ],

// A list of reporter names that Jest uses when writing coverage reports
// coverageReporters: [
// "json",
// "text",
// "lcov",
// "clover"
// ],

// An object that configures minimum threshold enforcement for coverage results
// coverageThreshold: null,

// A path to a custom dependency extractor
// dependencyExtractor: null,

// Make calling deprecated APIs throw helpful error messages
// errorOnDeprecated: false,

// Force coverage collection from ignored files using an array of glob patterns
// forceCoverageMatch: [],

// A path to a module which exports an async function that is triggered once before all test suites
// globalSetup: null,

// A path to a module which exports an async function that is triggered once after all test suites
// globalTeardown: null,

// A set of global variables that need to be available in all test environments
// globals: {},

// An array of directory names to be searched recursively up from the requiring module's location
// moduleDirectories: [
// "node_modules"
// ],

// An array of file extensions your modules use
// moduleFileExtensions: [
// "js",
// "json",
// "jsx",
// "ts",
// "tsx",
// "node"
// ],

// A map from regular expressions to module names that allow to stub out resources with a single module
// moduleNameMapper: {},

// An array of regexp pattern strings, matched against all module paths before considered 'visible' to the module loader
// modulePathIgnorePatterns: [],

// Activates notifications for test results
// notify: false,

// An enum that specifies notification mode. Requires { notify: true }
// notifyMode: "failure-change",

// A preset that is used as a base for Jest's configuration
// preset: null,

// Run tests from one or more projects
// projects: null,

// Use this configuration option to add custom reporters to Jest
reporters: ["default", "jest-junit"],

// Automatically reset mock state between every test
// resetMocks: false,

// Reset the module registry before running each individual test
// resetModules: false,

// A path to a custom resolver
// resolver: null,

// Automatically restore mock state between every test
// restoreMocks: false,

// The root directory that Jest should scan for tests and modules within
// rootDir: null,

// A list of paths to directories that Jest should use to search for files in
// roots: [
// "<rootDir>"
// ],

// Allows you to use a custom runner instead of Jest's default test runner
// runner: "jest-runner",

// The paths to modules that run some code to configure or set up the testing environment before each test
// setupFiles: [],

// A list of paths to modules that run some code to configure or set up the testing framework before each test
setupFilesAfterEnv: [
"<rootDir>/tests/Matchers.js",
"<rootDir>/tests/Jest.js"
],

// A list of paths to snapshot serializer modules Jest should use for snapshot testing
// snapshotSerializers: [],

// The test environment that will be used for testing
testEnvironment: "node",

// Options that will be passed to the testEnvironment
// testEnvironmentOptions: {},

// Adds a location field to test results
// testLocationInResults: false,

// The glob patterns Jest uses to detect test files
// testMatch: [
// "**/__tests__/**/*.[jt]s?(x)",
// "**/?(*.)+(spec|test).[tj]s?(x)"
// ],

// An array of regexp pattern strings that are matched against all test paths, matched tests are skipped
// testPathIgnorePatterns: [
// "/node_modules/"
// ],

// The regexp pattern or array of patterns that Jest uses to detect test files
// testRegex: [],

// This option allows the use of a custom results processor
// testResultsProcessor: null,

// This option allows use of a custom test runner
// testRunner: "jasmine2",

// This option sets the URL for the jsdom environment. It is reflected in properties such as location.href
// testURL: "http://localhost",

// Setting this value to "fake" allows the use of fake timers for functions such as "setTimeout"
// timers: "real",

// A map from regular expressions to paths to transformers
// transform: null,

// An array of regexp pattern strings that are matched against all source file paths, matched files will skip transformation
// transformIgnorePatterns: [
// "/node_modules/"
// ],

// An array of regexp pattern strings that are matched against all modules before the module loader will automatically return a mock for them
// unmockedModulePathPatterns: undefined,

// Indicates whether each individual test should be reported during the run
// verbose: null,

// An array of regexp patterns that are matched against all source file paths before re-running tests in watch mode
// watchPathIgnorePatterns: [],

// Whether to use watchman for file crawling
// watchman: true,
};
Loading

0 comments on commit e3bd593

Please sign in to comment.