From 550b2b9d878e1df7d610466bc002f4cd1a145e4e Mon Sep 17 00:00:00 2001 From: Fraz Arshad Date: Wed, 25 Sep 2024 12:18:09 +0500 Subject: [PATCH] test: add retries to flaky transactions in tests --- tests/e2e/specs/proposal.spec.js | 164 ++++++++++++++++++++++--------- 1 file changed, 116 insertions(+), 48 deletions(-) diff --git a/tests/e2e/specs/proposal.spec.js b/tests/e2e/specs/proposal.spec.js index a2933d6..8a5a2d4 100644 --- a/tests/e2e/specs/proposal.spec.js +++ b/tests/e2e/specs/proposal.spec.js @@ -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({ @@ -73,33 +75,55 @@ 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}`); @@ -107,15 +131,26 @@ describe('Make Proposal Tests', () => { // 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)); @@ -160,33 +195,55 @@ 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}`); @@ -194,15 +251,26 @@ describe('Make Proposal Tests', () => { // 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));