mirror of
https://github.com/kremalicious/metamask-extension.git
synced 2024-12-23 09:52:26 +01:00
b1d090ac4d
* add permissions controller, log, middleware, and restricted method unit tests * fix permissions-related bugs * convert permissions log to controller-like class * add permissions unit test coverage requirements * update rpc-cap Co-Authored-By: Whymarrh Whitby <whymarrh.whitby@gmail.com> Co-Authored-By: Mark Stacey <markjstacey@gmail.com>
36 lines
901 B
JavaScript
36 lines
901 B
JavaScript
import { strict as assert } from 'assert'
|
|
|
|
import getRestrictedMethods
|
|
from '../../../../../app/scripts/controllers/permissions/restrictedMethods'
|
|
|
|
describe('restricted methods', function () {
|
|
|
|
// this method is tested extensively in other permissions tests
|
|
describe('eth_accounts', function () {
|
|
|
|
it('handles failure', async function () {
|
|
const restrictedMethods = getRestrictedMethods({
|
|
getKeyringAccounts: async () => {
|
|
throw new Error('foo')
|
|
},
|
|
})
|
|
|
|
const res = {}
|
|
restrictedMethods.eth_accounts.method(null, res, null, (err) => {
|
|
|
|
const fooError = new Error('foo')
|
|
|
|
assert.deepEqual(
|
|
err, fooError,
|
|
'should end with expected error'
|
|
)
|
|
|
|
assert.deepEqual(
|
|
res, { error: fooError },
|
|
'response should have expected error and no result'
|
|
)
|
|
})
|
|
})
|
|
})
|
|
})
|