aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCsaba Solya <csaba.solya@gmail.com>2018-05-30 22:24:40 +0800
committerCsaba Solya <csaba.solya@gmail.com>2018-05-30 22:24:40 +0800
commit6affd8f9492e04cdc81007e4f5390e4faa56499d (patch)
tree8cedeb0cb4c84f8e9272e263ef73ccb68408e435
parentafb578886134663506320e7462935d3431512a9a (diff)
downloadtangerine-wallet-browser-6affd8f9492e04cdc81007e4f5390e4faa56499d.tar.gz
tangerine-wallet-browser-6affd8f9492e04cdc81007e4f5390e4faa56499d.tar.zst
tangerine-wallet-browser-6affd8f9492e04cdc81007e4f5390e4faa56499d.zip
adding transaction controller tests
-rw-r--r--app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js2
-rw-r--r--test/unit/app/controllers/transactions/tx-controller-test.js17
2 files changed, 18 insertions, 1 deletions
diff --git a/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js b/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js
index f6fbee678..c52e58863 100644
--- a/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js
+++ b/app/scripts/controllers/transactions/lib/recipient-blacklist-checker.js
@@ -30,7 +30,7 @@ async function checkAccount (networkId, account) {
const damnedAccounts = await keyring.getAccounts()
for (let i = 0; i < damnedAccounts.length; i++) {
if (damnedAccounts[i].toLowerCase() === accountToCheck) {
- throw new Error('this is a public account')
+ throw new Error('Recipient is a public account')
}
}
} \ No newline at end of file
diff --git a/test/unit/app/controllers/transactions/tx-controller-test.js b/test/unit/app/controllers/transactions/tx-controller-test.js
index 1f32a0f37..9bdfe7c1a 100644
--- a/test/unit/app/controllers/transactions/tx-controller-test.js
+++ b/test/unit/app/controllers/transactions/tx-controller-test.js
@@ -185,6 +185,23 @@ describe('Transaction Controller', function () {
.catch(done)
})
+ it('should fail if recipient is public', function (done) {
+ txController.networkStore = new ObservableStore(1)
+ txController.addUnapprovedTransaction({ from: '0x1678a085c290ebd122dc42cba69373b5953b831d', to: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' })
+ .catch((err) => {
+ if (err.message === 'Recipient is a public account') done()
+ else done(err)
+ })
+ })
+
+ it('should not fail if recipient is public but not on mainnet', function (done) {
+ txController.once('newUnapprovedTx', (txMetaFromEmit) => {
+ assert(txMetaFromEmit, 'txMeta is falsey')
+ done()
+ })
+ txController.addUnapprovedTransaction({ from: '0x1678a085c290ebd122dc42cba69373b5953b831d', to: '0x0d1d4e623D10F9FBA5Db95830F7d3839406C6AF2' })
+ .catch(done)
+ })
})
describe('#addTxGasDefaults', function () {