commit
c6a6e6c21b
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
After Width: | Height: | Size: 3.6 KiB |
After Width: | Height: | Size: 8.4 KiB |
@ -0,0 +1 @@ |
|||||||
|
export const TRANSAK_API_KEY = '25ac1309-a49b-4411-b20e-5e56c61a5b1c'; // It's a public key, which will be included in a URL for Transak.
|
@ -1,49 +1,76 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
|
import nock from 'nock'; |
||||||
import { |
import { |
||||||
KOVAN_CHAIN_ID, |
KOVAN_CHAIN_ID, |
||||||
MAINNET_CHAIN_ID, |
MAINNET_CHAIN_ID, |
||||||
RINKEBY_CHAIN_ID, |
RINKEBY_CHAIN_ID, |
||||||
ROPSTEN_CHAIN_ID, |
ROPSTEN_CHAIN_ID, |
||||||
} from '../../../shared/constants/network'; |
} from '../../../shared/constants/network'; |
||||||
|
import { TRANSAK_API_KEY } from '../constants/on-ramp'; |
||||||
import getBuyEthUrl from './buy-eth-url'; |
import getBuyEthUrl from './buy-eth-url'; |
||||||
|
|
||||||
|
const WYRE_ACCOUNT_ID = 'AC-7AG3W4XH4N2'; |
||||||
|
const ETH_ADDRESS = '0x0dcd5d886577d5581b0c524242ef2ee70be3e7bc'; |
||||||
|
const MAINNET = { |
||||||
|
chainId: MAINNET_CHAIN_ID, |
||||||
|
amount: 5, |
||||||
|
address: ETH_ADDRESS, |
||||||
|
}; |
||||||
|
const ROPSTEN = { |
||||||
|
chainId: ROPSTEN_CHAIN_ID, |
||||||
|
}; |
||||||
|
const RINKEBY = { |
||||||
|
chainId: RINKEBY_CHAIN_ID, |
||||||
|
}; |
||||||
|
const KOVAN = { |
||||||
|
chainId: KOVAN_CHAIN_ID, |
||||||
|
}; |
||||||
|
|
||||||
describe('buy-eth-url', function () { |
describe('buy-eth-url', function () { |
||||||
const mainnet = { |
it('returns Wyre url with an ETH address for Ethereum mainnet', async function () { |
||||||
chainId: MAINNET_CHAIN_ID, |
nock('https://api.metaswap.codefi.network') |
||||||
amount: 5, |
.get(`/fiatOnRampUrl?serviceName=wyre&destinationAddress=${ETH_ADDRESS}`) |
||||||
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', |
.reply(200, { |
||||||
}; |
url: `https://pay.sendwyre.com/purchase?accountId=${WYRE_ACCOUNT_ID}&utm_campaign=${WYRE_ACCOUNT_ID}&destCurrency=ETH&utm_medium=widget&paymentMethod=debit-card&reservation=MLZVUF8FMXZUMARJC23B&dest=ethereum%3A${ETH_ADDRESS}&utm_source=checkout`, |
||||||
const ropsten = { |
}); |
||||||
chainId: ROPSTEN_CHAIN_ID, |
const wyreUrl = await getBuyEthUrl(MAINNET); |
||||||
}; |
assert.equal( |
||||||
const rinkeby = { |
wyreUrl, |
||||||
chainId: RINKEBY_CHAIN_ID, |
`https://pay.sendwyre.com/purchase?accountId=${WYRE_ACCOUNT_ID}&utm_campaign=${WYRE_ACCOUNT_ID}&destCurrency=ETH&utm_medium=widget&paymentMethod=debit-card&reservation=MLZVUF8FMXZUMARJC23B&dest=ethereum%3A${ETH_ADDRESS}&utm_source=checkout`, |
||||||
}; |
); |
||||||
const kovan = { |
nock.cleanAll(); |
||||||
chainId: KOVAN_CHAIN_ID, |
}); |
||||||
}; |
|
||||||
|
it('returns a fallback Wyre url if /orders/reserve API call fails', async function () { |
||||||
it('returns wyre url with address for network 1', function () { |
const wyreUrl = await getBuyEthUrl(MAINNET); |
||||||
const wyreUrl = getBuyEthUrl(mainnet); |
|
||||||
|
|
||||||
assert.equal( |
assert.equal( |
||||||
wyreUrl, |
wyreUrl, |
||||||
'https://pay.sendwyre.com/purchase?dest=ethereum:0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc&destCurrency=ETH&accountId=AC-7AG3W4XH4N2&paymentMethod=debit-card', |
`https://pay.sendwyre.com/purchase?dest=ethereum:${ETH_ADDRESS}&destCurrency=ETH&accountId=${WYRE_ACCOUNT_ID}&paymentMethod=debit-card`, |
||||||
|
); |
||||||
|
}); |
||||||
|
|
||||||
|
it('returns Transak url with an ETH address for Ethereum mainnet', async function () { |
||||||
|
const transakUrl = await getBuyEthUrl({ ...MAINNET, service: 'transak' }); |
||||||
|
|
||||||
|
assert.equal( |
||||||
|
transakUrl, |
||||||
|
`https://global.transak.com/?apiKey=${TRANSAK_API_KEY}&hostURL=https%3A%2F%2Fmetamask.io&defaultCryptoCurrency=ETH&walletAddress=${ETH_ADDRESS}`, |
||||||
); |
); |
||||||
}); |
}); |
||||||
|
|
||||||
it('returns metamask ropsten faucet for network 3', function () { |
it('returns metamask ropsten faucet for network 3', async function () { |
||||||
const ropstenUrl = getBuyEthUrl(ropsten); |
const ropstenUrl = await getBuyEthUrl(ROPSTEN); |
||||||
assert.equal(ropstenUrl, 'https://faucet.metamask.io/'); |
assert.equal(ropstenUrl, 'https://faucet.metamask.io/'); |
||||||
}); |
}); |
||||||
|
|
||||||
it('returns rinkeby dapp for network 4', function () { |
it('returns rinkeby dapp for network 4', async function () { |
||||||
const rinkebyUrl = getBuyEthUrl(rinkeby); |
const rinkebyUrl = await getBuyEthUrl(RINKEBY); |
||||||
assert.equal(rinkebyUrl, 'https://www.rinkeby.io/'); |
assert.equal(rinkebyUrl, 'https://www.rinkeby.io/'); |
||||||
}); |
}); |
||||||
|
|
||||||
it('returns kovan github test faucet for network 42', function () { |
it('returns kovan github test faucet for network 42', async function () { |
||||||
const kovanUrl = getBuyEthUrl(kovan); |
const kovanUrl = await getBuyEthUrl(KOVAN); |
||||||
assert.equal(kovanUrl, 'https://github.com/kovan-testnet/faucet'); |
assert.equal(kovanUrl, 'https://github.com/kovan-testnet/faucet'); |
||||||
}); |
}); |
||||||
}); |
}); |
||||||
|
@ -0,0 +1,16 @@ |
|||||||
|
/** |
||||||
|
* Exit the process with an error message. |
||||||
|
* |
||||||
|
* Note that this should be called before the process ends, but it will not |
||||||
|
* itself end the process. This is because the Node.js documentation strongly |
||||||
|
* advises against calling `process.exit` directly. |
||||||
|
* |
||||||
|
* @param {string} errorMessage - The error message that is causing the non- |
||||||
|
* zero exit code. |
||||||
|
*/ |
||||||
|
function exitWithError(errorMessage) { |
||||||
|
console.error(errorMessage); |
||||||
|
process.exitCode = 1; |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = { exitWithError }; |
@ -0,0 +1,23 @@ |
|||||||
|
/** |
||||||
|
* Run the given function, retrying it upon failure until reaching the |
||||||
|
* specified number of retries. |
||||||
|
* |
||||||
|
* @param {number} retries - The number of retries upon failure to attempt. |
||||||
|
* @param {function} functionToRetry - The function that will be retried upon failure. |
||||||
|
*/ |
||||||
|
async function retry(retries, functionToRetry) { |
||||||
|
let attempts = 0; |
||||||
|
while (attempts <= retries) { |
||||||
|
try { |
||||||
|
await functionToRetry(); |
||||||
|
return; |
||||||
|
} catch (error) { |
||||||
|
console.error(error); |
||||||
|
} finally { |
||||||
|
attempts += 1; |
||||||
|
} |
||||||
|
} |
||||||
|
throw new Error('Retry limit reached'); |
||||||
|
} |
||||||
|
|
||||||
|
module.exports = { retry }; |
@ -0,0 +1,19 @@ |
|||||||
|
diff --git a/node_modules/selenium-webdriver/chromium.js b/node_modules/selenium-webdriver/chromium.js
|
||||||
|
index d828ce5..87176f4 100644
|
||||||
|
--- a/node_modules/selenium-webdriver/chromium.js
|
||||||
|
+++ b/node_modules/selenium-webdriver/chromium.js
|
||||||
|
@@ -197,6 +197,14 @@ class ServiceBuilder extends remote.DriverService.Builder {
|
||||||
|
return this.addArguments('--log-path=' + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ /**
|
||||||
|
+ * Enables Chrome logging.
|
||||||
|
+ * @returns {!ServiceBuilder} A self reference.
|
||||||
|
+ */
|
||||||
|
+ enableChromeLogging() {
|
||||||
|
+ return this.addArguments('--enable-chrome-logs');
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
/**
|
||||||
|
* Enables verbose logging.
|
||||||
|
* @return {!ServiceBuilder} A self reference.
|
@ -0,0 +1,57 @@ |
|||||||
|
const path = require('path'); |
||||||
|
const { promises: fs } = require('fs'); |
||||||
|
const yargs = require('yargs/yargs'); |
||||||
|
const { hideBin } = require('yargs/helpers'); |
||||||
|
const { runInShell } = require('../../development/lib/run-command'); |
||||||
|
const { exitWithError } = require('../../development/lib/exit-with-error'); |
||||||
|
|
||||||
|
async function main() { |
||||||
|
const { argv } = yargs(hideBin(process.argv)) |
||||||
|
.usage( |
||||||
|
'$0 [options]', |
||||||
|
'Run all E2E tests, with a variable number of retries.', |
||||||
|
(_yargs) => |
||||||
|
_yargs |
||||||
|
.option('browser', { |
||||||
|
description: `Set the browser used; either 'chrome' or 'firefox'.`, |
||||||
|
type: 'string', |
||||||
|
choices: ['chrome', 'firefox'], |
||||||
|
}) |
||||||
|
.option('retries', { |
||||||
|
description: |
||||||
|
'Set how many times the test should be retried upon failure.', |
||||||
|
type: 'number', |
||||||
|
}), |
||||||
|
) |
||||||
|
.strict() |
||||||
|
.help('help'); |
||||||
|
|
||||||
|
const { browser, retries } = argv; |
||||||
|
|
||||||
|
const testDir = path.join(__dirname, 'tests'); |
||||||
|
const metamaskUiTest = path.join(__dirname, 'metamask-ui.spec.js'); |
||||||
|
|
||||||
|
const testFilenames = await fs.readdir(testDir); |
||||||
|
const testPaths = testFilenames.map((filename) => |
||||||
|
path.join(testDir, filename), |
||||||
|
); |
||||||
|
const allE2eTestPaths = [...testPaths, metamaskUiTest]; |
||||||
|
|
||||||
|
const runE2eTestPath = path.join(__dirname, 'run-e2e-test.js'); |
||||||
|
|
||||||
|
const args = [runE2eTestPath]; |
||||||
|
if (browser) { |
||||||
|
args.push('--browser', browser); |
||||||
|
} |
||||||
|
if (retries) { |
||||||
|
args.push('--retries', retries); |
||||||
|
} |
||||||
|
|
||||||
|
for (const testPath of allE2eTestPaths) { |
||||||
|
await runInShell('node', [...args, testPath]); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
main().catch((error) => { |
||||||
|
exitWithError(error); |
||||||
|
}); |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue