ethers.js/tests
2020-01-03 18:20:15 -05:00
..
dist Added shims for React-Native support. 2018-11-08 18:25:16 -05:00
make-tests Allow Secret Storage wallet address to be optional (#582). 2019-08-22 15:22:20 -04:00
shims Fixed PhantomJS test cases for new elliptic library. 2019-11-24 20:56:28 +09:00
tests Allow Secret Storage wallet address to be optional (#582). 2019-08-22 15:22:20 -04:00
wordlist-generation Added French and Spanish BIP-39 wordlists (#191). 2018-10-03 19:58:45 -04:00
.gitignore Major version update; some changes are not backwards compatible. This package has been merged into one package instead of an umbrella pacakge. (See: #95) 2018-03-04 19:31:09 -05:00
.npmignore Major version update; some changes are not backwards compatible. This package has been merged into one package instead of an umbrella pacakge. (See: #95) 2018-03-04 19:31:09 -05:00
browser.js Updated test suite utils. 2018-07-23 03:02:39 -04:00
deploy-test-contract.js Moved contract tests to Rinkeby. 2018-06-05 19:19:40 -04:00
local-tests.js Fixed and refactored populating transaction values for signers (#306). 2018-10-14 19:00:15 -04:00
README.md Update README.md 2019-10-14 01:25:55 +09:00
reporter.js Fixed PhantomJS test cases for new elliptic library. 2019-11-24 20:56:28 +09:00
run-providers.js Added names for nested tuples and fixed topics (now optional) for event parsing. 2017-11-21 19:24:44 -05:00
run-testrpc.js Less strict parsing for loose providers. 2017-10-27 17:03:26 -04:00
sandbox.html Added sandbox test HTML file for debugging and testing. 2018-06-21 21:01:52 -04:00
test-account.js Added utility function to compute CREATE2 addresses (#697). 2020-01-03 18:20:15 -05:00
test-build.js Increased timeout for querying npm registry. 2018-10-03 20:08:01 -04:00
test-contract-interface.js Added proper support for v0.6 Solidity JSON type (#688). 2019-12-21 01:03:05 -05:00
test-contract.js Updated dist files. 2018-09-24 16:07:14 -04:00
test-contract.json Moved contract tests to Rinkeby. 2018-06-05 19:19:40 -04:00
test-contract.sol Major version update; some changes are not backwards compatible. This package has been merged into one package instead of an umbrella pacakge. (See: #95) 2018-03-04 19:31:09 -05:00
test-hdnode.js Reduce number of HDNode tests which cause TravisCI to timeout. 2019-07-09 20:16:37 -04:00
test-providers.js Added goerli to InfuraProvider (#421). 2019-03-08 14:28:39 -05:00
test-utils.js Fixed utils test case for phantomjs. 2019-02-08 19:52:29 -05:00
test-wallet.js Allow Secret Storage wallet address to be optional (#582). 2019-08-22 15:22:20 -04:00
test-wordlists.js Added French and Spanish BIP-39 wordlists (#191). 2018-10-03 19:58:45 -04:00
test.html Fixed PhantomJS test cases for new elliptic library. 2019-11-24 20:56:28 +09:00
utils-ethers-browser.js Type in console.log for tests. 2018-07-23 05:38:27 -04:00
utils-ethers.js Fixed PhantomJS test cases for new elliptic library. 2019-11-24 20:56:28 +09:00
utils.js Change Buffer constructor to safer operations (#265). 2018-09-04 10:20:31 -04:00

Ethers Test Suite

There are a lot of test cases, and it can take a while for them to all run.

Please be patient.

Running Tests

Node.js:

# Test everything (in node)
/Users/ricmoo/ethers.js> npm test

# Test everything (in phantomjs)
/Users/ricmoo/ethers.js> npm run-script test-phantomjs


# Test just one specific package

# Test the Solidity ABI coder
# - See tests/contract-interface.json.gz
/Users/ricmoo/ethers.js> ./node_modules/.bin/mocha test-contract-interface.js

# Test HD Wallet derivations
# - See tests/hdnode.json.gz
/Users/ricmoo/ethers.js> ./node_modules/.bin/mocha test-hdnode.js

# Test general utilities
# - See tests/namehash.json.gz
# - See tests/rlp-coder.json.gz
# - See tests/units.json.gz
/Users/ricmoo/ethers.js> ./node_modules/.bin/mocha test-utils.js

# Test accounts and addresses
# - See tests/accounts.json.gz
/Users/ricmoo/ethers.js> ./node_modules/.bin/mocha test-account.js

# Test encrypting/decrypting JSON wallets and transaction parsing/signing
# - See tests/transactions.json.gz
# - See tests/wallets.json.gz
/Users/ricmoo/ethers.js> ./node_modules/.bin/mocha test-wallet.js

Test Cases

The testcases take up a large amount of space, so they are gzipped in the /tests/tests/ folder. See /tests/utils.js for saving and loading.

To dump a test case from the terminal, you can use:

/Users/ricmoo/ethers.js> cat ./tests/accounts.json.gz | gunzip

Building Testcases

Each suite of testcases is produced from a variety of sources. Many include a specific set of test vectors as well as procedurally generated tests using known correct implementations.

The contract-interface test cases are created by selecting a (deterministically) random set of types and values, a solidity contract is then created to represent a contract with the correct return types and values, which is then compiled and deployed to a local Ethereum node, then executed once mined.

As a result, genearting the test cases can take quite some time. So, they are generated using a separate set of files found in make-tests.

  • make-accounts
  • make-contract-interface
  • make-hdnode
  • makr-rlpcoder
  • make-transaction
  • make-wallets

Additional Test Vectors:

  • make-tests/test-mnemonics -- The trezor test vectors for BIP39
  • make-tests/test-wallets -- Sample JSON Wallets (crowdsale and Geth)

All generated JSON test files are then placed gzipped in tests with the extension '.json.gz'.

Adding Test Cases

For any patch, feature upgrade or pull request of any sort, there must be relevant test cases added and all test cases must pass.

If you report a bug and provide test cases, it will get attention sooner.