|
|
@ -1171,11 +1171,35 @@ describe('Transaction Controller', function () { |
|
|
|
let approveTransactionSpy; |
|
|
|
let approveTransactionSpy; |
|
|
|
let txParams; |
|
|
|
let txParams; |
|
|
|
let expectedTxParams; |
|
|
|
let expectedTxParams; |
|
|
|
|
|
|
|
const selectedAddress = '0x1678a085c290ebd122dc42cba69373b5953b831d'; |
|
|
|
|
|
|
|
const recipientAddress = '0xc42edfcc21ed14dda456aa0756c153f7985d8813'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
let getSelectedAddress, |
|
|
|
|
|
|
|
getPermittedAccounts, |
|
|
|
|
|
|
|
getDefaultGasFees, |
|
|
|
|
|
|
|
getDefaultGasLimit; |
|
|
|
|
|
|
|
|
|
|
|
beforeEach(function () { |
|
|
|
beforeEach(function () { |
|
|
|
addTransactionSpy = sinon.spy(txController, 'addTransaction'); |
|
|
|
addTransactionSpy = sinon.spy(txController, 'addTransaction'); |
|
|
|
approveTransactionSpy = sinon.spy(txController, 'approveTransaction'); |
|
|
|
approveTransactionSpy = sinon.spy(txController, 'approveTransaction'); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const hash = |
|
|
|
|
|
|
|
'0x2a5523c6fa98b47b7d9b6c8320179785150b42a16bcff36b398c5062b65657e8'; |
|
|
|
|
|
|
|
providerResultStub.eth_sendRawTransaction = hash; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
getSelectedAddress = sinon |
|
|
|
|
|
|
|
.stub(txController, 'getSelectedAddress') |
|
|
|
|
|
|
|
.returns(selectedAddress); |
|
|
|
|
|
|
|
getDefaultGasFees = sinon |
|
|
|
|
|
|
|
.stub(txController, '_getDefaultGasFees') |
|
|
|
|
|
|
|
.returns({}); |
|
|
|
|
|
|
|
getDefaultGasLimit = sinon |
|
|
|
|
|
|
|
.stub(txController, '_getDefaultGasLimit') |
|
|
|
|
|
|
|
.returns({}); |
|
|
|
|
|
|
|
getPermittedAccounts = sinon |
|
|
|
|
|
|
|
.stub(txController, 'getPermittedAccounts') |
|
|
|
|
|
|
|
.returns([selectedAddress]); |
|
|
|
|
|
|
|
|
|
|
|
txParams = { |
|
|
|
txParams = { |
|
|
|
nonce: '0x00', |
|
|
|
nonce: '0x00', |
|
|
|
from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4', |
|
|
|
from: '0xB09d8505E1F4EF1CeA089D47094f5DD3464083d4', |
|
|
@ -1201,6 +1225,10 @@ describe('Transaction Controller', function () { |
|
|
|
afterEach(function () { |
|
|
|
afterEach(function () { |
|
|
|
addTransactionSpy.restore(); |
|
|
|
addTransactionSpy.restore(); |
|
|
|
approveTransactionSpy.restore(); |
|
|
|
approveTransactionSpy.restore(); |
|
|
|
|
|
|
|
getSelectedAddress.restore(); |
|
|
|
|
|
|
|
getPermittedAccounts.restore(); |
|
|
|
|
|
|
|
getDefaultGasFees.restore(); |
|
|
|
|
|
|
|
getDefaultGasLimit.restore(); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
it('should call this.addTransaction and this.approveTransaction with the expected args', async function () { |
|
|
|
it('should call this.addTransaction and this.approveTransaction with the expected args', async function () { |
|
|
@ -1242,6 +1270,52 @@ describe('Transaction Controller', function () { |
|
|
|
}, |
|
|
|
}, |
|
|
|
); |
|
|
|
); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should add only 1 speedup transaction when called twice with same actionId', async function () { |
|
|
|
|
|
|
|
const txMeta = await txController.addUnapprovedTransaction({ |
|
|
|
|
|
|
|
from: selectedAddress, |
|
|
|
|
|
|
|
to: recipientAddress, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await txController.approveTransaction(txMeta.id); |
|
|
|
|
|
|
|
await txController.createSpeedUpTransaction( |
|
|
|
|
|
|
|
txMeta.id, |
|
|
|
|
|
|
|
{}, |
|
|
|
|
|
|
|
{ actionId: 12345 }, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
const transactionCount1 = |
|
|
|
|
|
|
|
txController.txStateManager.getTransactions().length; |
|
|
|
|
|
|
|
await txController.createSpeedUpTransaction( |
|
|
|
|
|
|
|
txMeta.id, |
|
|
|
|
|
|
|
{}, |
|
|
|
|
|
|
|
{ actionId: 12345 }, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
const transactionCount2 = |
|
|
|
|
|
|
|
txController.txStateManager.getTransactions().length; |
|
|
|
|
|
|
|
assert.equal(transactionCount1, transactionCount2); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
it('should add multiple transactions when called with different actionId', async function () { |
|
|
|
|
|
|
|
const txMeta = await txController.addUnapprovedTransaction({ |
|
|
|
|
|
|
|
from: selectedAddress, |
|
|
|
|
|
|
|
to: recipientAddress, |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
await txController.approveTransaction(txMeta.id); |
|
|
|
|
|
|
|
await txController.createSpeedUpTransaction( |
|
|
|
|
|
|
|
txMeta.id, |
|
|
|
|
|
|
|
{}, |
|
|
|
|
|
|
|
{ actionId: 12345 }, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
const transactionCount1 = |
|
|
|
|
|
|
|
txController.txStateManager.getTransactions().length; |
|
|
|
|
|
|
|
await txController.createSpeedUpTransaction( |
|
|
|
|
|
|
|
txMeta.id, |
|
|
|
|
|
|
|
{}, |
|
|
|
|
|
|
|
{ actionId: 11111 }, |
|
|
|
|
|
|
|
); |
|
|
|
|
|
|
|
const transactionCount2 = |
|
|
|
|
|
|
|
txController.txStateManager.getTransactions().length; |
|
|
|
|
|
|
|
assert.equal(transactionCount1 + 1, transactionCount2); |
|
|
|
|
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
|
|
|
|
describe('#signTransaction', function () { |
|
|
|
describe('#signTransaction', function () { |
|
|
|