aboutsummaryrefslogtreecommitdiffstats
path: root/test/unit/tx-controller-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'test/unit/tx-controller-test.js')
-rw-r--r--test/unit/tx-controller-test.js32
1 files changed, 14 insertions, 18 deletions
diff --git a/test/unit/tx-controller-test.js b/test/unit/tx-controller-test.js
index 36f3e1c68..cc99afee4 100644
--- a/test/unit/tx-controller-test.js
+++ b/test/unit/tx-controller-test.js
@@ -1,11 +1,12 @@
const assert = require('assert')
const ethUtil = require('ethereumjs-util')
const EthTx = require('ethereumjs-tx')
+const EthjsQuery = require('ethjs-query')
const ObservableStore = require('obs-store')
const sinon = require('sinon')
const TransactionController = require('../../app/scripts/controllers/transactions')
const TxGasUtils = require('../../app/scripts/lib/tx-gas-utils')
-const { createStubedProvider, createEthJsQueryStub } = require('../stub/provider')
+const { createTestProviderTools } = require('../stub/provider')
const noop = () => true
const currentNetworkId = 42
@@ -14,11 +15,18 @@ const privKey = new Buffer('8718b9618a37d1fc78c436511fc6df3c8258d3250635bba617f3
describe('Transaction Controller', function () {
- let txController, provider, providerResultStub
+ let txController, provider, providerResultStub, testBlockchain
beforeEach(function () {
- providerResultStub = {}
- provider = createStubedProvider(providerResultStub)
+ providerResultStub = {
+ // 1 gwei
+ eth_gasPrice: '0x0de0b6b3a7640000',
+ // by default, all accounts are external accounts (not contracts)
+ eth_getCode: '0x',
+ }
+ const providerTools = createTestProviderTools({ scaffold: providerResultStub })
+ provider = providerTools.provider
+ testBlockchain = providerTools.testBlockchain
txController = new TransactionController({
provider,
@@ -30,10 +38,7 @@ describe('Transaction Controller', function () {
resolve()
}),
})
- txController.query = createEthJsQueryStub(provider)
- txController.txGasUtil.query = createEthJsQueryStub(provider)
txController.nonceTracker.getNonceLock = () => Promise.resolve({ nextNonce: 0, releaseLock: noop })
- txController.txProviderUtils = new TxGasUtils(txController.provider)
})
describe('#getState', function () {
@@ -155,15 +160,6 @@ describe('Transaction Controller', function () {
})
describe('#addUnapprovedTransaction', function () {
- let addTxDefaults
- beforeEach(() => {
- addTxDefaults = txController.addTxDefaults
- txController.addTxDefaults = function addTxDefaultsStub () { return Promise.resolve() }
-
- })
- afterEach(() => {
- txController.addTxDefaults = addTxDefaults
- })
it('should add an unapproved transaction and return a valid txMeta', function (done) {
txController.addUnapprovedTransaction({})
@@ -219,7 +215,7 @@ describe('Transaction Controller', function () {
var sample = {
value: '0x01',
}
- txController.txProviderUtils.validateTxParams(sample).then(() => {
+ txController.txGasUtil.validateTxParams(sample).then(() => {
done()
}).catch(done)
})
@@ -228,7 +224,7 @@ describe('Transaction Controller', function () {
var sample = {
value: '-0x01',
}
- txController.txProviderUtils.validateTxParams(sample)
+ txController.txGasUtil.validateTxParams(sample)
.then(() => done('expected to thrown on negativity values but didn\'t'))
.catch((err) => {
assert.ok(err, 'error')