Skip to content

Commit

Permalink
test: propose and vote with gov4
Browse files Browse the repository at this point in the history
  • Loading branch information
rabi-siddique committed Oct 16, 2024
1 parent 7b748a5 commit 2d97a5c
Show file tree
Hide file tree
Showing 3 changed files with 154 additions and 3 deletions.
148 changes: 145 additions & 3 deletions tests/e2e/specs/proposal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,14 @@ import { phrasesList, getTimeUntilVoteClose, DEFAULT_TIMEOUT } from '../utils';

describe('Make Proposal Tests', () => {
let startTime;
const networkPhrases = phrasesList[Cypress.env('AGORIC_NET') || 'local'];
const AGORIC_NET = Cypress.env('AGORIC_NET') || 'local';
const networkPhrases = phrasesList[AGORIC_NET];
const txRetryCount = 2;

context('PSM tests', () => {
it('should setup two econ committee member wallets', () => {
cy.task('info', `${AGORIC_NET}`);

cy.setupWallet({
secretWords: networkPhrases.gov1Phrase,
walletName: 'gov1',
Expand All @@ -16,6 +19,12 @@ describe('Make Proposal Tests', () => {
secretWords: networkPhrases.gov2Phrase,
walletName: 'gov2',
});
if (AGORIC_NET !== 'local') {
cy.setupWallet({
secretWords: networkPhrases.gov4Phrase,
walletName: 'gov4',
});
}
});

it('should connect to wallet', () => {
Expand Down Expand Up @@ -54,7 +63,11 @@ describe('Make Proposal Tests', () => {
cy.acceptAccess();
});

it('should allow gov1 to create a proposal', () => {
it('should allow gov2 to create a proposal', () => {
if (AGORIC_NET !== 'local') {
cy.switchWallet('gov2');
}
cy.reload();
// open PSM and select token
cy.get('button').contains('PSM').click();
cy.get('button').contains('AUSD').click();
Expand All @@ -78,7 +91,7 @@ describe('Make Proposal Tests', () => {
});

it(
'should confirm transaction for gov1 to create a proposal',
'should confirm transaction for gov2 to create a proposal',
{
retries: {
runMode: txRetryCount,
Expand Down Expand Up @@ -290,4 +303,133 @@ describe('Make Proposal Tests', () => {
});
});
});

context('Gov4 tests', () => {
it('should allow gov4 to create a proposal', () => {
cy.skipWhen(AGORIC_NET === 'local');

cy.switchWallet('gov4');
cy.visit(`/?agoricNet=${networkPhrases.network}`);

// open Values and select manager 0
cy.get('button').contains('Vaults').click();
cy.get('button').contains('Select Manager').click();
cy.get('button').contains('manager0').click();

// Change debt limit and proposal time to 1 min
cy.get('label')
.contains('DebtLimit')
.parent()
.within(() => {
cy.get('input').spread(element => {
cy.get('input').clear().type(element.value);
});
});
cy.get('label')
.contains('Minutes until close of vote')
.parent()
.within(() => {
cy.get('input').clear().type(networkPhrases.minutes);
});
});

it(
'should confirm transaction for gov4 to create a proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
cy.skipWhen(AGORIC_NET === 'local');
cy.get('[value="Propose Parameter Change"]').click();

// Submit proposal and wait for confirmation
cy.confirmTransaction();
cy.get('p')
.contains('sent', { timeout: DEFAULT_TIMEOUT })
.should('be.visible')
.then(() => {
startTime = Date.now();
});
},
);

it('should allow gov4 to vote on the proposal', () => {
cy.skipWhen(AGORIC_NET === 'local');
cy.visit(`/?agoricNet=${networkPhrases.network}`);

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
});

it(
'should confirm transaction for gov4 to vote on the proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
cy.skipWhen(AGORIC_NET === 'local');
cy.get('input:enabled[value="Submit Vote"]').click();

// Wait for vote to confirm
cy.confirmTransaction();
cy.get('p')
.contains('sent', { timeout: DEFAULT_TIMEOUT })
.should('be.visible');
},
);

it('should allow gov2 to vote on the proposal', () => {
cy.skipWhen(AGORIC_NET === 'local');
cy.switchWallet('gov2');
cy.visit(`/?agoricNet=${networkPhrases.network}`);

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
});

it(
'should confirm transaction for gov2 to vote on the proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
cy.skipWhen(AGORIC_NET === 'local');
cy.get('input:enabled[value="Submit Vote"]').click();

// Wait for vote to confirm
cy.confirmTransaction();
cy.get('p')
.contains('sent', { timeout: DEFAULT_TIMEOUT })
.should('be.visible');
},
);

it('should wait for proposal to pass', () => {
cy.skipWhen(AGORIC_NET === 'local');
// Wait for 1 minute to pass
cy.wait(getTimeUntilVoteClose(startTime, networkPhrases.minutes));
cy.visit(`/?agoricNet=${networkPhrases.network}`);

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

// Select the first element proposal containing ATOM and check
// its status should be accepted
cy.get('code')
.contains('VaultFactory - ATOM')
.parent()
.parent()
.parent()
.within(() => {
cy.get('span').contains('Change Accepted').should('be.visible');
});
});
});
});
6 changes: 6 additions & 0 deletions tests/e2e/support.js
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
import '@agoric/synpress/support/index';

Cypress.Commands.add('skipWhen', function (expression) {
if (expression) {
this.skip();
}
});
3 changes: 3 additions & 0 deletions tests/e2e/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ export const phrasesList = {
networkConfigURL: 'https://emerynet.agoric.net/network-config',
gov1Phrase: Cypress.env('GOV1_PHRASE'),
gov2Phrase: Cypress.env('GOV2_PHRASE'),
gov4Phrase: Cypress.env('GOV4_PHRASE'),
},
devnet: {
isLocal: false,
Expand All @@ -18,6 +19,7 @@ export const phrasesList = {
networkConfigURL: 'https://devnet.agoric.net/network-config',
gov1Phrase: Cypress.env('GOV1_PHRASE'),
gov2Phrase: Cypress.env('GOV2_PHRASE'),
gov4Phrase: Cypress.env('GOV4_PHRASE'),
},
xnet: {
isLocal: false,
Expand All @@ -27,6 +29,7 @@ export const phrasesList = {
networkConfigURL: 'https://xnet.agoric.net/network-config',
gov1Phrase: Cypress.env('GOV1_PHRASE'),
gov2Phrase: Cypress.env('GOV2_PHRASE'),
gov4Phrase: Cypress.env('GOV4_PHRASE'),
},
local: {
isLocal: true,
Expand Down

0 comments on commit 2d97a5c

Please sign in to comment.