Skip to content

Commit

Permalink
Merge pull request #133 from Agoric/fraz/retry-flaky-transactions
Browse files Browse the repository at this point in the history
test: add retries to flaky transactions in tests
  • Loading branch information
frazarshad authored Sep 25, 2024
2 parents 27af6eb + 550b2b9 commit 6f09752
Showing 1 changed file with 116 additions and 48 deletions.
164 changes: 116 additions & 48 deletions tests/e2e/specs/proposal.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { phrasesList, getTimeUntilVoteClose, DEFAULT_TIMEOUT } from '../utils';
describe('Make Proposal Tests', () => {
let startTime;
const networkPhrases = phrasesList[Cypress.env('AGORIC_NET') || 'local'];
const txRetryCount = 2;

context('PSM tests', () => {
it('should setup two econ committee member wallets', () => {
cy.setupWallet({
Expand Down Expand Up @@ -73,49 +75,82 @@ describe('Make Proposal Tests', () => {
.within(() => {
cy.get('input').clear().type(networkPhrases.minutes);
});
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 confirm transaction for gov1 to create a proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
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 gov2 to vote on the proposal', () => {
cy.visit(`/?agoricNet=${networkPhrases.network}`);

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
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 confirm transaction for gov2 to vote on the proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
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 gov1 to vote on the proposal', () => {
cy.switchWallet('gov1');
cy.visit(`/?agoricNet=${networkPhrases.network}`);

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
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 confirm transaction for gov1 to vote on the proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
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', () => {
// Wait for 1 minute to pass
cy.wait(getTimeUntilVoteClose(startTime, networkPhrases.minutes));
Expand Down Expand Up @@ -160,49 +195,82 @@ describe('Make Proposal Tests', () => {
.within(() => {
cy.get('input').clear().type(networkPhrases.minutes);
});
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 confirm transaction for gov1 to create a proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
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 gov1 to vote on the proposal', () => {
cy.visit(`/?agoricNet=${networkPhrases.network}`);

// Open vote, click on yes and submit
cy.get('button').contains('Vote').click();
cy.get('p').contains('YES').click();
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 confirm transaction for gov1 to vote on the proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
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.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();
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 confirm transaction for gov2 to vote on the proposal',
{
retries: {
runMode: txRetryCount,
},
},
() => {
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', () => {
// Wait for 1 minute to pass
cy.wait(getTimeUntilVoteClose(startTime, networkPhrases.minutes));
Expand Down

0 comments on commit 6f09752

Please sign in to comment.