Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: adding tests for setting up governance params for liquidation flow and ci changes #156

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ ENV PATH="/usr/src/agoric-sdk/packages/agoric-cli/bin:${PATH}"
RUN apt-get update \
&& apt-get install -y wget gnupg ca-certificates jq expect xvfb


RUN apt update && apt install -y nginx
COPY test/e2e/nginx.conf /etc/nginx/sites-available/default

# Install Chrome
RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | apt-key add - \
&& sh -c 'echo "deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main" >> /etc/apt/sources.list.d/google-chrome.list' \
Expand Down
23 changes: 21 additions & 2 deletions test/e2e/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,14 @@ services:
- SECRET_WORDS="orbit bench unit task food shock brand bracket domain regular warfare company announce wheel grape trust sphere boy doctor half guard ritual three ecology"
depends_on:
- display
- agd
entrypoint: []
working_dir: /app
volumes:
- ./cypress/videos:/app/test/e2e/videos
- ./cypress/screenshots:/app/test/e2e/screenshots
command: >
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && yarn 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:ci'
bash -c 'echo -n "======> local noVNC URL: http://localhost:8080/vnc.html?autoconnect=true " && yarn wait-on http://display:8080 && echo -n "======> remote noVNC URL: " && curl -s ngrok:4040/api/tunnels | jq -r .tunnels[0].public_url && nginx && yarn test:e2e:ci'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This long line makes it hard to see changes. Consider a script with new lines

networks:
- x11

Expand Down Expand Up @@ -77,5 +78,23 @@ services:
networks:
- x11

agd:
profiles:
- synpress
container_name: agoric_chain
image: ghcr.io/agoric/agoric-3-proposals:latest
logging:
driver: none
platform: linux/amd64
ports:
- 26656:26656
- 26657:26657
- 1317:1317
environment:
DEST: 1
DEBUG: 'SwingSet:ls,SwingSet:vat'
networks:
- x11

