You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
999 lines
31 KiB
999 lines
31 KiB
4 years ago
|
import { strict as assert } from 'assert';
|
||
|
import EventEmitter from 'events';
|
||
|
import ethUtil from 'ethereumjs-util';
|
||
|
import EthTx from 'ethereumjs-tx';
|
||
|
import { ObservableStore } from '@metamask/obs-store';
|
||
|
import sinon from 'sinon';
|
||
5 years ago
|
|
||
4 years ago
|
import {
|
||
|
createTestProviderTools,
|
||
|
getTestAccounts,
|
||
4 years ago
|
} from '../../../../test/stub/provider';
|
||
4 years ago
|
import {
|
||
4 years ago
|
TRANSACTION_STATUSES,
|
||
4 years ago
|
TRANSACTION_TYPES,
|
||
4 years ago
|
} from '../../../../shared/constants/transaction';
|
||
|
import { METAMASK_CONTROLLER_EVENTS } from '../../metamask-controller';
|
||
|
import TransactionController from '.';
|
||
7 years ago
|
|
||
4 years ago
|
const noop = () => true;
|
||
|
const currentNetworkId = '42';
|
||
|
const currentChainId = '0x2a';
|
||
7 years ago
|
|
||
7 years ago
|
describe('Transaction Controller', function () {
|
||
4 years ago
|
let txController, provider, providerResultStub, fromAccount;
|
||
8 years ago
|
|
||
8 years ago
|
beforeEach(function () {
|
||
7 years ago
|
providerResultStub = {
|
||
|
// 1 gwei
|
||
|
eth_gasPrice: '0x0de0b6b3a7640000',
|
||
|
// by default, all accounts are external accounts (not contracts)
|
||
|
eth_getCode: '0x',
|
||
4 years ago
|
};
|
||
4 years ago
|
provider = createTestProviderTools({ scaffold: providerResultStub })
|
||
4 years ago
|
.provider;
|
||
|
fromAccount = getTestAccounts()[0];
|
||
|
const blockTrackerStub = new EventEmitter();
|
||
|
blockTrackerStub.getCurrentBlock = noop;
|
||
|
blockTrackerStub.getLatestBlock = noop;
|
||
8 years ago
|
txController = new TransactionController({
|
||
7 years ago
|
provider,
|
||
4 years ago
|
getGasPrice() {
|
||
4 years ago
|
return '0xee6b2800';
|
||
5 years ago
|
},
|
||
5 years ago
|
networkStore: new ObservableStore(currentNetworkId),
|
||
8 years ago
|
txHistoryLimit: 10,
|
||
7 years ago
|
blockTracker: blockTrackerStub,
|
||
4 years ago
|
signTransaction: (ethTx) =>
|
||
|
new Promise((resolve) => {
|
||
4 years ago
|
ethTx.sign(fromAccount.key);
|
||
|
resolve();
|
||
4 years ago
|
}),
|
||
4 years ago
|
getPermittedAccounts: () => undefined,
|
||
4 years ago
|
getCurrentChainId: () => currentChainId,
|
||
4 years ago
|
getParticipateInMetrics: () => false,
|
||
4 years ago
|
});
|
||
4 years ago
|
txController.nonceTracker.getNonceLock = () =>
|
||
4 years ago
|
Promise.resolve({ nextNonce: 0, releaseLock: noop });
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#getState', function () {
|
||
5 years ago
|
it('should return a state object with the right keys and data types', function () {
|
||
4 years ago
|
const exposedState = txController.getState();
|
||
4 years ago
|
assert.ok(
|
||
|
'unapprovedTxs' in exposedState,
|
||
|
'state should have the key unapprovedTxs',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.ok(
|
||
|
'currentNetworkTxList' in exposedState,
|
||
|
'state should have the key currentNetworkTxList',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.ok(
|
||
|
typeof exposedState?.unapprovedTxs === 'object',
|
||
|
'should be an object',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.ok(
|
||
|
Array.isArray(exposedState.currentNetworkTxList),
|
||
|
'should be an array',
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
|
describe('#getUnapprovedTxCount', function () {
|
||
|
it('should return the number of unapproved txs', function () {
|
||
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 2,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 3,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
4 years ago
|
]);
|
||
|
const unapprovedTxCount = txController.getUnapprovedTxCount();
|
||
|
assert.equal(unapprovedTxCount, 3, 'should be 3');
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#getPendingTxCount', function () {
|
||
|
it('should return the number of pending txs', function () {
|
||
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 2,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 3,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
4 years ago
|
]);
|
||
|
const pendingTxCount = txController.getPendingTxCount();
|
||
|
assert.equal(pendingTxCount, 3, 'should be 3');
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#getConfirmedTransactions', function () {
|
||
5 years ago
|
it('should return the number of confirmed txs', function () {
|
||
4 years ago
|
const address = '0xc684832530fcbddae4b4230a47e991ddcec2831d';
|
||
7 years ago
|
const txParams = {
|
||
4 years ago
|
from: address,
|
||
|
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||
4 years ago
|
};
|
||
7 years ago
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 0,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 2,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 3,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 4,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.REJECTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 5,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.APPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 6,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SIGNED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 7,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 8,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.FAILED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
4 years ago
|
]);
|
||
4 years ago
|
assert.equal(
|
||
|
txController.nonceTracker.getConfirmedTransactions(address).length,
|
||
|
3,
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#newUnapprovedTransaction', function () {
|
||
4 years ago
|
let stub, txMeta, txParams;
|
||
7 years ago
|
beforeEach(function () {
|
||
|
txParams = {
|
||
4 years ago
|
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||
|
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||
4 years ago
|
};
|
||
7 years ago
|
txMeta = {
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
7 years ago
|
id: 1,
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
6 years ago
|
history: [{}],
|
||
4 years ago
|
};
|
||
|
txController.txStateManager._saveTxList([txMeta]);
|
||
4 years ago
|
stub = sinon
|
||
|
.stub(txController, 'addUnapprovedTransaction')
|
||
|
.callsFake(() => {
|
||
4 years ago
|
txController.emit('newUnapprovedTx', txMeta);
|
||
|
return Promise.resolve(txController.txStateManager.addTx(txMeta));
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
afterEach(function () {
|
||
4 years ago
|
txController.txStateManager._saveTxList([]);
|
||
|
stub.restore();
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
it('should resolve when finished and status is submitted and resolve with the hash', async function () {
|
||
7 years ago
|
txController.once('newUnapprovedTx', (txMetaFromEmit) => {
|
||
7 years ago
|
setTimeout(() => {
|
||
4 years ago
|
txController.setTxHash(txMetaFromEmit.id, '0x0');
|
||
|
txController.txStateManager.setTxStatusSubmitted(txMetaFromEmit.id);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
const hash = await txController.newUnapprovedTransaction(txParams);
|
||
|
assert.ok(hash, 'newUnapprovedTransaction needs to return the hash');
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
it('should reject when finished and status is rejected', async function () {
|
||
7 years ago
|
txController.once('newUnapprovedTx', (txMetaFromEmit) => {
|
||
7 years ago
|
setTimeout(() => {
|
||
4 years ago
|
txController.txStateManager.setTxStatusRejected(txMetaFromEmit.id);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
await assert.rejects(
|
||
|
() => txController.newUnapprovedTransaction(txParams),
|
||
4 years ago
|
{
|
||
|
message: 'MetaMask Tx Signature: User denied transaction signature.',
|
||
|
},
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#addUnapprovedTransaction', function () {
|
||
4 years ago
|
const selectedAddress = '0x1678a085c290ebd122dc42cba69373b5953b831d';
|
||
|
const recipientAddress = '0xc42edfcc21ed14dda456aa0756c153f7985d8813';
|
||
6 years ago
|
|
||
4 years ago
|
let getSelectedAddress, getPermittedAccounts;
|
||
6 years ago
|
beforeEach(function () {
|
||
4 years ago
|
getSelectedAddress = sinon
|
||
|
.stub(txController, 'getSelectedAddress')
|
||
4 years ago
|
.returns(selectedAddress);
|
||
4 years ago
|
getPermittedAccounts = sinon
|
||
|
.stub(txController, 'getPermittedAccounts')
|
||
4 years ago
|
.returns([selectedAddress]);
|
||
|
});
|
||
6 years ago
|
|
||
|
afterEach(function () {
|
||
4 years ago
|
getSelectedAddress.restore();
|
||
|
getPermittedAccounts.restore();
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
it('should add an unapproved transaction and return a valid txMeta', async function () {
|
||
4 years ago
|
const txMeta = await txController.addUnapprovedTransaction({
|
||
|
from: selectedAddress,
|
||
4 years ago
|
to: recipientAddress,
|
||
4 years ago
|
});
|
||
|
assert.ok('id' in txMeta, 'should have a id');
|
||
|
assert.ok('time' in txMeta, 'should have a time stamp');
|
||
4 years ago
|
assert.ok(
|
||
|
'metamaskNetworkId' in txMeta,
|
||
|
'should have a metamaskNetworkId',
|
||
4 years ago
|
);
|
||
|
assert.ok('txParams' in txMeta, 'should have a txParams');
|
||
|
assert.ok('history' in txMeta, 'should have a history');
|
||
4 years ago
|
assert.equal(
|
||
|
txMeta.txParams.value,
|
||
|
'0x0',
|
||
|
'should have added 0x0 as the value',
|
||
4 years ago
|
);
|
||
5 years ago
|
|
||
4 years ago
|
const memTxMeta = txController.txStateManager.getTx(txMeta.id);
|
||
|
assert.deepEqual(txMeta, memTxMeta);
|
||
|
});
|
||
7 years ago
|
|
||
|
it('should emit newUnapprovedTx event and pass txMeta as the first argument', function (done) {
|
||
4 years ago
|
providerResultStub.eth_gasPrice = '4a817c800';
|
||
7 years ago
|
txController.once('newUnapprovedTx', (txMetaFromEmit) => {
|
||
4 years ago
|
assert.ok(txMetaFromEmit, 'txMeta is falsy');
|
||
|
done();
|
||
|
});
|
||
4 years ago
|
txController
|
||
4 years ago
|
.addUnapprovedTransaction({
|
||
|
from: selectedAddress,
|
||
|
to: recipientAddress,
|
||
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
it("should fail if the from address isn't the selected address", async function () {
|
||
4 years ago
|
await assert.rejects(() =>
|
||
|
txController.addUnapprovedTransaction({
|
||
|
from: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2',
|
||
|
}),
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('should fail if netId is loading', async function () {
|
||
4 years ago
|
txController.networkStore = new ObservableStore('loading');
|
||
5 years ago
|
await assert.rejects(
|
||
4 years ago
|
() =>
|
||
|
txController.addUnapprovedTransaction({
|
||
|
from: selectedAddress,
|
||
|
to: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2',
|
||
|
}),
|
||
5 years ago
|
{ message: 'MetaMask is having trouble connecting to the network' },
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
8 years ago
|
|
||
7 years ago
|
describe('#addTxGasDefaults', function () {
|
||
5 years ago
|
it('should add the tx defaults if their are none', async function () {
|
||
5 years ago
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
4 years ago
|
]);
|
||
7 years ago
|
const txMeta = {
|
||
5 years ago
|
id: 1,
|
||
7 years ago
|
txParams: {
|
||
|
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||
|
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||
7 years ago
|
},
|
||
6 years ago
|
history: [{}],
|
||
4 years ago
|
};
|
||
|
providerResultStub.eth_gasPrice = '4a817c800';
|
||
|
providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' };
|
||
|
providerResultStub.eth_estimateGas = '5209';
|
||
7 years ago
|
|
||
4 years ago
|
const txMetaWithDefaults = await txController.addTxGasDefaults(txMeta);
|
||
4 years ago
|
assert.ok(
|
||
|
txMetaWithDefaults.txParams.gasPrice,
|
||
|
'should have added the gas price',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.ok(
|
||
|
txMetaWithDefaults.txParams.gas,
|
||
|
'should have added the gas field',
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
8 years ago
|
describe('#addTx', function () {
|
||
7 years ago
|
it('should emit updates', function (done) {
|
||
8 years ago
|
const txMeta = {
|
||
|
id: '1',
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
8 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
7 years ago
|
txParams: {},
|
||
4 years ago
|
};
|
||
8 years ago
|
|
||
4 years ago
|
const eventNames = [
|
||
|
METAMASK_CONTROLLER_EVENTS.UPDATE_BADGE,
|
||
|
'1:unapproved',
|
||
|
];
|
||
4 years ago
|
const listeners = [];
|
||
7 years ago
|
eventNames.forEach((eventName) => {
|
||
4 years ago
|
listeners.push(
|
||
|
new Promise((resolve) => {
|
||
|
txController.once(eventName, (arg) => {
|
||
4 years ago
|
resolve(arg);
|
||
|
});
|
||
4 years ago
|
}),
|
||
4 years ago
|
);
|
||
|
});
|
||
7 years ago
|
Promise.all(listeners)
|
||
5 years ago
|
.then((returnValues) => {
|
||
4 years ago
|
assert.deepEqual(
|
||
|
returnValues.pop(),
|
||
|
txMeta,
|
||
|
'last event 1:unapproved should return txMeta',
|
||
4 years ago
|
);
|
||
|
done();
|
||
5 years ago
|
})
|
||
4 years ago
|
.catch(done);
|
||
|
txController.addTx(txMeta);
|
||
|
});
|
||
|
});
|
||
8 years ago
|
|
||
8 years ago
|
describe('#approveTransaction', function () {
|
||
5 years ago
|
it('does not overwrite set values', async function () {
|
||
4 years ago
|
const originalValue = '0x01';
|
||
5 years ago
|
const txMeta = {
|
||
8 years ago
|
id: '1',
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
8 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {
|
||
|
nonce: originalValue,
|
||
|
gas: originalValue,
|
||
|
gasPrice: originalValue,
|
||
|
},
|
||
4 years ago
|
};
|
||
4 years ago
|
// eslint-disable-next-line @babel/no-invalid-this
|
||
4 years ago
|
this.timeout(15000);
|
||
|
const wrongValue = '0x05';
|
||
8 years ago
|
|
||
4 years ago
|
txController.addTx(txMeta);
|
||
|
providerResultStub.eth_gasPrice = wrongValue;
|
||
|
providerResultStub.eth_estimateGas = '0x5209';
|
||
8 years ago
|
|
||
4 years ago
|
const signStub = sinon
|
||
|
.stub(txController, 'signTransaction')
|
||
4 years ago
|
.callsFake(() => Promise.resolve());
|
||
8 years ago
|
|
||
4 years ago
|
const pubStub = sinon
|
||
|
.stub(txController, 'publishTransaction')
|
||
|
.callsFake(() => {
|
||
4 years ago
|
txController.setTxHash('1', originalValue);
|
||
|
txController.txStateManager.setTxStatusSubmitted('1');
|
||
|
});
|
||
8 years ago
|
|
||
4 years ago
|
await txController.approveTransaction(txMeta.id);
|
||
|
const result = txController.txStateManager.getTx(txMeta.id);
|
||
|
const params = result.txParams;
|
||
8 years ago
|
|
||
4 years ago
|
assert.equal(params.gas, originalValue, 'gas unmodified');
|
||
|
assert.equal(params.gasPrice, originalValue, 'gas price unmodified');
|
||
|
assert.equal(result.hash, originalValue);
|
||
4 years ago
|
assert.equal(
|
||
|
result.status,
|
||
4 years ago
|
TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
'should have reached the submitted status.',
|
||
4 years ago
|
);
|
||
|
signStub.restore();
|
||
|
pubStub.restore();
|
||
|
});
|
||
|
});
|
||
8 years ago
|
|
||
8 years ago
|
describe('#sign replay-protected tx', function () {
|
||
5 years ago
|
it('prepares a tx with the chainId set', async function () {
|
||
4 years ago
|
txController.addTx(
|
||
|
{
|
||
|
id: '1',
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
},
|
||
|
noop,
|
||
4 years ago
|
);
|
||
|
const rawTx = await txController.signTransaction('1');
|
||
|
const ethTx = new EthTx(ethUtil.toBuffer(rawTx));
|
||
|
assert.equal(ethTx.getChainId(), 42);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#updateAndApproveTransaction', function () {
|
||
5 years ago
|
it('should update and approve transactions', async function () {
|
||
|
const txMeta = {
|
||
7 years ago
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
7 years ago
|
txParams: {
|
||
7 years ago
|
from: fromAccount.address,
|
||
7 years ago
|
to: '0x1678a085c290ebd122dc42cba69373b5953b831d',
|
||
|
gasPrice: '0x77359400',
|
||
|
gas: '0x7b0d',
|
||
|
nonce: '0x4b',
|
||
|
},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
4 years ago
|
};
|
||
|
txController.txStateManager.addTx(txMeta);
|
||
|
const approvalPromise = txController.updateAndApproveTransaction(txMeta);
|
||
|
const tx = txController.txStateManager.getTx(1);
|
||
|
assert.equal(tx.status, TRANSACTION_STATUSES.APPROVED);
|
||
|
await approvalPromise;
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#getChainId', function () {
|
||
|
it('returns 0 when the chainId is NaN', function () {
|
||
4 years ago
|
txController.networkStore = new ObservableStore('loading');
|
||
|
assert.equal(txController.getChainId(), 0);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
|
describe('#cancelTransaction', function () {
|
||
5 years ago
|
it('should emit a status change to rejected', function (done) {
|
||
7 years ago
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 0,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.REJECTED,
|
||
4 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 2,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.APPROVED,
|
||
4 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 3,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SIGNED,
|
||
4 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 4,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 5,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 6,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.FAILED,
|
||
4 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
},
|
||
4 years ago
|
]);
|
||
7 years ago
|
|
||
7 years ago
|
txController.once('tx:status-update', (txId, status) => {
|
||
|
try {
|
||
4 years ago
|
assert.equal(
|
||
|
status,
|
||
|
TRANSACTION_STATUSES.REJECTED,
|
||
|
'status should be rejected',
|
||
4 years ago
|
);
|
||
|
assert.equal(txId, 0, 'id should e 0');
|
||
|
done();
|
||
5 years ago
|
} catch (e) {
|
||
4 years ago
|
done(e);
|
||
5 years ago
|
}
|
||
4 years ago
|
});
|
||
7 years ago
|
|
||
4 years ago
|
txController.cancelTransaction(0);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
5 years ago
|
describe('#createSpeedUpTransaction', function () {
|
||
4 years ago
|
let addTxSpy;
|
||
|
let approveTransactionSpy;
|
||
|
let txParams;
|
||
|
let expectedTxParams;
|
||
6 years ago
|
|
||
5 years ago
|
beforeEach(function () {
|
||
4 years ago
|
addTxSpy = sinon.spy(txController, 'addTx');
|
||
|
approveTransactionSpy = sinon.spy(txController, 'approveTransaction');
|
||
6 years ago
|
|
||
|
txParams = {
|
||
|
nonce: '0x00',
|
||
|
from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4',
|
||
|
to: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4',
|
||
|
gas: '0x5209',
|
||
|
gasPrice: '0xa',
|
||
4 years ago
|
};
|
||
6 years ago
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams,
|
||
|
history: [{}],
|
||
|
},
|
||
4 years ago
|
]);
|
||
6 years ago
|
|
||
4 years ago
|
expectedTxParams = { ...txParams, gasPrice: '0xb' };
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
afterEach(function () {
|
||
4 years ago
|
addTxSpy.restore();
|
||
|
approveTransactionSpy.restore();
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('should call this.addTx and this.approveTransaction with the expected args', async function () {
|
||
4 years ago
|
await txController.createSpeedUpTransaction(1);
|
||
|
assert.equal(addTxSpy.callCount, 1);
|
||
6 years ago
|
|
||
4 years ago
|
const addTxArgs = addTxSpy.getCall(0).args[0];
|
||
|
assert.deepEqual(addTxArgs.txParams, expectedTxParams);
|
||
6 years ago
|
|
||
4 years ago
|
const { lastGasPrice, type } = addTxArgs;
|
||
4 years ago
|
assert.deepEqual(
|
||
|
{ lastGasPrice, type },
|
||
|
{
|
||
|
lastGasPrice: '0xa',
|
||
4 years ago
|
type: TRANSACTION_TYPES.RETRY,
|
||
4 years ago
|
},
|
||
4 years ago
|
);
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('should call this.approveTransaction with the id of the returned tx', async function () {
|
||
4 years ago
|
const result = await txController.createSpeedUpTransaction(1);
|
||
|
assert.equal(approveTransactionSpy.callCount, 1);
|
||
6 years ago
|
|
||
4 years ago
|
const approveTransactionArg = approveTransactionSpy.getCall(0).args[0];
|
||
|
assert.equal(result.id, approveTransactionArg);
|
||
|
});
|
||
6 years ago
|
|
||
5 years ago
|
it('should return the expected txMeta', async function () {
|
||
4 years ago
|
const result = await txController.createSpeedUpTransaction(1);
|
||
6 years ago
|
|
||
4 years ago
|
assert.deepEqual(result.txParams, expectedTxParams);
|
||
6 years ago
|
|
||
4 years ago
|
const { lastGasPrice, type } = result;
|
||
4 years ago
|
assert.deepEqual(
|
||
|
{ lastGasPrice, type },
|
||
|
{
|
||
|
lastGasPrice: '0xa',
|
||
4 years ago
|
type: TRANSACTION_TYPES.RETRY,
|
||
4 years ago
|
},
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
6 years ago
|
|
||
7 years ago
|
describe('#publishTransaction', function () {
|
||
4 years ago
|
let hash, txMeta;
|
||
7 years ago
|
beforeEach(function () {
|
||
4 years ago
|
hash =
|
||
4 years ago
|
'0x2a5523c6fa98b47b7d9b6c8320179785150b42a16bcff36b398c5062b65657e8';
|
||
7 years ago
|
txMeta = {
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
7 years ago
|
txParams: {},
|
||
|
metamaskNetworkId: currentNetworkId,
|
||
4 years ago
|
};
|
||
|
providerResultStub.eth_sendRawTransaction = hash;
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
it('should publish a tx, updates the rawTx when provided a one', async function () {
|
||
4 years ago
|
const rawTx =
|
||
4 years ago
|
'0x477b2e6553c917af0db0388ae3da62965ff1a184558f61b749d1266b2e6d024c';
|
||
|
txController.txStateManager.addTx(txMeta);
|
||
|
await txController.publishTransaction(txMeta.id, rawTx);
|
||
|
const publishedTx = txController.txStateManager.getTx(1);
|
||
|
assert.equal(publishedTx.hash, hash);
|
||
|
assert.equal(publishedTx.status, TRANSACTION_STATUSES.SUBMITTED);
|
||
|
});
|
||
5 years ago
|
|
||
|
it('should ignore the error "Transaction Failed: known transaction" and be as usual', async function () {
|
||
4 years ago
|
providerResultStub.eth_sendRawTransaction = async (_, __, ___, end) => {
|
||
4 years ago
|
end('Transaction Failed: known transaction');
|
||
|
};
|
||
4 years ago
|
const rawTx =
|
||
4 years ago
|
'0xf86204831e848082520894f231d46dd78806e1dd93442cf33c7671f853874880802ca05f973e540f2d3c2f06d3725a626b75247593cb36477187ae07ecfe0a4db3cf57a00259b52ee8c58baaa385fb05c3f96116e58de89bcc165cb3bfdfc708672fed8a';
|
||
|
txController.txStateManager.addTx(txMeta);
|
||
|
await txController.publishTransaction(txMeta.id, rawTx);
|
||
|
const publishedTx = txController.txStateManager.getTx(1);
|
||
4 years ago
|
assert.equal(
|
||
|
publishedTx.hash,
|
||
|
'0x2cc5a25744486f7383edebbf32003e5a66e18135799593d6b5cdd2bb43674f09',
|
||
4 years ago
|
);
|
||
|
assert.equal(publishedTx.status, TRANSACTION_STATUSES.SUBMITTED);
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
7 years ago
|
describe('#_markNonceDuplicatesDropped', function () {
|
||
|
it('should mark all nonce duplicates as dropped without marking the confirmed transaction as dropped', function () {
|
||
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
txParams: { nonce: '0x01' },
|
||
|
},
|
||
|
{
|
||
|
id: 2,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
txParams: { nonce: '0x01' },
|
||
|
},
|
||
|
{
|
||
|
id: 3,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
txParams: { nonce: '0x01' },
|
||
|
},
|
||
|
{
|
||
|
id: 4,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
txParams: { nonce: '0x01' },
|
||
|
},
|
||
|
{
|
||
|
id: 5,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
txParams: { nonce: '0x01' },
|
||
|
},
|
||
|
{
|
||
|
id: 6,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
txParams: { nonce: '0x01' },
|
||
|
},
|
||
|
{
|
||
|
id: 7,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
history: [{}],
|
||
|
txParams: { nonce: '0x01' },
|
||
|
},
|
||
4 years ago
|
]);
|
||
|
txController._markNonceDuplicatesDropped(1);
|
||
|
const confirmedTx = txController.txStateManager.getTx(1);
|
||
4 years ago
|
const droppedTxs = txController.txStateManager.getFilteredTxList({
|
||
|
nonce: '0x01',
|
||
4 years ago
|
status: TRANSACTION_STATUSES.DROPPED,
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.equal(
|
||
|
confirmedTx.status,
|
||
4 years ago
|
TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
'the confirmedTx should remain confirmed',
|
||
4 years ago
|
);
|
||
|
assert.equal(droppedTxs.length, 6, 'their should be 6 dropped txs');
|
||
|
});
|
||
|
});
|
||
7 years ago
|
|
||
4 years ago
|
describe('#_determineTransactionType', function () {
|
||
|
it('should return a simple send type when to is truthy but data is falsy', async function () {
|
||
|
const result = await txController._determineTransactionType({
|
||
6 years ago
|
to: '0xabc',
|
||
|
data: '',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.SENT_ETHER,
|
||
4 years ago
|
getCodeResponse: null,
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should return a token transfer type when data is for the respective method call', async function () {
|
||
|
const result = await txController._determineTransactionType({
|
||
6 years ago
|
to: '0xabc',
|
||
4 years ago
|
data:
|
||
|
'0xa9059cbb0000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C970000000000000000000000000000000000000000000000000000000000000000a',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.TOKEN_METHOD_TRANSFER,
|
||
4 years ago
|
getCodeResponse: undefined,
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should return a token approve type when data is for the respective method call', async function () {
|
||
|
const result = await txController._determineTransactionType({
|
||
6 years ago
|
to: '0xabc',
|
||
4 years ago
|
data:
|
||
|
'0x095ea7b30000000000000000000000002f318C334780961FB129D2a6c30D0763d9a5C9700000000000000000000000000000000000000000000000000000000000000005',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.TOKEN_METHOD_APPROVE,
|
||
4 years ago
|
getCodeResponse: undefined,
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should return a contract deployment type when to is falsy and there is data', async function () {
|
||
|
const result = await txController._determineTransactionType({
|
||
6 years ago
|
to: '',
|
||
|
data: '0xabd',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.DEPLOY_CONTRACT,
|
||
4 years ago
|
getCodeResponse: undefined,
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should return a simple send type with a 0x getCodeResponse when there is data and but the to address is not a contract address', async function () {
|
||
|
const result = await txController._determineTransactionType({
|
||
6 years ago
|
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
|
||
|
data: '0xabd',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.SENT_ETHER,
|
||
4 years ago
|
getCodeResponse: '0x',
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should return a simple send type with a null getCodeResponse when to is truthy and there is data and but getCode returns an error', async function () {
|
||
|
const result = await txController._determineTransactionType({
|
||
6 years ago
|
to: '0xabc',
|
||
|
data: '0xabd',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.SENT_ETHER,
|
||
4 years ago
|
getCodeResponse: null,
|
||
4 years ago
|
});
|
||
|
});
|
||
6 years ago
|
|
||
4 years ago
|
it('should return a contract interaction type with the correct getCodeResponse when to is truthy and there is data and it is not a token transaction', async function () {
|
||
6 years ago
|
const _providerResultStub = {
|
||
|
// 1 gwei
|
||
|
eth_gasPrice: '0x0de0b6b3a7640000',
|
||
|
// by default, all accounts are external accounts (not contracts)
|
||
|
eth_getCode: '0xa',
|
||
4 years ago
|
};
|
||
4 years ago
|
const _provider = createTestProviderTools({
|
||
|
scaffold: _providerResultStub,
|
||
4 years ago
|
}).provider;
|
||
|
const _fromAccount = getTestAccounts()[0];
|
||
|
const _blockTrackerStub = new EventEmitter();
|
||
|
_blockTrackerStub.getCurrentBlock = noop;
|
||
|
_blockTrackerStub.getLatestBlock = noop;
|
||
6 years ago
|
const _txController = new TransactionController({
|
||
|
provider: _provider,
|
||
4 years ago
|
getGasPrice() {
|
||
4 years ago
|
return '0xee6b2800';
|
||
5 years ago
|
},
|
||
6 years ago
|
networkStore: new ObservableStore(currentNetworkId),
|
||
4 years ago
|
getCurrentChainId: () => currentChainId,
|
||
6 years ago
|
txHistoryLimit: 10,
|
||
|
blockTracker: _blockTrackerStub,
|
||
4 years ago
|
signTransaction: (ethTx) =>
|
||
|
new Promise((resolve) => {
|
||
4 years ago
|
ethTx.sign(_fromAccount.key);
|
||
|
resolve();
|
||
4 years ago
|
}),
|
||
4 years ago
|
getParticipateInMetrics: () => false,
|
||
4 years ago
|
});
|
||
4 years ago
|
const result = await _txController._determineTransactionType({
|
||
6 years ago
|
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
|
||
|
data: 'abd',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.CONTRACT_INTERACTION,
|
||
4 years ago
|
getCodeResponse: '0x0a',
|
||
4 years ago
|
});
|
||
|
});
|
||
5 years ago
|
|
||
4 years ago
|
it('should return a contract interaction type with the correct getCodeResponse when to is a contract address and data is falsy', async function () {
|
||
5 years ago
|
const _providerResultStub = {
|
||
|
// 1 gwei
|
||
|
eth_gasPrice: '0x0de0b6b3a7640000',
|
||
|
// by default, all accounts are external accounts (not contracts)
|
||
|
eth_getCode: '0xa',
|
||
4 years ago
|
};
|
||
4 years ago
|
const _provider = createTestProviderTools({
|
||
|
scaffold: _providerResultStub,
|
||
4 years ago
|
}).provider;
|
||
|
const _fromAccount = getTestAccounts()[0];
|
||
|
const _blockTrackerStub = new EventEmitter();
|
||
|
_blockTrackerStub.getCurrentBlock = noop;
|
||
|
_blockTrackerStub.getLatestBlock = noop;
|
||
5 years ago
|
const _txController = new TransactionController({
|
||
|
provider: _provider,
|
||
4 years ago
|
getGasPrice() {
|
||
4 years ago
|
return '0xee6b2800';
|
||
5 years ago
|
},
|
||
5 years ago
|
networkStore: new ObservableStore(currentNetworkId),
|
||
4 years ago
|
getCurrentChainId: () => currentChainId,
|
||
5 years ago
|
txHistoryLimit: 10,
|
||
|
blockTracker: _blockTrackerStub,
|
||
4 years ago
|
signTransaction: (ethTx) =>
|
||
|
new Promise((resolve) => {
|
||
4 years ago
|
ethTx.sign(_fromAccount.key);
|
||
|
resolve();
|
||
4 years ago
|
}),
|
||
4 years ago
|
getParticipateInMetrics: () => false,
|
||
4 years ago
|
});
|
||
4 years ago
|
const result = await _txController._determineTransactionType({
|
||
5 years ago
|
to: '0x9e673399f795D01116e9A8B2dD2F156705131ee9',
|
||
|
data: '',
|
||
4 years ago
|
});
|
||
4 years ago
|
assert.deepEqual(result, {
|
||
4 years ago
|
type: TRANSACTION_TYPES.CONTRACT_INTERACTION,
|
||
4 years ago
|
getCodeResponse: '0x0a',
|
||
4 years ago
|
});
|
||
|
});
|
||
|
});
|
||
6 years ago
|
|
||
7 years ago
|
describe('#getPendingTransactions', function () {
|
||
5 years ago
|
it('should show only submitted and approved transactions as pending transaction', function () {
|
||
7 years ago
|
txController.txStateManager._saveTxList([
|
||
4 years ago
|
{
|
||
|
id: 1,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.UNAPPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
},
|
||
|
{
|
||
|
id: 2,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.REJECTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 3,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.APPROVED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 4,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SIGNED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 5,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.SUBMITTED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 6,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.CONFIRMED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
|
{
|
||
|
id: 7,
|
||
4 years ago
|
status: TRANSACTION_STATUSES.FAILED,
|
||
4 years ago
|
metamaskNetworkId: currentNetworkId,
|
||
|
txParams: {},
|
||
|
history: [{}],
|
||
|
},
|
||
4 years ago
|
]);
|
||
5 years ago
|
|
||
4 years ago
|
assert.equal(
|
||
|
txController.pendingTxTracker.getPendingTransactions().length,
|
||
|
2,
|
||
4 years ago
|
);
|
||
4 years ago
|
const states = txController.pendingTxTracker
|
||
|
.getPendingTransactions()
|
||
4 years ago
|
.map((tx) => tx.status);
|
||
4 years ago
|
assert.ok(
|
||
|
states.includes(TRANSACTION_STATUSES.APPROVED),
|
||
|
'includes approved',
|
||
4 years ago
|
);
|
||
4 years ago
|
assert.ok(
|
||
|
states.includes(TRANSACTION_STATUSES.SUBMITTED),
|
||
|
'includes submitted',
|
||
4 years ago
|
);
|
||
|
});
|
||
|
});
|
||
|
});
|