2022-04-12 11:57:18 +02:00
|
|
|
const { withFixtures } = require('../helpers');
|
2023-03-07 16:51:15 +01:00
|
|
|
const {
|
|
|
|
withFixturesOptions,
|
|
|
|
loadExtension,
|
|
|
|
buildQuote,
|
|
|
|
reviewQuote,
|
|
|
|
waitForTransactionToComplete,
|
|
|
|
checkActivityTransaction,
|
|
|
|
} = require('./shared');
|
2022-04-12 11:57:18 +02:00
|
|
|
|
|
|
|
describe('Swap Eth for another Token', function () {
|
2023-03-07 16:51:15 +01:00
|
|
|
it('Completes second Swaps while first swap is processing', async function () {
|
|
|
|
withFixturesOptions.ganacheOptions.blockTime = 10;
|
|
|
|
|
2022-04-12 11:57:18 +02:00
|
|
|
await withFixtures(
|
|
|
|
{
|
2022-11-03 14:54:49 +01:00
|
|
|
...withFixturesOptions,
|
2023-03-07 16:51:15 +01:00
|
|
|
failOnConsoleError: false,
|
2022-10-28 16:09:46 +02:00
|
|
|
title: this.test.title,
|
2022-04-12 11:57:18 +02:00
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
2023-03-07 16:51:15 +01:00
|
|
|
await loadExtension(driver);
|
2022-10-28 16:09:46 +02:00
|
|
|
await buildQuote(driver, {
|
2023-03-07 16:51:15 +01:00
|
|
|
amount: 0.001,
|
|
|
|
swapTo: 'USDC',
|
2022-10-28 16:09:46 +02:00
|
|
|
});
|
2023-03-07 16:51:15 +01:00
|
|
|
await reviewQuote(driver, {
|
|
|
|
amount: '0.001',
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'USDC',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
2023-03-07 16:51:15 +01:00
|
|
|
await driver.clickElement({ text: 'Swap', tag: 'button' });
|
|
|
|
await driver.clickElement({ text: 'View in activity', tag: 'button' });
|
|
|
|
await buildQuote(driver, {
|
|
|
|
amount: 0.003,
|
|
|
|
swapTo: 'DAI',
|
|
|
|
});
|
|
|
|
await reviewQuote(driver, {
|
|
|
|
amount: '0.003',
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
|
|
|
await driver.clickElement({ text: 'Swap', tag: 'button' });
|
2023-03-07 16:51:15 +01:00
|
|
|
await waitForTransactionToComplete(driver, 'DAI');
|
|
|
|
await checkActivityTransaction(driver, {
|
|
|
|
index: 0,
|
|
|
|
amount: '0.003',
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
2023-03-07 16:51:15 +01:00
|
|
|
await checkActivityTransaction(driver, {
|
|
|
|
index: 1,
|
|
|
|
amount: '0.001',
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'USDC',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it('Completes a Swap between Eth and Dai', async function () {
|
|
|
|
await withFixtures(
|
|
|
|
{
|
|
|
|
...withFixturesOptions,
|
|
|
|
title: this.test.title,
|
|
|
|
},
|
|
|
|
async ({ driver }) => {
|
|
|
|
await loadExtension(driver);
|
|
|
|
await buildQuote(driver, {
|
|
|
|
amount: 2,
|
|
|
|
swapTo: 'DAI',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
2023-03-07 16:51:15 +01:00
|
|
|
await reviewQuote(driver, {
|
|
|
|
amount: '2',
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
2023-03-07 16:51:15 +01:00
|
|
|
await driver.clickElement({ text: 'Swap', tag: 'button' });
|
|
|
|
await waitForTransactionToComplete(driver, 'DAI');
|
|
|
|
await checkActivityTransaction(driver, {
|
|
|
|
index: 0,
|
|
|
|
amount: '2',
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|