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,
|
2023-06-15 20:17:21 +02:00
|
|
|
changeExchangeRate,
|
2023-03-07 16:51:15 +01:00
|
|
|
} = 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, {
|
2023-06-15 20:17:21 +02:00
|
|
|
amount: 0.001,
|
2023-03-07 16:51:15 +01:00
|
|
|
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, {
|
2023-06-15 20:17:21 +02:00
|
|
|
amount: 0.003,
|
2023-03-07 16:51:15 +01:00
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
|
|
|
await driver.clickElement({ text: 'Swap', tag: 'button' });
|
2023-06-15 20:17:21 +02:00
|
|
|
await waitForTransactionToComplete(driver, { tokenName: 'DAI' });
|
2023-03-07 16:51:15 +01:00
|
|
|
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',
|
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
2023-06-15 20:17:21 +02:00
|
|
|
it('Completes a Swap between ETH and DAI after changing initial rate', async function () {
|
2023-03-07 16:51:15 +01:00
|
|
|
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, {
|
2023-06-15 20:17:21 +02:00
|
|
|
amount: 2,
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
|
|
|
});
|
|
|
|
await changeExchangeRate(driver);
|
|
|
|
await reviewQuote(driver, {
|
|
|
|
amount: 2,
|
2023-03-07 16:51:15 +01:00
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
2023-06-15 20:17:21 +02:00
|
|
|
skipCounter: true,
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
2023-03-07 16:51:15 +01:00
|
|
|
await driver.clickElement({ text: 'Swap', tag: 'button' });
|
2023-06-15 20:17:21 +02:00
|
|
|
await waitForTransactionToComplete(driver, { tokenName: 'DAI' });
|
2023-03-07 16:51:15 +01:00
|
|
|
await checkActivityTransaction(driver, {
|
|
|
|
index: 0,
|
|
|
|
amount: '2',
|
|
|
|
swapFrom: 'TESTETH',
|
|
|
|
swapTo: 'DAI',
|
2022-04-12 11:57:18 +02:00
|
|
|
});
|
|
|
|
},
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|