Skip to content

Commit

Permalink
Merge pull request #552 from Synthetixio/anvil-int
Browse files Browse the repository at this point in the history
feat: use anvil for e2e testing
  • Loading branch information
drptbl authored Oct 29, 2022
2 parents 28fccc2 + 0404ea1 commit afaffdc
Show file tree
Hide file tree
Showing 5 changed files with 42 additions and 10 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/audit_and_lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ jobs:
${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

Expand All @@ -152,6 +153,7 @@ jobs:
${{ secrets.CYPRESS_PRIVATE_KEY_WITH_FUNDS }}
CYPRESS_PROJECT_ID: ${{ secrets.CYPRESS_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
ANVIL_FORK_URL: ${{ secrets.ANVIL_FORK_URL }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
continue-on-error: true

Expand Down
17 changes: 13 additions & 4 deletions docker-compose.ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ services:
bash -c 'echo -n "======> local noVNC URL:
http://localhost:8080/vnc.html?autoconnect=true " && npx wait-on
http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn test:e2e'
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn test:e2e:anvil'
networks:
- x11

display:
container_name: display
image: synthetixio/display:b2643097e891906524e52e7ee956260b20fa01fb-base
image: synthetixio/display:016121eafdfff448414894d0ca5a50b1d72b62eb-base
environment:
- RUN_XTERM=no
- DISPLAY_WIDTH=${DISPLAY_WIDTH}
Expand All @@ -43,7 +43,7 @@ services:
profiles:
- ngrok
container_name: ngrok
image: synthetixio/ngrok:b2643097e891906524e52e7ee956260b20fa01fb-base
image: synthetixio/ngrok:016121eafdfff448414894d0ca5a50b1d72b62eb-base
ports:
- '4040:4040'
command: ['ngrok', 'http', 'display:8080', '--authtoken', '${NGROK_AUTH}']
Expand All @@ -54,7 +54,7 @@ services:

video:
container_name: video
image: synthetixio/video:b2643097e891906524e52e7ee956260b20fa01fb-base
image: synthetixio/video:016121eafdfff448414894d0ca5a50b1d72b62eb-base
volumes:
- ./docker/videos-ci:/videos
environment:
Expand All @@ -66,5 +66,14 @@ services:
networks:
- x11

foundry:
container_name: foundry
image: synthetixio/foundry:016121eafdfff448414894d0ca5a50b1d72b62eb-base
command: ['anvil', '--fork-url', '${ANVIL_FORK_URL}']
ports:
- '8545:8545'
networks:
- x11

networks:
x11:
18 changes: 14 additions & 4 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
depends_on:
- display
- video
- foundry
entrypoint: []
working_dir: /app
volumes:
Expand All @@ -21,13 +22,13 @@ services:
bash -c 'echo -n "======> local noVNC URL:
http://localhost:8080/vnc.html?autoconnect=true " && npx wait-on
http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn test:e2e'
ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && yarn test:e2e:anvil'
networks:
- x11

display:
container_name: display
image: synthetixio/display:b2643097e891906524e52e7ee956260b20fa01fb-base
image: synthetixio/display:016121eafdfff448414894d0ca5a50b1d72b62eb-base
environment:
- RUN_XTERM=no
ports:
Expand All @@ -39,7 +40,7 @@ services:
profiles:
- ngrok
container_name: ngrok
image: synthetixio/ngrok:b2643097e891906524e52e7ee956260b20fa01fb-base
image: synthetixio/ngrok:016121eafdfff448414894d0ca5a50b1d72b62eb-base
ports:
- '4040:4040'
command: ['ngrok', 'http', 'display:8080', '--authtoken', '${NGROK_AUTH}']
Expand All @@ -50,7 +51,7 @@ services:

video:
container_name: video
image: synthetixio/video:b2643097e891906524e52e7ee956260b20fa01fb-base
image: synthetixio/video:016121eafdfff448414894d0ca5a50b1d72b62eb-base
volumes:
- ./docker/videos-ci:/videos
environment:
Expand All @@ -60,5 +61,14 @@ services:
networks:
- x11

foundry:
container_name: foundry
image: synthetixio/foundry:016121eafdfff448414894d0ca5a50b1d72b62eb-base
command: ['anvil', '--fork-url', '${ANVIL_FORK_URL}']
ports:
- '8545:8545'
networks:
- x11

networks:
x11:
4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,9 @@
"update:deps": "ncu -u -x 'node-fetch eslint' && yarn",
"start:server": "serve node_modules/@metamask/test-dapp/dist -p 3000",
"test:e2e": "start-server-and-test 'yarn start:server' http-get://localhost:3000 'SKIP_METAMASK_SETUP=true SYNPRESS_LOCAL_TEST=true node synpress.js run --configFile=synpress.config.js'",
"test:e2e:ci": "start-server-and-test 'yarn start:server' http-get://localhost:3000 'SKIP_METAMASK_SETUP=true SYNPRESS_LOCAL_TEST=true node synpress.js run --group smoke-tests --record'"
"test:e2e:ci": "start-server-and-test 'yarn start:server' http-get://localhost:3000 'SKIP_METAMASK_SETUP=true SYNPRESS_LOCAL_TEST=true node synpress.js run --group smoke-tests --record'",
"test:e2e:anvil": "start-server-and-test 'yarn start:server' http-get://localhost:3000 'SKIP_METAMASK_SETUP=true SYNPRESS_LOCAL_TEST=true CYPRESS_USE_ANVIL=true node synpress.js run --configFile=synpress.config.js'",
"test:e2e:ci:anvil": "start-server-and-test 'yarn start:server' http-get://localhost:3000 'SKIP_METAMASK_SETUP=true SYNPRESS_LOCAL_TEST=true CYPRESS_USE_ANVIL=true node synpress.js run --group smoke-tests --record'"
},
"dependencies": {
"@cypress/code-coverage": "^3.10.0",
Expand Down
11 changes: 10 additions & 1 deletion tests/e2e/specs/metamask-spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,16 @@ describe('Metamask', () => {
);
});
it(`rejectMetamaskTransaction should reject transaction`, () => {
cy.importMetamaskAccount(Cypress.env('PRIVATE_KEY_WITH_FUNDS'));
if (Cypress.env('USE_ANVIL')) {
cy.importMetamaskAccount(
// don't worry my friend, this is just first private key from:
// 'test test test test test test test test test test test junk'
'0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',
);
cy.changeMetamaskNetwork('localhost');
} else {
cy.importMetamaskAccount(Cypress.env('PRIVATE_KEY_WITH_FUNDS'));
}
cy.get('#requestPermissions').click();
cy.acceptMetamaskAccess();
cy.get('#createToken').click();
Expand Down

0 comments on commit afaffdc

Please sign in to comment.