mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-11-22 09:57:02 +01:00
parent
d222f652c3
commit
d66db28ae6
@ -445,6 +445,30 @@ class FixtureBuilder {
|
||||
return this;
|
||||
}
|
||||
|
||||
withIncomingTransactionsControllerOneTransaction() {
|
||||
return this.withIncomingTransactionsController({
|
||||
incomingTransactions: {
|
||||
'0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab': {
|
||||
blockNumber: '1',
|
||||
chainId: '0x539',
|
||||
hash: '0xf1af8286e4fa47578c2aec5f08c108290643df978ebc766d72d88476eee90bab',
|
||||
id: 5748272735958807,
|
||||
metamaskNetworkId: '1337',
|
||||
status: 'confirmed',
|
||||
time: 1671635520000,
|
||||
txParams: {
|
||||
from: '0xc87261ba337be737fa744f50e7aaf4a920bdfcd6',
|
||||
gas: '0x5208',
|
||||
gasPrice: '0x329af9707',
|
||||
to: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||
value: '0xDE0B6B3A7640000',
|
||||
},
|
||||
type: 'incoming',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
withKeyringController(data) {
|
||||
merge(this.fixture.data.KeyringController, data);
|
||||
return this;
|
||||
@ -1102,6 +1126,207 @@ class FixtureBuilder {
|
||||
});
|
||||
}
|
||||
|
||||
withTransactionControllerCompletedTransaction() {
|
||||
return this.withTransactionController({
|
||||
transactions: {
|
||||
5748272735958801: {
|
||||
chainId: '0x539',
|
||||
history: [
|
||||
{
|
||||
chainId: 0x539,
|
||||
id: 5748272735958801,
|
||||
loadingDefaults: true,
|
||||
metamaskNetworkId: '1337',
|
||||
origin: 'metamask',
|
||||
status: 'unapproved',
|
||||
time: 1671635506502,
|
||||
txParams: {
|
||||
from: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||
gas: '0x5208',
|
||||
maxFeePerGas: '0x4c03c96f8',
|
||||
maxPriorityFeePerGas: '0x59682f00',
|
||||
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||
type: '0x2',
|
||||
value: '0xde0b6b3a7640000',
|
||||
},
|
||||
type: 'simpleSend',
|
||||
},
|
||||
[
|
||||
{
|
||||
note: 'Added new unapproved transaction.',
|
||||
op: 'replace',
|
||||
path: '/loadingDefaults',
|
||||
timestamp: 1671635506520,
|
||||
value: false,
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'confTx: user approved transaction',
|
||||
op: 'replace',
|
||||
path: '/txParams/maxFeePerGas',
|
||||
timestamp: 1671635510589,
|
||||
value: '0x4d7fc07fb',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'txStateManager: setting status to approved',
|
||||
op: 'replace',
|
||||
path: '/status',
|
||||
timestamp: 1671635510589,
|
||||
value: 'approved',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'transactions#approveTransaction',
|
||||
op: 'add',
|
||||
path: '/txParams/nonce',
|
||||
timestamp: 1671635510592,
|
||||
value: '0x2',
|
||||
},
|
||||
{
|
||||
op: 'add',
|
||||
path: '/nonceDetails',
|
||||
value: {
|
||||
local: {
|
||||
details: {
|
||||
highest: 2,
|
||||
startPoint: 2,
|
||||
},
|
||||
name: 'local',
|
||||
nonce: 2,
|
||||
},
|
||||
network: {
|
||||
details: {
|
||||
baseCount: 2,
|
||||
blockNumber: '0x7cbf93',
|
||||
},
|
||||
name: 'network',
|
||||
nonce: 2,
|
||||
},
|
||||
params: {
|
||||
highestLocallyConfirmed: 0,
|
||||
highestSuggested: 2,
|
||||
nextNetworkNonce: 2,
|
||||
},
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'txStateManager: setting status to signed',
|
||||
op: 'replace',
|
||||
path: '/status',
|
||||
timestamp: 1671635510651,
|
||||
value: 'signed',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'transactions#publishTransaction',
|
||||
op: 'add',
|
||||
path: '/rawTx',
|
||||
timestamp: 1671635510653,
|
||||
value:
|
||||
'0x02f87205028459682f008504d7fc07fb825208947d17148ed7ec802e4458e94deec1ef28aef645e987038d7ea4c6800080c001a0c60aeaef1556a52b009e3973f06c64d5cd6dc935463afd0d2b1c00661655e47ea061b121db8f2cb2241b1454d1794256e5634d26a5b873e89a816efe210377492a',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'txStateManager: setting status to submitted',
|
||||
op: 'replace',
|
||||
path: '/status',
|
||||
timestamp: 1671635510753,
|
||||
value: 'submitted',
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'txStateManager: setting status to confirmed',
|
||||
op: 'replace',
|
||||
path: '/status',
|
||||
timestamp: 1671635522978,
|
||||
value: 'confirmed',
|
||||
},
|
||||
{
|
||||
op: 'add',
|
||||
path: '/txReceipt',
|
||||
value: {
|
||||
blockNumber: '7cbf95',
|
||||
from: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||
gasUsed: '5208',
|
||||
status: '0x1',
|
||||
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||
type: '0x2',
|
||||
},
|
||||
},
|
||||
],
|
||||
[
|
||||
{
|
||||
note: 'transactions#confirmTransaction - add txReceipt',
|
||||
op: 'replace',
|
||||
path: '/blockTimestamp',
|
||||
timestamp: 1671635522999,
|
||||
value: '63a32240',
|
||||
},
|
||||
],
|
||||
],
|
||||
id: 5748272735958801,
|
||||
loadingDefaults: false,
|
||||
metamaskNetworkId: '5',
|
||||
nonceDetails: {
|
||||
local: {
|
||||
details: {
|
||||
highest: 2,
|
||||
startPoint: 2,
|
||||
},
|
||||
name: 'local',
|
||||
nonce: 2,
|
||||
},
|
||||
network: {
|
||||
details: {
|
||||
baseCount: 2,
|
||||
blockNumber: '0x7cbf93',
|
||||
},
|
||||
name: 'network',
|
||||
nonce: 2,
|
||||
},
|
||||
params: {
|
||||
highestLocallyConfirmed: 0,
|
||||
highestSuggested: 2,
|
||||
nextNetworkNonce: 2,
|
||||
},
|
||||
},
|
||||
origin: 'metamask',
|
||||
status: 'confirmed',
|
||||
submittedTime: 1671635510753,
|
||||
time: 1671635506502,
|
||||
txParams: {
|
||||
from: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||
gas: '0x5208',
|
||||
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||
type: '0x2',
|
||||
value: '0xde0b6b3a7640000',
|
||||
},
|
||||
txReceipt: {
|
||||
blockNumber: {
|
||||
length: 1,
|
||||
negative: 0,
|
||||
words: [8175509, null],
|
||||
},
|
||||
from: '0x5cfe73b6021e818b776b421b1c4db2474086a7e1',
|
||||
status: '0x1',
|
||||
to: '0x2f318C334780961FB129D2a6c30D0763d9a5C970',
|
||||
type: '0x2',
|
||||
},
|
||||
type: 'simpleSend',
|
||||
},
|
||||
},
|
||||
});
|
||||
}
|
||||
|
||||
withNetworkSupportEIP1559() {
|
||||
merge(this.fixture.data.NetworkController, {
|
||||
networkDetails: {
|
||||
|
71
test/e2e/tests/reset-account.spec.js
Normal file
71
test/e2e/tests/reset-account.spec.js
Normal file
@ -0,0 +1,71 @@
|
||||
const { strict: assert } = require('assert');
|
||||
const { convertToHexValue, withFixtures } = require('../helpers');
|
||||
const FixtureBuilder = require('../fixture-builder');
|
||||
|
||||
describe('Reset account', function () {
|
||||
// ////////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// When user get stuck with pending transactions, one can reset the account by clicking the 'Reset account' //
|
||||
// button in settings, advanced tab. This functionality will clear all the send transactions history. //
|
||||
// Note that the receive transactions history will be kept and it only only affects the current network. //
|
||||
// ///////////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
it('User can reset account via the advanced setting tab, ', async function () {
|
||||
const ganacheOptions = {
|
||||
accounts: [
|
||||
{
|
||||
secretKey:
|
||||
'0x7C9529A67102755B7E6102D6D950AC5D5863C98713805CEC576B945B15B71EAC',
|
||||
balance: convertToHexValue(25000000000000000000),
|
||||
},
|
||||
],
|
||||
};
|
||||
await withFixtures(
|
||||
{
|
||||
fixtures: new FixtureBuilder()
|
||||
.withTransactionControllerCompletedTransaction()
|
||||
.withIncomingTransactionsControllerOneTransaction()
|
||||
.build(),
|
||||
ganacheOptions,
|
||||
title: this.test.title,
|
||||
},
|
||||
async ({ driver }) => {
|
||||
await driver.navigate();
|
||||
await driver.fill('#password', 'correct horse battery staple');
|
||||
await driver.press('#password', driver.Key.ENTER);
|
||||
|
||||
// Check send transaction and receive transaction history are all displayed
|
||||
await driver.clickElement('[data-testid="home__activity-tab"]');
|
||||
await driver.waitForSelector(
|
||||
{ css: '.list-item__title', text: 'Send' },
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
await driver.waitForSelector(
|
||||
{ css: '.list-item__title', text: 'Receive' },
|
||||
{ timeout: 10000 },
|
||||
);
|
||||
|
||||
// Reset account
|
||||
await driver.clickElement('.account-menu__icon');
|
||||
await driver.clickElement({ text: 'Settings', tag: 'div' });
|
||||
await driver.clickElement({
|
||||
css: '.tab-bar__tab__content__title',
|
||||
text: 'Advanced',
|
||||
});
|
||||
await driver.clickElement({ text: 'Reset account', tag: 'button' });
|
||||
await driver.clickElement({ text: 'Reset', tag: 'button' });
|
||||
await driver.navigate();
|
||||
|
||||
// Check send transaction history is cleared and receive transaction history is kept
|
||||
const sendTransaction = await driver.isElementPresent({
|
||||
css: '.list-item__title',
|
||||
text: 'Send',
|
||||
});
|
||||
const receiveTransaction = await driver.isElementPresent({
|
||||
css: '.list-item__title',
|
||||
text: 'Receive',
|
||||
});
|
||||
assert.equal(sendTransaction, false);
|
||||
assert.equal(receiveTransaction, true);
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
Loading…
Reference in New Issue
Block a user