Skip to content

Commit bbe00f6

Browse files
authored
Merge pull request #881 from makerdao/hardhat-removal
Hardhat, cypress, and more goerli removal
2 parents 17c322a + 9b1992c commit bbe00f6

Some content is hidden

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

69 files changed

+123
-6655
lines changed

.env.sample

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ INFURA_KEY=
44
ALCHEMY_KEY=
55
ETHERSCAN_KEY=
66
POCKET_KEY=
7-
GOERLI_FORK_API_KEY=
87
GITHUB_TOKEN=
98
MONGODB_URI=
109
MONGODB_COMMENTS_DB=

.eslintrc

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
"plugin:react/recommended",
1212
"plugin:@typescript-eslint/recommended",
1313
"plugin:jest-dom/recommended",
14-
"plugin:cypress/recommended"
1514
],
1615
"globals": {
1716
"cy": true

.github/workflows/e2e.yml

Lines changed: 0 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +0,0 @@
1-
name: E2E Tests
2-
3-
on:
4-
push:
5-
branches:
6-
- master
7-
- develop
8-
pull_request:
9-
# Sequence of patterns matched against refs/heads
10-
branches:
11-
- master
12-
- develop
13-
jobs:
14-
ui-chrome-tests:
15-
runs-on: ubuntu-latest
16-
container: cypress/browsers:node16.18.0-chrome107-ff106-edge
17-
strategy:
18-
fail-fast: false
19-
env:
20-
INFURA_KEY: ${{ secrets.INFURA_KEY }}
21-
MONGODB_COMMENTS_DB: ${{ secrets.MONGODB_COMMENTS_DB }}
22-
MONGODB_URI: ${{ secrets.MONGODB_URI }}
23-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
24-
GOERLI_FORK_API_KEY: ${{ secrets.GOERLI_FORK_API_KEY }}
25-
ETHERSCAN_KEY: ${{ secrets.ETHERSCAN_KEY }}
26-
POCKET_KEY: ${{ secrets.POCKET_KEY }}
27-
ALCHEMY_KEY: ${{ secrets.ALCHEMY_KEY }}
28-
REDIS_URL: ${{ secrets.REDIS_URL }}
29-
USE_CACHE: true
30-
31-
steps:
32-
- name: Checkout
33-
uses: actions/checkout@v3
34-
35-
- name: Install node packages
36-
run: yarn
37-
38-
## Download prebuilt next data
39-
# - name: Download the build folders
40-
# uses: actions/download-artifact@v2
41-
# with:
42-
# name: build
43-
44-
- name: 'UI Tests - Chrome'
45-
uses: cypress-io/github-action@v3
46-
with:
47-
# we have already installed all dependencies above
48-
# use (install: false) if you want to do parallel jobs.
49-
install: false
50-
start: yarn start:ci
51-
## command: yarn run e2e:ci
52-
wait-on: 'http://localhost:3000'
53-
wait-on-timeout: 120
54-
browser: chrome
55-
record: true
56-
parallel: false
57-
group: 'UI - Chrome'
58-
spec: cypress/integration/**
59-
env:
60-
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
61-
# Recommended: pass the GitHub token lets this action correctly
62-
# determine the unique run id necessary to re-run the checks
63-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
64-
65-
- name: Codecov
66-
run: |
67-
yarn add --dev codecov
68-
./node_modules/.bin/codecov -f combined-coverage/lcov.info

README.md

Lines changed: 2 additions & 102 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ The following configuration values can be added to the `.env` file:
115115

116116
#### Optional (DUX-specific config, no performance improvements):
117117

118-
- Set `GOERLI_FORK_API_KEY` to a valid [Infura](https://docs.infura.io/infura/networks/ethereum/how-to/secure-a-project/project-id) API key for Hardhat to use during e2e testing
119-
120118
- Set `MIGRATION_WEBHOOK_URL` for sending migration requests to discord
121119

122120
- Set `GASLESS_WEBHOOK_URL` for sending gasless vote requests to discord
@@ -135,9 +133,9 @@ The following configuration values can be added to the `.env` file:
135133

136134
### Tests
137135

138-
The Governance portal includes two test suites: Jest and Cypress
136+
The Governance portal includes two test suites: Jest and E2E (TODO)
139137

140-
Jest tests under the folder `__tests__` currently execute unit tests of the platform. The e2e Cypress tests are under the `cypress` folder.
138+
Jest tests under the folder `__tests__` currently execute unit tests of the platform.
141139

142140
#### Test commands
143141

@@ -151,100 +149,6 @@ npm run test
151149
npm run test:ci
152150
```
153151

154-
Cypress:
155-
156-
```bash
157-
# opens a cypress browser for the e2e
158-
npm run e2e
159-
160-
# runs e2e tests in a headless manner, for CI systems
161-
npm run e2e:headless
162-
```
163-
164-
#### Goerli fork
165-
166-
By default, e2e tests run on a fork of Goerli. We do this because the governance contracts are deployed in Goerli for testing purposes. We also need to start the governance polling database services in a docker container so that the database and the forked chains are in sync. Please follow these steps:
167-
168-
1. First we want to spin up our networks: the forked Goerli and the forked Arbitrum Testnet (for testing gasless voting). The following command will start the two networks on ports 8545 and 8546 respectively.
169-
170-
```bash
171-
npm run hardhat:gasless:config
172-
```
173-
174-
2. When you see the accounts & keys displayed in the terminal, you can now start the dockerized database services. You may need to pull down the latest images from docker if you don't have them. In a new terminal window type these two commands:
175-
176-
```bash
177-
docker-compose pull
178-
179-
docker-compose up
180-
```
181-
182-
This will download two images, the first is a pre-seeded postgres database containing all the data you need to get started. The second one contains the API and ETL services required to work with our tests. This allows the test database to listen for events on the testchain, and return the requested data to the frontend, just as it is done in production. Wait a few minutes for the images to download and the services to start. When you see the following message displayed it means the services are ready and you can proceed to the next step:
183-
184-
`"Running a GraphQL API server at http://localhost:3001"`
185-
186-
Note: when you're finished running tests, you can remove the docker images by running `docker-compose down`. This will reset the database to its original state the next time you run the tests.
187-
188-
3. Now that our testchains and our database services are running, we can start the e2e tests. Run the following command in yet another new terminal window to start cypress:
189-
190-
```
191-
npm run e2e
192-
```
193-
194-
Note: Make sure to fill in the `GOERLI_FORK_API_KEY` environment variable.
195-
196-
You can use this local network from MetaMask, by switching to the "localhost:8545" network, with chain ID: `31337`. In order to get a wallet with some MKR and ETH you can run the script: `npm run fund` that will send some MKR and ETH to the first 50 wallets under the `/cypress/support/constants/keypairs.json`.
197-
198-
For more information about the fund process, take a look at `/scripts/setup.js`
199-
200-
**Writing e2e**:
201-
202-
Please refer to: https://docs.cypress.io/guides/references/best-practices and check current test examples under the cypress folder.
203-
204-
At the beginning of each test or describe-block, we run two commands to fork the hardhat networks & reset the database. This ensures that the tests are run from a clean slate and using the same blockchain and database state beforehand. Add the functions into a `before` or `beforeEach` block like this:
205-
206-
```js
207-
before(() => {
208-
forkNetwork(); // Restarts the blockchain & re-funds all the accounts
209-
resetDatabase(); // Wipes the db and starts over from its initial state
210-
});
211-
```
212-
213-
**Windows support**
214-
215-
If you are using Windows and WSL you will need to install XLaunch to be able to launch a client for the UI, remember to disable access control.
216-
217-
#### Adding Data to the DB for Tests
218-
219-
The docker image of the gov polling db starts out with a very minimal amount of data (to conserve space), but you may require some extra data for tests. For example, you may want to add some additional polls, or add some delegates. Most of the tables in the DB have primary key constraints to other tables, which makes manually adding data via an `UPDATE` query time consuming and unstable. The easiest way to add data in a safe way is to have the gov polling db add this data on its own, the way it's done in production. The process works like this:
220-
221-
1. Spock adds block information (number & hash) to a row in a database.
222-
2. Spock extracts the transactions from the block and scans these for specific events.
223-
3. If an event is found, the corresponding event transformer is run to handle the event data, inserting the data into tables.
224-
225-
So, if we want to add a specific poll, first we locate the block in which the event was emitted (use Etherscan). We add the blocknumber to the list of blocknumbers in the `docker-compose.yml` file. Adding it to the `SEED_BLOCKS` environmental var (see example below).
226-
227-
```yml
228-
spock:
229-
image: makerdaodux/govpolldb-app:latest
230-
container_name: spock-test-container
231-
command: ['yarn', 'start-all']
232-
environment:
233-
- SEED_BLOCKS=5815619,6495082
234-
depends_on:
235-
postgres:
236-
condition: service_healthy
237-
ports: - '3001:3001'
238-
```
239-
240-
Now, when the docker image is started or restarted, spock looks for the environmental variable and parses the block numbers that have been added. It then runs the process described above on each block, adding any events it finds to the respective tables.
241-
242-
NB: This data will not be persisted in the docker image when the image is shut down using the `docker-compose stop` command, but it will be recreated every time the ETL service is restarted, as long as it remains part of the `SEED_BLOCKS` env var.
243-
244-
**Future Enhancements:**
245-
246-
In time, this list of blocks will grow too large to maintain in this file. We can either permanently update the image with the data from these blocks, or move this list to an external file and load it into the env var that way.
247-
248152
### CI/CD
249153

250154
The CI/CD system is integrated with Github Actions.
@@ -255,14 +159,10 @@ After each push the system will execute:
255159

256160
- Unit test, execute Jest test suite
257161

258-
- E2E, executy cypress test suite and record results at https://dashboard.cypress.io/projects/uckcr1/runs
259-
260162
```bash
261163
npm run start:ci
262164
```
263165

264-
The command `npm run start:ci` launches a detached process with hardhat, executes e2e in a headless mode and kills the hardhat process.
265-
266166
### Contributing
267167

268168
See our [contributing guide](./CONTRIBUTING.md).

cypress.config.ts

Lines changed: 0 additions & 26 deletions
This file was deleted.

cypress/e2e/account.spec.ts

Lines changed: 0 additions & 104 deletions
This file was deleted.

0 commit comments

Comments
 (0)