mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
test - unit - tx-controller-test - add history object to txMeta when using internal calls
This commit is contained in:
parent
630e2300f4
commit
afdefc58e9
@ -53,9 +53,9 @@ describe('Transaction Controller', function () {
|
||||
describe('#getUnapprovedTxCount', function () {
|
||||
it('should return the number of unapproved txs', function () {
|
||||
txController.txStateManager._saveTxList([
|
||||
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
||||
{ id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
||||
{ id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {} },
|
||||
{ id: 1, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||
{ id: 2, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||
{ id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||
])
|
||||
const unapprovedTxCount = txController.getUnapprovedTxCount()
|
||||
assert.equal(unapprovedTxCount, 3, 'should be 3')
|
||||
@ -65,9 +65,9 @@ describe('Transaction Controller', function () {
|
||||
describe('#getPendingTxCount', function () {
|
||||
it('should return the number of pending txs', function () {
|
||||
txController.txStateManager._saveTxList([
|
||||
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
|
||||
{ id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
|
||||
{ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {} },
|
||||
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||
{ id: 2, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||
{ id: 3, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams: {}, history: [] },
|
||||
])
|
||||
const pendingTxCount = txController.getPendingTxCount()
|
||||
assert.equal(pendingTxCount, 3, 'should be 3')
|
||||
@ -83,15 +83,15 @@ describe('Transaction Controller', function () {
|
||||
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||
}
|
||||
txController.txStateManager._saveTxList([
|
||||
{id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams},
|
||||
{id: 0, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 1, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 2, status: 'confirmed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 3, status: 'unapproved', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 4, status: 'rejected', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 5, status: 'approved', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 6, status: 'signed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 7, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
{id: 8, status: 'failed', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
])
|
||||
})
|
||||
|
||||
@ -188,24 +188,22 @@ describe('Transaction Controller', function () {
|
||||
})
|
||||
|
||||
describe('#addTxGasDefaults', function () {
|
||||
it('should add the tx defaults if their are none', function (done) {
|
||||
it('should add the tx defaults if their are none', async () => {
|
||||
const txMeta = {
|
||||
'txParams': {
|
||||
'from': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||
'to': '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||
txParams: {
|
||||
from: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||
to: '0xc684832530fcbddae4b4230a47e991ddcec2831d',
|
||||
},
|
||||
history: [],
|
||||
}
|
||||
providerResultStub.eth_gasPrice = '4a817c800'
|
||||
providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' }
|
||||
providerResultStub.eth_estimateGas = '5209'
|
||||
txController.addTxGasDefaults(txMeta)
|
||||
.then((txMetaWithDefaults) => {
|
||||
assert(txMetaWithDefaults.txParams.value, '0x0', 'should have added 0x0 as the value')
|
||||
assert(txMetaWithDefaults.txParams.gasPrice, 'should have added the gas price')
|
||||
assert(txMetaWithDefaults.txParams.gas, 'should have added the gas field')
|
||||
done()
|
||||
})
|
||||
.catch(done)
|
||||
providerResultStub.eth_gasPrice = '4a817c800'
|
||||
providerResultStub.eth_getBlockByNumber = { gasLimit: '47b784' }
|
||||
providerResultStub.eth_estimateGas = '5209'
|
||||
|
||||
const txMetaWithDefaults = await txController.addTxGasDefaults(txMeta)
|
||||
assert(txMetaWithDefaults.txParams.value, '0x0', 'should have added 0x0 as the value')
|
||||
assert(txMetaWithDefaults.txParams.gasPrice, 'should have added the gas price')
|
||||
assert(txMetaWithDefaults.txParams.gas, 'should have added the gas field')
|
||||
})
|
||||
})
|
||||
|
||||
@ -378,7 +376,7 @@ describe('Transaction Controller', function () {
|
||||
data: '0x0',
|
||||
}
|
||||
txController.txStateManager._saveTxList([
|
||||
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams },
|
||||
{ id: 1, status: 'submitted', metamaskNetworkId: currentNetworkId, txParams, history: [] },
|
||||
])
|
||||
txController.retryTransaction(1)
|
||||
.then((txMeta) => {
|
||||
|
Loading…
Reference in New Issue
Block a user