Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Fixes broken seed overlay trigger #14002

Merged
merged 1 commit into from
May 3, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -1688,6 +1688,7 @@ const getStateInfo = (state, parsedData) => {
}
} catch (e) {
console.error(e)
state = ledgerState.setAboutProp(state, 'status', ledgerStatuses.CORRUPTED_SEED)
}

state = ledgerState.mergeInfoProp(state, newInfo)
Expand Down
28 changes: 28 additions & 0 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ const appActions = require('../../../../../js/actions/appActions')
const batPublisher = require('bat-publisher')
const ledgerMediaProviders = require('../../../../../app/common/constants/ledgerMediaProviders')
const fs = require('fs')
const ledgerStatuses = require('../../../../../app/common/constants/ledgerStatuses')

describe('ledger api unit tests', function () {
let ledgerApi
Expand Down Expand Up @@ -161,6 +162,10 @@ describe('ledger api unit tests', function () {
isReadyToReconcile: () => {}
}
window.getWalletPassphrase = (parsedData) => {
if (walletPassphraseReturn === 'error') {
throw TypeError('Invalid entropy')
}

return walletPassphraseReturn
}
ledgerClient.prototype.boolion = function (value) { return false }
Expand Down Expand Up @@ -2002,6 +2007,29 @@ describe('ledger api unit tests', function () {
}))
assert.deepEqual(result.toJS(), expectedState.toJS())
})

it('seed is broken', function () {
const wrongSeed = Immutable
.fromJS(seedData)
.setIn(['properties', 'wallet', 'keyinfo', 'seed'], Buffer.from([0, 0]))
.toJS()

walletPassphraseReturn = 'error'

const result = ledgerApi.getStateInfo(defaultAppState, wrongSeed)
const expectedState = defaultAppState
.setIn(['ledger', 'info'], Immutable.fromJS({
'created': true,
'creating': false,
'paymentId': '21951877-5998-4acf-9302-4a7b101c9188',
'reconcileFrequency': 30,
'reconcileStamp': 1
}))
.setIn(['ledger', 'about', 'status'], ledgerStatuses.CORRUPTED_SEED)

assert.deepEqual(result.toJS(), expectedState.toJS())
assert(getWalletPassphraseSpy.withArgs(wrongSeed).calledOnce)
})
})
})

Expand Down