Skip to content

Commit

Permalink
Faucet Polling in E2E Tests (#191)
Browse files Browse the repository at this point in the history
  • Loading branch information
usmanmani1122 authored Sep 11, 2024
1 parent 08faa89 commit 1207eaa
Show file tree
Hide file tree
Showing 7 changed files with 95 additions and 99 deletions.
17 changes: 5 additions & 12 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,11 @@
// This file can contain .js-specific Typescript compiler config.
{
"compilerOptions": {
"target": "esnext",

"noEmit": true,
/*
// The following flags are for creating .d.ts files:
"noEmit": false,
"declaration": true,
"emitDeclarationOnly": true,
*/
"downlevelIteration": true,
"strictNullChecks": true,
"moduleResolution": "node",
"noEmit": true,
"strictNullChecks": true,
"target": "esnext",
"types": ["cypress", "node"]
},
"include": ["src/**/*.js", "exported.js", "components/**/*.js"],
"include": ["components/**/*.js", "exported.js", "src/**/*.js", "test/**/*.js"],
}
6 changes: 4 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,9 @@
"eslint": "^7.23.0",
"eslint-config-airbnb-base": "^14.2.0",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-cypress": "3.5.0",
"eslint-plugin-import": "^2.22.0",
"eslint-plugin-jsdoc": "^30.7.0",
"eslint-plugin-jsdoc": "^43.0.8",
"eslint-plugin-jsx-a11y": "^6.4.0",
"eslint-plugin-prettier": "5.0.0",
"prettier": "3.0.0",
Expand All @@ -66,7 +67,8 @@
},
"eslintConfig": {
"extends": [
"@agoric"
"@agoric",
"plugin:cypress/recommended"
],
"ignorePatterns": [
"build/**"
Expand Down
16 changes: 0 additions & 16 deletions test/e2e/constants.js

This file was deleted.

1 change: 1 addition & 0 deletions test/e2e/specs/test.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ describe('Wallet App Test Cases', { execTimeout: DEFAULT_EXEC_TIMEOUT }, () => {
walletName: 'newWallet',
selectedChains: ['Agoric'],
});
cy.visit('/wallet/');

cy.getWalletAddress('Agoric').then((address) => {
// provision BLD
Expand Down
58 changes: 35 additions & 23 deletions test/e2e/support.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import '@agoric/synpress/support/index';
import { flattenObject, FACUET_HEADERS, MINUTE_MS, config } from './test.utils';
import { FAUCET_URL_MAP } from './constants';
import { flattenObject, FACUET_HEADERS, config } from './test.utils';

const AGORIC_NET = Cypress.env('AGORIC_NET').trim() || 'local';
const environment = Cypress.env('ENVIRONMENT');
Expand Down Expand Up @@ -87,44 +86,57 @@ Cypress.Commands.add('listBids', (userAddress) => {
});

Cypress.Commands.add('provisionFromFaucet', (walletAddress, command) => {
const TRANSACTION_STATUS = {
FAILED: 1000,
NOT_FOUND: 1001,
SUCCESSFUL: 1002,
};

const getStatus = (txHash) =>
cy
.request({
method: 'GET',
url: `https://${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: FAUCET_URL_MAP[AGORIC_NET],
body: {
address: walletAddress,
command,
clientType: 'SMART_WALLET',
},
followRedirect: false,
headers: FACUET_HEADERS,
timeout: 4 * MINUTE_MS,
retryOnStatusCodeFailure: true,
}).then((resp) => {
expect(resp.body).to.eq('success');
});
method: 'POST',
url: `https://${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));
});

Cypress.Commands.add('setNetworkConfigURL', (agoricNet) => {
let networkConfigURL = '';

if (agoricNet === 'xnet') {
networkConfigURL = 'https://xnet.agoric.net/network-config';
} else if (agoricNet === 'ollinet') {
networkConfigURL = 'https://ollinet.agoric.net/network-config';
} else if (agoricNet === 'emerynet') {
networkConfigURL = 'https://emerynet.agoric.net/network-config';
} else if (agoricNet === 'devnet') {
networkConfigURL = 'https://devnet.agoric.net/network-config';
} else if (agoricNet === 'local') {
if (agoricNet === 'local')
// UNTIL https:/Agoric/wallet-app/issues/184
networkConfigURL = 'https://wallet.agoric.app/wallet/network-config';
} else {
throw new Error('Unknown Agoric network specified');
}
else networkConfigURL = `https://${agoricNet}.agoric.net/network-config`;

// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.get('input[value="https://main.agoric.net/network-config"]')
.should('be.visible')
.click()
.then(($input) => {
// eslint-disable-next-line cypress/unsafe-to-chain-command
cy.wrap($input).clear().type(networkConfigURL);
})
.should('have.value', networkConfigURL);
Expand Down Expand Up @@ -160,8 +172,8 @@ Cypress.Commands.add('createVault', (params) => {
cy.exec(broadcastCommand, {
env: { AGORIC_NET },
timeout: config[AGORIC_NET].COMMAND_TIMEOUT,
}).then(({ stdout }) => {
expect(stdout).not.to.contain('Error');
}).then(({ stdout: _stdout }) => {
expect(_stdout).not.to.contain('Error');
});
});
});
2 changes: 1 addition & 1 deletion wallet/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@
"eslint-config-airbnb-base": "^14.2.0",
"eslint-plugin-import": "^2.26.0",
"eslint-plugin-jest": "^27.1.3",
"eslint-plugin-jsdoc": "^39.6.2",
"eslint-plugin-jsdoc": "^43.0.8",
"eslint-plugin-jsx-a11y": "^6.4.0",
"eslint-plugin-react": "^7.31.10",
"eslint-plugin-react-hooks": "^4.6.0",
Expand Down
94 changes: 49 additions & 45 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -3252,14 +3252,14 @@
resolved "https://registry.yarnpkg.com/@endo/zip/-/zip-0.2.31.tgz#371b1a9ca8b3216ad8a3564e97e3d747be42a657"
integrity sha512-rNCZtQzPm6Q8kW69gyeU0hUwKZtwuR8cX1+URgpDuUuaMUbKWBaqURKOmrqKVtE5fkqCE7pSrHvGH02DMDbDHQ==

"@es-joy/jsdoccomment@~0.36.1":
version "0.36.1"
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.36.1.tgz#c37db40da36e4b848da5fd427a74bae3b004a30f"
integrity sha512-922xqFsTpHs6D0BUiG4toiyPOMc8/jafnWKxz1KWgS4XzKPy2qXf1Pe6UFuNSCQqt6tOuhAWXBNuuyUhJmw9Vg==
"@es-joy/jsdoccomment@~0.38.0":
version "0.38.0"
resolved "https://registry.yarnpkg.com/@es-joy/jsdoccomment/-/jsdoccomment-0.38.0.tgz#2e74f8d824b4a4ec831eaabd4c3548fb11eae5cd"
integrity sha512-TFac4Bnv0ZYNkEeDnOWHQhaS1elWlvOCQxH06iHeu5iffs+hCaLVIZJwF+FqksQi68R4i66Pu+4DfFGvble+Uw==
dependencies:
comment-parser "1.3.1"
esquery "^1.4.0"
jsdoc-type-pratt-parser "~3.1.0"
esquery "^1.5.0"
jsdoc-type-pratt-parser "~4.0.0"

"@esbuild/[email protected]":
version "0.17.19"
Expand Down Expand Up @@ -6201,6 +6201,11 @@ archy@^1.0.0:
resolved "https://registry.yarnpkg.com/archy/-/archy-1.0.0.tgz#f9c8c13757cc1dd7bc379ac77b2c62a5c2868c40"
integrity sha512-Xg+9RwCg/0p32teKdGMPTPnVXKD0w3DfHnFTficozsAgsvq2XenPJq/MYpzzQ/v8zrOyJn6Ds39VA4JIDwFfqw==

are-docs-informative@^0.0.2:
version "0.0.2"
resolved "https://registry.yarnpkg.com/are-docs-informative/-/are-docs-informative-0.0.2.tgz#387f0e93f5d45280373d387a59d34c96db321963"
integrity sha512-ixiS0nLNNG5jNQzgZJNoUpBKdo9yTYZMGJ+QgT2jmjR7G7+QHRCc4v6LQ3NgE7EBJq+o0ams3waJwkrlBom8Ig==

arg@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/arg/-/arg-5.0.2.tgz#c81433cc427c92c4dcf4865142dbca6f15acd59c"
Expand Down Expand Up @@ -7499,11 +7504,6 @@ [email protected]:
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-1.3.1.tgz#3d7ea3adaf9345594aedee6563f422348f165c1b"
integrity sha512-B52sN2VNghyq5ofvUsqZjmk6YkihBX5vMSChmSK9v4ShjKf3Vk5Xcmgpw4o+iIgtrnM/u5FiMpz9VKb8lpBveA==

comment-parser@^0.7.6:
version "0.7.6"
resolved "https://registry.yarnpkg.com/comment-parser/-/comment-parser-0.7.6.tgz#0e743a53c8e646c899a1323db31f6cd337b10f12"
integrity sha512-GKNxVA7/iuTnAqGADlTWX4tkhzxZKXp5fLJqKTlQLHkE65XDUKutZ3BHaJC5IGcper2tT3QRD1xr4o3jNpgXXg==

common-path-prefix@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/common-path-prefix/-/common-path-prefix-3.0.0.tgz#7d007a7e07c58c4b4d5f433131a19141b29f11e0"
Expand Down Expand Up @@ -9184,6 +9184,13 @@ eslint-module-utils@^2.7.4:
dependencies:
debug "^3.2.7"

[email protected]:
version "3.5.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-cypress/-/eslint-plugin-cypress-3.5.0.tgz#380ef5049ad80ebeca923db69e4aa96e72fcd893"
integrity sha512-JZQ6XnBTNI8h1B9M7wJSFzc48SYbh7VMMKaNTQOFa3BQlnmXPrVc4PKen8R+fpv6VleiPeej6VxloGb42zdRvw==
dependencies:
globals "^13.20.0"

eslint-plugin-eslint-comments@^3.1.2:
version "3.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-eslint-comments/-/eslint-plugin-eslint-comments-3.2.0.tgz#9e1cd7b4413526abb313933071d7aba05ca12ffa"
Expand Down Expand Up @@ -9235,30 +9242,18 @@ eslint-plugin-jest@^27.1.3:
dependencies:
"@typescript-eslint/utils" "^5.10.0"

eslint-plugin-jsdoc@^30.7.0:
version "30.7.13"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-30.7.13.tgz#52e5c74fb806d3bbeb51d04a0c829508c3c6b563"
integrity sha512-YM4WIsmurrp0rHX6XiXQppqKB8Ne5ATiZLJe2+/fkp9l9ExXFr43BbAbjZaVrpCT+tuPYOZ8k1MICARHnURUNQ==
dependencies:
comment-parser "^0.7.6"
debug "^4.3.1"
jsdoctypeparser "^9.0.0"
lodash "^4.17.20"
regextras "^0.7.1"
semver "^7.3.4"
spdx-expression-parse "^3.0.1"

eslint-plugin-jsdoc@^39.6.2:
version "39.8.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-39.8.0.tgz#9ca38ae31fb6e6de6268c5c041fa175fe1190469"
integrity sha512-ZwGmk0jJoJD/NILeDRBKrpq/PCgddUdATjeU5JGTqTzKsOWfeaHOnaAwZjuOh7T8EB4hSoZ/9pR4+Qns2ldQVg==
eslint-plugin-jsdoc@^43.0.8:
version "43.2.0"
resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-43.2.0.tgz#9d0df2329100a6956635f26211d0723c3ff91f15"
integrity sha512-Hst7XUfqh28UmPD52oTXmjaRN3d0KrmOZdgtp4h9/VHUJD3Evoo82ZGXi1TtRDWgWhvqDIRI63O49H0eH7NrZQ==
dependencies:
"@es-joy/jsdoccomment" "~0.36.1"
"@es-joy/jsdoccomment" "~0.38.0"
are-docs-informative "^0.0.2"
comment-parser "1.3.1"
debug "^4.3.4"
escape-string-regexp "^4.0.0"
esquery "^1.4.0"
semver "^7.3.8"
esquery "^1.5.0"
semver "^7.5.0"
spdx-expression-parse "^3.0.1"

eslint-plugin-jsx-a11y@^6.4.0, eslint-plugin-jsx-a11y@^6.5.1:
Expand Down Expand Up @@ -9510,6 +9505,13 @@ esquery@^1.4.0:
dependencies:
estraverse "^5.1.0"

esquery@^1.5.0:
version "1.6.0"
resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.6.0.tgz#91419234f804d852a82dceec3e16cdc22cf9dae7"
integrity sha512-ca9pw9fomFcKPvFLXhBKUK90ZvGibiGOvRJNbjljY7s7uq/5YO4BOzcYtJqExdx99rF6aAcnRxHmcUHcz6sQsg==
dependencies:
estraverse "^5.1.0"

esrecurse@^4.3.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.3.0.tgz#7ad7964d679abb28bee72cec63758b1c5d2c9921"
Expand Down Expand Up @@ -10466,6 +10468,13 @@ globals@^13.19.0, globals@^13.6.0, globals@^13.9.0:
dependencies:
type-fest "^0.20.2"

globals@^13.20.0:
version "13.24.0"
resolved "https://registry.yarnpkg.com/globals/-/globals-13.24.0.tgz#8432a19d78ce0c1e833949c36adb345400bb1171"
integrity sha512-AhO5QUcj8llrbG09iWhPU2B204J1xnPeL8kQmVorSsy+Sjj1sk8gIyh6cUocGmH4L0UuhAJy+hJMRA4mgA4mFQ==
dependencies:
type-fest "^0.20.2"

globalthis@^1.0.1, globalthis@^1.0.3:
version "1.0.3"
resolved "https://registry.yarnpkg.com/globalthis/-/globalthis-1.0.3.tgz#5852882a52b80dc301b0660273e1ed082f0b6ccf"
Expand Down Expand Up @@ -12265,15 +12274,10 @@ jsbn@~0.1.0:
resolved "https://registry.yarnpkg.com/jsbn/-/jsbn-0.1.1.tgz#a5e654c2e5a2deb5f201d96cefbca80c0ef2f513"
integrity sha512-UVU9dibq2JcFWxQPA6KCqj5O42VOmAY3zQUfEKxU0KpTGXwNoCjkX1e13eHNvw/xPynt6pU0rZ1htjWTNTSXsg==

jsdoc-type-pratt-parser@~3.1.0:
version "3.1.0"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-3.1.0.tgz#a4a56bdc6e82e5865ffd9febc5b1a227ff28e67e"
integrity sha512-MgtD0ZiCDk9B+eI73BextfRrVQl0oyzRG8B2BjORts6jbunj4ScKPcyXGTbB6eXL4y9TzxCm6hyeLq/2ASzNdw==

jsdoctypeparser@^9.0.0:
version "9.0.0"
resolved "https://registry.yarnpkg.com/jsdoctypeparser/-/jsdoctypeparser-9.0.0.tgz#8c97e2fb69315eb274b0f01377eaa5c940bd7b26"
integrity sha512-jrTA2jJIL6/DAEILBEh2/w9QxCuwmvNXIry39Ay/HVfhE3o2yVV0U44blYkqdHA/OKloJEqvJy0xU+GSdE2SIw==
jsdoc-type-pratt-parser@~4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/jsdoc-type-pratt-parser/-/jsdoc-type-pratt-parser-4.0.0.tgz#136f0571a99c184d84ec84662c45c29ceff71114"
integrity sha512-YtOli5Cmzy3q4dP26GraSOeAhqecewG04hoO8DY56CH4KJ9Fvv5qKWUCCo3HZob7esJQHCv6/+bnTy72xZZaVQ==

jsdom@^16.6.0:
version "16.7.0"
Expand Down Expand Up @@ -15477,11 +15481,6 @@ regexpu-core@^5.2.1:
unicode-match-property-ecmascript "^2.0.0"
unicode-match-property-value-ecmascript "^2.1.0"

regextras@^0.7.1:
version "0.7.1"
resolved "https://registry.yarnpkg.com/regextras/-/regextras-0.7.1.tgz#be95719d5f43f9ef0b9fa07ad89b7c606995a3b2"
integrity sha512-9YXf6xtW+qzQ+hcMQXx95MOvfqXFgsKDZodX3qZB0x2n5Z94ioetIITsBtvJbiOyxa/6s9AtyweBLCdPmPko/w==

regjsparser@^0.9.1:
version "0.9.1"
resolved "https://registry.yarnpkg.com/regjsparser/-/regjsparser-0.9.1.tgz#272d05aa10c7c1f67095b1ff0addae8442fc5709"
Expand Down Expand Up @@ -15947,6 +15946,11 @@ semver@^7.2.1, semver@^7.3.2, semver@^7.3.4, semver@^7.3.5, semver@^7.3.7, semve
dependencies:
lru-cache "^6.0.0"

semver@^7.5.0:
version "7.6.3"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.3.tgz#980f7b5550bc175fb4dc09403085627f9eb33143"
integrity sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==

semver@^7.5.3:
version "7.6.0"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.6.0.tgz#1a46a4db4bffcccd97b743b5005c8325f23d4e2d"
Expand Down

0 comments on commit 1207eaa

Please sign in to comment.