aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorkumavis <aaron@kumavis.me>2017-01-13 18:00:11 +0800
committerkumavis <aaron@kumavis.me>2017-01-13 18:00:11 +0800
commit29e83d71a82bfdbeadc9fbecfa97d73ef11fecfb (patch)
treeab5dc7ae04109c0b78a33db14637e71a267c6635 /test
parentcc5e9aca4fa2a1e78c49be680405d93ac918bccf (diff)
downloadtangerine-wallet-browser-29e83d71a82bfdbeadc9fbecfa97d73ef11fecfb.tar.gz
tangerine-wallet-browser-29e83d71a82bfdbeadc9fbecfa97d73ef11fecfb.tar.zst
tangerine-wallet-browser-29e83d71a82bfdbeadc9fbecfa97d73ef11fecfb.zip
background - handle tx finalization in controllers instead of provider-engine
Diffstat (limited to 'test')
-rw-r--r--test/unit/metamask-controller-test.js18
-rw-r--r--test/unit/tx-manager-test.js31
2 files changed, 27 insertions, 22 deletions
diff --git a/test/unit/metamask-controller-test.js b/test/unit/metamask-controller-test.js
index 414610404..a6164c9a0 100644
--- a/test/unit/metamask-controller-test.js
+++ b/test/unit/metamask-controller-test.js
@@ -25,24 +25,6 @@ describe('MetaMaskController', function() {
this.sinon.restore()
})
- describe('#enforceTxValidations', function () {
- it('returns null for positive values', function() {
- var sample = {
- value: '0x01'
- }
- var res = controller.enforceTxValidations(sample)
- assert.equal(res, null, 'no error')
- })
-
-
- it('returns error for negative values', function() {
- var sample = {
- value: '-0x01'
- }
- var res = controller.enforceTxValidations(sample)
- assert.ok(res, 'error')
- })
- })
})
diff --git a/test/unit/tx-manager-test.js b/test/unit/tx-manager-test.js
index be16facad..d5d386234 100644
--- a/test/unit/tx-manager-test.js
+++ b/test/unit/tx-manager-test.js
@@ -18,6 +18,27 @@ describe('Transaction Manager', function() {
})
})
+ describe('#validateTxParams', function () {
+ it('returns null for positive values', function() {
+ var sample = {
+ value: '0x01'
+ }
+ var res = txManager.validateTxParams(sample, (err) => {
+ assert.equal(err, null, 'no error')
+ })
+ })
+
+
+ it('returns error for negative values', function() {
+ var sample = {
+ value: '-0x01'
+ }
+ var res = txManager.validateTxParams(sample, (err) => {
+ assert.ok(err, 'error')
+ })
+ })
+ })
+
describe('#getTxList', function() {
it('when new should return empty array', function() {
var result = txManager.getTxList()
@@ -100,11 +121,12 @@ describe('Transaction Manager', function() {
it('should emit a signed event to signal the exciton of callback', (done) => {
this.timeout(10000)
var tx = { id: 1, status: 'unapproved' }
- let onTxDoneCb = function (err, txId) {
+ let onTxDoneCb = function () {
assert(true, 'event listener has been triggered and onTxDoneCb executed')
done()
}
- txManager.addTx(tx, onTxDoneCb)
+ txManager.addTx(tx)
+ txManager.on('1:signed', onTxDoneCb)
txManager.setTxStatusSigned(1)
})
})
@@ -112,7 +134,7 @@ describe('Transaction Manager', function() {
describe('#setTxStatusRejected', function() {
it('sets the tx status to rejected', function() {
var tx = { id: 1, status: 'unapproved' }
- txManager.addTx(tx, onTxDoneCb)
+ txManager.addTx(tx)
txManager.setTxStatusRejected(1)
var result = txManager.getTxList()
assert.ok(Array.isArray(result))
@@ -123,11 +145,12 @@ describe('Transaction Manager', function() {
it('should emit a rejected event to signal the exciton of callback', (done) => {
this.timeout(10000)
var tx = { id: 1, status: 'unapproved' }
+ txManager.addTx(tx)
let onTxDoneCb = function (err, txId) {
assert(true, 'event listener has been triggered and onTxDoneCb executed')
done()
}
- txManager.addTx(tx, onTxDoneCb)
+ txManager.on('1:rejected', onTxDoneCb)
txManager.setTxStatusRejected(1)
})