livepeer / livepeer/protocol

Create global chai setup

Open
#572 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
155
Forks
50
PR merge metrics
No merged PRs in 30d

Description

**Context**
Currently `chai` is directly imported on each test file, where it is then attached to the ethereum-waffle's `solidity` chai matcher (i.e.: [here](https://github.com/livepeer/protocol/blob/confluence/test/unit/Governor.js#L8-L9)). Furthermore, there are occurrences where it uses different assertion styles (i.e.: [here](
https://github.com/livepeer/protocol/blob/confluence/test/unit/Governor.js#L7) and [here](https://github.com/livepeer/protocol/blob/confluence/test/integration/PoolUpdatesWithHints.js#L125)).

**TODO**
- Create a global chai setup in its own separate file
- Replace `ethereum-waffle` with `chai-ethers`: the `ethereum-waffle` library is much broader in its scope than chai-ethers which, similarly to ethereum-waffle's solidity, only provides chai matchers to deal with ethereum testing. Removing `ethereum-waffle` will prevent potential misuse in the future should anyone use it for anything else other than attaching its matchers to chai.
- Enforce a consistent assertion style: since it seems that the most used construct is `expect`, we should remove all the occurrences of `assert`
- add [expectThrow](https://github.com/livepeer/protocol/blob/confluence/test/helpers/expectThrow.js) and [expectFail](https://github.com/livepeer/protocol/blob/confluence/test/helpers/expectFail.js) as custom assertions in the custom chai setup

Related to https://github.com/livepeer/protocol/issues/566

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the Chai imports and assertions in test/unit/Governor.js and test/integration/PoolUpdatesWithHints.js, then inspect test/helpers/expectThrow.js and test/helpers/expectFail.js. Create the separate global setup, migrate the matcher dependency and assertion usage, and verify that the existing test suite still passes with the custom assertions available globally.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, solidity
Domain
testing
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.