From 9377210a416c19d1a4fe5ea89fb131351502fbdb Mon Sep 17 00:00:00 2001 From: usmanmani1122 Date: Thu, 29 Aug 2024 23:25:26 +0500 Subject: [PATCH 1/3] poll on transaction status --- .github/workflows/e2e_tests.yml | 9 +------- tests/e2e/support.js | 38 ++++++++++++++++++++++++--------- 2 files changed, 29 insertions(+), 18 deletions(-) diff --git a/.github/workflows/e2e_tests.yml b/.github/workflows/e2e_tests.yml index ba2aaad..6645a38 100644 --- a/.github/workflows/e2e_tests.yml +++ b/.github/workflows/e2e_tests.yml @@ -41,14 +41,7 @@ jobs: runs-on: ubuntu-latest env: - NETWORK: >- - ${{ inputs.network - || contains(github.event.pull_request.labels.*.name, 'emerynet') && 'emerynet' - || contains(github.event.pull_request.labels.*.name, 'devnet') && 'devnet' - || contains(github.event.pull_request.labels.*.name, 'xnet') && 'xnet' - || github.event_name == 'schedule' && 'emerynet' - || 'local' - }} + NETWORK: usman steps: - name: Print network name diff --git a/tests/e2e/support.js b/tests/e2e/support.js index 1dc8f18..de7f386 100644 --- a/tests/e2e/support.js +++ b/tests/e2e/support.js @@ -1,24 +1,42 @@ import '@agoric/synpress/support/index'; -import { FACUET_HEADERS, phrasesList, DEFAULT_TIMEOUT } from './utils'; - -const networkPhrases = phrasesList[Cypress.env('AGORIC_NET')]; +import { FACUET_HEADERS } from './utils'; Cypress.Commands.add( 'provisionFromFaucet', (walletAddress, command, clientType) => { + const TRANSACTION_STATUS = { + FAILED: 1000, + NOT_FOUND: 1001, + SUCCESSFUL: 1002, + }; + + const getStatus = (txHash) => + cy + .request({ + method: 'GET', + url: `https://${Cypress.env('AGORIC_NET')}.faucet.agoric.net/api/transaction-status/${txHash}`, + }) + .then((resp) => { + const { transactionStatus } = resp.body; + if (transactionStatus === TRANSACTION_STATUS.NOT_FOUND) + // eslint-disable-next-line cypress/no-unnecessary-waiting + return cy.wait(2000).then(() => getStatus(txHash)); + else return cy.wrap(transactionStatus); + }); + cy.request({ - method: 'POST', - url: networkPhrases.faucetUrl, body: { address: walletAddress, command, clientType, }, + followRedirect: false, headers: FACUET_HEADERS, - timeout: 4 * DEFAULT_TIMEOUT, - retryOnStatusCodeFailure: true, - }).then(resp => { - expect(resp.body).to.eq('success'); - }); + method: 'POST', + url: `https://${Cypress.env('AGORIC_NET')}.faucet.agoric.net/go`, + }).then((resp) => + getStatus(/\/transaction-status\/(.*)/.exec(resp.headers.location)[1]), + ) + .then((status) => expect(status).to.eq(TRANSACTION_STATUS.SUCCESSFUL)); } ); From dfaf1eacc9d2d0d4dc495cfe8d01d9a2b7acea75 Mon Sep 17 00:00:00 2001 From: usmanmani1122 Date: Thu, 5 Sep 2024 14:37:24 +0500 Subject: [PATCH 2/3] revert --- .github/workflows/e2e_tests.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/e2e_tests.yml b/.github/workflows/e2e_tests.yml index 6645a38..ba2aaad 100644 --- a/.github/workflows/e2e_tests.yml +++ b/.github/workflows/e2e_tests.yml @@ -41,7 +41,14 @@ jobs: runs-on: ubuntu-latest env: - NETWORK: usman + NETWORK: >- + ${{ inputs.network + || contains(github.event.pull_request.labels.*.name, 'emerynet') && 'emerynet' + || contains(github.event.pull_request.labels.*.name, 'devnet') && 'devnet' + || contains(github.event.pull_request.labels.*.name, 'xnet') && 'xnet' + || github.event_name == 'schedule' && 'emerynet' + || 'local' + }} steps: - name: Print network name From 266b0999c4643129427be94d380cace17691c2d6 Mon Sep 17 00:00:00 2001 From: usmanmani1122 Date: Tue, 10 Sep 2024 18:13:37 +0500 Subject: [PATCH 3/3] prettier --- tests/e2e/support.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/e2e/support.js b/tests/e2e/support.js index de7f386..03a98f0 100644 --- a/tests/e2e/support.js +++ b/tests/e2e/support.js @@ -10,13 +10,15 @@ Cypress.Commands.add( SUCCESSFUL: 1002, }; - const getStatus = (txHash) => + const getStatus = txHash => cy .request({ method: 'GET', - url: `https://${Cypress.env('AGORIC_NET')}.faucet.agoric.net/api/transaction-status/${txHash}`, + url: `https://${Cypress.env( + 'AGORIC_NET' + )}.faucet.agoric.net/api/transaction-status/${txHash}`, }) - .then((resp) => { + .then(resp => { const { transactionStatus } = resp.body; if (transactionStatus === TRANSACTION_STATUS.NOT_FOUND) // eslint-disable-next-line cypress/no-unnecessary-waiting @@ -34,9 +36,10 @@ Cypress.Commands.add( headers: FACUET_HEADERS, method: 'POST', url: `https://${Cypress.env('AGORIC_NET')}.faucet.agoric.net/go`, - }).then((resp) => - getStatus(/\/transaction-status\/(.*)/.exec(resp.headers.location)[1]), - ) - .then((status) => expect(status).to.eq(TRANSACTION_STATUS.SUCCESSFUL)); + }) + .then(resp => + getStatus(/\/transaction-status\/(.*)/.exec(resp.headers.location)[1]) + ) + .then(status => expect(status).to.eq(TRANSACTION_STATUS.SUCCESSFUL)); } );