networks:
x11:
x11:
39 changes: 39 additions & 0 deletions test/e2e/nginx.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
server {
listen 26656;
server_name localhost;

location / {
proxy_pass http://agoric_chain:26656;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}

server {
listen 26657;
server_name localhost;

location / {
proxy_pass http://agoric_chain:26657;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}


server {
listen 1317;
server_name localhost;

location / {
proxy_pass http://agoric_chain:1317;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
}
}
218 changes: 218 additions & 0 deletions test/e2e/specs/liquidation-happy-path.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
/* eslint-disable ui-testing/no-disabled-tests */
describe('Wallet App Test Cases', () => {
let startTime;

context('Setting up accounts', () => {
it('should set up wallets for two members of the econ committee.', () => {
cy.setupWallet({
secretWords:
'such field health riot cost kitten silly tube flash wrap festival portion imitate this make question host bitter puppy wait area glide soldier knee',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Magic string. Please source from constants in a config module

walletName: 'gov2',
});
cy.setupWallet({
secretWords:
'physical immune cargo feel crawl style fox require inhale law local glory cheese bring swear royal spy buyer diesel field when task spin alley',
walletName: 'gov1',
});
});

it('should connect with chain and wallet', () => {
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');
cy.acceptAccess();
});
});

context('Adjusting Vault Params', () => {
it('should allow gov1 to create a proposal', () => {
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider a const

cy.acceptAccess();

cy.get('button').contains('Vaults').click();
cy.get('button').contains('Select Manager').click();
cy.get('button').contains('manager0').click();

cy.get('label')
.contains('LiquidationMargin')
.parent()
.within(() => {
cy.get('input').clear().type('150');
});

cy.get('label')
.contains('LiquidationPadding')
.parent()
.within(() => {
cy.get('input').clear().type('25');
});

cy.get('label')
.contains('LiquidationPenalty')
.parent()
.within(() => {
cy.get('input').clear().type('1');
});

cy.get('label')
.contains('StabilityFee')
.parent()
.within(() => {
cy.get('input').clear().type('1');
});

cy.get('label')
.contains('MintFee')
.parent()
.within(() => {
cy.get('input').clear().type('0.5');
});

cy.get('label')
.contains('Minutes until close of vote')
.parent()
.within(() => {
cy.get('input').clear().type(1);
});
cy.get('[value="Propose Parameter Change"]').click();

cy.confirmTransaction();
cy.get('p')
.contains('sent')
.should('be.visible')
.then(() => {
startTime = Date.now();
});
});

it('should allow gov1 to vote on the proposal', () => {
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');

cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should allow gov2 to vote on the proposal', () => {
cy.switchWallet('gov2');
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');

cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should wait for proposal to pass', () => {
cy.wait(60000 - Date.now() + startTime);
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');

cy.get('button').contains('History').click();

cy.get('code')
.contains('VaultFactory - ATOM')
.parent()
.parent()
.parent()
.within(() => {
cy.get('span').contains('Change Accepted').should('be.visible');
});
});
});

context('Adjusting Auction Params', () => {
it('should allow gov2 to create a proposal', () => {
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');

cy.get('button').contains('Vaults').click();
cy.get('button').contains('Change Manager Params').click();
cy.get('button').contains('Change Auctioneer Params').click();

cy.get('label')
.contains('StartingRate')
.parent()
.within(() => {
cy.get('input').clear().type('105');
});

cy.get('label')
.contains('LowestRate')
.parent()
.within(() => {
cy.get('input').clear().type('65');
});

cy.get('label')
.contains('DiscountStep')
.parent()
.within(() => {
cy.get('input').clear().type('5');
});

cy.get('label')
.contains('AuctionStartDelay')
.parent()
.within(() => {
cy.get('input').clear().type('2');
});

cy.get('label')
.contains('Minutes until close of vote')
.parent()
.within(() => {
cy.get('input').clear().type(1);
});
cy.get('[value="Propose Parameter Change"]').click();

cy.confirmTransaction();
cy.get('p')
.contains('sent')
.should('be.visible')
.then(() => {
startTime = Date.now();
});
});

it('should allow gov2 to vote on the proposal', () => {
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');

cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should allow gov1 to vote on the proposal', () => {
cy.switchWallet('gov1');
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');

cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
cy.get('input:enabled[value="Submit Vote"]').click();

cy.confirmTransaction();
cy.get('p').contains('sent').should('be.visible');
});

it('should wait for proposal to pass', () => {
cy.wait(60000 - Date.now() + startTime);
cy.visit('https://econ-gov.inter.trade/?agoricNet=local');

cy.get('button').contains('History').click();

cy.get('code')
.contains('VaultFactory - ATOM')
.parent()
.parent()
.parent()
.within(() => {
cy.get('span').contains('Change Accepted').should('be.visible');
});
});
});
});
3 changes: 2 additions & 1 deletion test/e2e/specs/test.spec.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
/* eslint-disable ui-testing/no-disabled-tests */
describe('Wallet App Test Cases', () => {
context('Test commands', () => {
it(`should connect with Agoric Chain`, () => {
it(`should setup wallet and connect with Agoric Chain`, () => {
cy.setupWallet();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we dont have the SKIP_EXTENSION_SETUP flag enabled anywhere, wont this duplicate the setup of the wallet?

cy.visit('/');

cy.acceptAccess().then((taskCompleted) => {
Expand Down
2 changes: 1 addition & 1 deletion test/e2e/synpress.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ module.exports = defineConfig({
specPattern: 'test/e2e/specs/**/*spec.{js,jsx,ts,tsx}',
supportFile: 'test/support.js',
screenshotsFolder: 'test/e2e/screenshots',
videosFolder: 'test/e2e/videos'
videosFolder: 'test/e2e/videos',
},
});
2 changes: 1 addition & 1 deletion test/e2e/test-scripts/place-bid-by-discount.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
source ./test/e2e/test-scripts/common.sh

agops inter bid by-discount --discount 5 --give 2IST --from $accountAddress --keyring-backend=test 2>&1
wait
wait
2 changes: 1 addition & 1 deletion test/e2e/test-scripts/place-bid-by-price.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@
source ./test/e2e/test-scripts/common.sh

agops inter bid by-price --give 1IST --price 8.55 --from $accountAddress --keyring-backend=test 2>&1
wait
wait
2 changes: 1 addition & 1 deletion test/support.js
Original file line number Diff line number Diff line change
@@ -1 +1 @@
import '@agoric/synpress/support/index';
import '@agoric/synpress/support/commands';
Loading