* origin/develop: (45 commits) eth-block-tracker@5.0.1 (#10737) Allow 11 characters in symbol for RPC (#10670) security - update SES lockdown (#10663) build - refactor build system for easier configuration (#10718) ci - cache deps before patch-package (#10735) Additional swaps network support (#10721) Update @metamask/controllers to v6.2.1 (#10701) Fix 10562 - Hide the suggested token pane when not on Mainnet or test network (#10702) Fix mismatchedChain typo in custom network approval screen (#10723) Fix 10706 - Prevent autocomplete from add token input (#10700) fix: remove unused `metamask.rpcUrl` from redux state + fix tests to reflect that (#10714) rule out empty string for symbol (#10712) Removing hard references to 12 word seed phrases in copy (#10704) Add MetaMask to list of BIP44 HD path examples (#10703) resolve issue with missing template error (#10692) Delete setupFetchDebugging.js (#10636) Excluding sourcemaps comment in production builds (#10695) deps - remove "remotedev-server" (#10687) Adding default properties to NetworkForm (#10682) make migration more safe (#10689) ...feature/default_network_editable
commit
68d3756528
After Width: | Height: | Size: 2.2 KiB |
@ -1,6 +1,6 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import ethUtil from 'ethereumjs-util'; |
import ethUtil from 'ethereumjs-util'; |
||||||
import accountImporter from '../../../app/scripts/account-import-strategies'; |
import accountImporter from '.'; |
||||||
|
|
||||||
describe('Account Import Strategies', function () { |
describe('Account Import Strategies', function () { |
||||||
const privkey = |
const privkey = |
@ -1,7 +1,7 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
import CachedBalancesController from '../../../../app/scripts/controllers/cached-balances'; |
import { KOVAN_CHAIN_ID } from '../../../shared/constants/network'; |
||||||
import { KOVAN_CHAIN_ID } from '../../../../shared/constants/network'; |
import CachedBalancesController from './cached-balances'; |
||||||
|
|
||||||
describe('CachedBalancesController', function () { |
describe('CachedBalancesController', function () { |
||||||
describe('updateCachedBalances', function () { |
describe('updateCachedBalances', function () { |
@ -1,6 +1,6 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
import EnsController from '../../../../app/scripts/controllers/ens'; |
import EnsController from '.'; |
||||||
|
|
||||||
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; |
const ZERO_ADDRESS = '0x0000000000000000000000000000000000000000'; |
||||||
const ZERO_X_ERROR_ADDRESS = '0x'; |
const ZERO_X_ERROR_ADDRESS = '0x'; |
File diff suppressed because it is too large
Load Diff
@ -1,14 +1,14 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
import MetaMetricsController from '../../../../app/scripts/controllers/metametrics'; |
import { ENVIRONMENT_TYPE_BACKGROUND } from '../../../shared/constants/app'; |
||||||
import { ENVIRONMENT_TYPE_BACKGROUND } from '../../../../shared/constants/app'; |
import { createSegmentMock } from '../lib/segment'; |
||||||
import { createSegmentMock } from '../../../../app/scripts/lib/segment'; |
|
||||||
import { |
import { |
||||||
METAMETRICS_ANONYMOUS_ID, |
METAMETRICS_ANONYMOUS_ID, |
||||||
METAMETRICS_BACKGROUND_PAGE_OBJECT, |
METAMETRICS_BACKGROUND_PAGE_OBJECT, |
||||||
} from '../../../../shared/constants/metametrics'; |
} from '../../../shared/constants/metametrics'; |
||||||
import waitUntilCalled from '../../../lib/wait-until-called'; |
import waitUntilCalled from '../../../test/lib/wait-until-called'; |
||||||
import { NETWORK_EVENTS } from '../../../../app/scripts/controllers/network'; |
import MetaMetricsController from './metametrics'; |
||||||
|
import { NETWORK_EVENTS } from './network'; |
||||||
|
|
||||||
const segment = createSegmentMock(2, 10000); |
const segment = createSegmentMock(2, 10000); |
||||||
const segmentLegacy = createSegmentMock(2, 10000); |
const segmentLegacy = createSegmentMock(2, 10000); |
@ -1,7 +1,7 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
import NetworkController from '../../../../../app/scripts/controllers/network'; |
import { getNetworkDisplayName } from './util'; |
||||||
import { getNetworkDisplayName } from '../../../../../app/scripts/controllers/network/util'; |
import NetworkController from './network'; |
||||||
|
|
||||||
describe('NetworkController', function () { |
describe('NetworkController', function () { |
||||||
describe('controller', function () { |
describe('controller', function () { |
@ -1,9 +1,9 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
|
import { txMetaStub } from '../../../../test/stub/tx-meta-stub'; |
||||||
import { |
import { |
||||||
createPendingNonceMiddleware, |
createPendingNonceMiddleware, |
||||||
createPendingTxMiddleware, |
createPendingTxMiddleware, |
||||||
} from '../../../../../app/scripts/controllers/network/middleware/pending'; |
} from './middleware/pending'; |
||||||
import { txMetaStub } from './stubs'; |
|
||||||
|
|
||||||
describe('PendingNonceMiddleware', function () { |
describe('PendingNonceMiddleware', function () { |
||||||
describe('#createPendingNonceMiddleware', function () { |
describe('#createPendingNonceMiddleware', function () { |
@ -1,18 +1,19 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
|
|
||||||
import { METADATA_STORE_KEY } from '../../../../../app/scripts/controllers/permissions/enums'; |
|
||||||
|
|
||||||
import { PermissionsController } from '../../../../../app/scripts/controllers/permissions'; |
|
||||||
|
|
||||||
import { getUserApprovalPromise, grantPermissions } from './helpers'; |
|
||||||
|
|
||||||
import { |
import { |
||||||
constants, |
constants, |
||||||
getters, |
getters, |
||||||
getPermControllerOpts, |
getPermControllerOpts, |
||||||
getPermissionsMiddleware, |
getPermissionsMiddleware, |
||||||
} from './mocks'; |
} from '../../../../test/mocks/permission-controller'; |
||||||
|
import { |
||||||
|
getUserApprovalPromise, |
||||||
|
grantPermissions, |
||||||
|
} from '../../../../test/helpers/permission-controller-helpers'; |
||||||
|
import { METADATA_STORE_KEY } from './enums'; |
||||||
|
|
||||||
|
import { PermissionsController } from '.'; |
||||||
|
|
||||||
const { CAVEATS, ERRORS, PERMS, RPC_REQUESTS } = getters; |
const { CAVEATS, ERRORS, PERMS, RPC_REQUESTS } = getters; |
||||||
|
|
@ -1,7 +1,7 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import pify from 'pify'; |
import pify from 'pify'; |
||||||
|
|
||||||
import getRestrictedMethods from '../../../../../app/scripts/controllers/permissions/restrictedMethods'; |
import getRestrictedMethods from './restrictedMethods'; |
||||||
|
|
||||||
describe('restricted methods', function () { |
describe('restricted methods', function () { |
||||||
describe('eth_accounts', function () { |
describe('eth_accounts', function () { |
@ -1,7 +1,7 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
import { ObservableStore } from '@metamask/obs-store'; |
import { ObservableStore } from '@metamask/obs-store'; |
||||||
import TokenRatesController from '../../../../app/scripts/controllers/token-rates'; |
import TokenRatesController from './token-rates'; |
||||||
|
|
||||||
describe('TokenRatesController', function () { |
describe('TokenRatesController', function () { |
||||||
let nativeCurrency; |
let nativeCurrency; |
@ -1,11 +1,11 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
|
import testData from '../../../../../test/data/mock-tx-history.json'; |
||||||
import { |
import { |
||||||
snapshotFromTxMeta, |
snapshotFromTxMeta, |
||||||
migrateFromSnapshotsToDiffs, |
migrateFromSnapshotsToDiffs, |
||||||
replayHistory, |
replayHistory, |
||||||
generateHistoryEntry, |
generateHistoryEntry, |
||||||
} from '../../../../../app/scripts/controllers/transactions/lib/tx-state-history-helpers'; |
} from './tx-state-history-helpers'; |
||||||
import testData from '../../../../data/mock-tx-history.json'; |
|
||||||
|
|
||||||
describe('Transaction state history helper', function () { |
describe('Transaction state history helper', function () { |
||||||
describe('#snapshotFromTxMeta', function () { |
describe('#snapshotFromTxMeta', function () { |
@ -1,5 +1,5 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import * as txUtils from '../../../../../app/scripts/controllers/transactions/lib/util'; |
import * as txUtils from './util'; |
||||||
|
|
||||||
describe('txUtils', function () { |
describe('txUtils', function () { |
||||||
describe('#validateTxParams', function () { |
describe('#validateTxParams', function () { |
@ -1,8 +1,8 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
import BN from 'bn.js'; |
import BN from 'bn.js'; |
||||||
import PendingTransactionTracker from '../../../../../app/scripts/controllers/transactions/pending-tx-tracker'; |
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'; |
||||||
import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction'; |
import PendingTransactionTracker from './pending-tx-tracker'; |
||||||
|
|
||||||
describe('PendingTransactionTracker', function () { |
describe('PendingTransactionTracker', function () { |
||||||
describe('#resubmitPendingTxs', function () { |
describe('#resubmitPendingTxs', function () { |
@ -1,7 +1,7 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import Transaction from 'ethereumjs-tx'; |
import Transaction from 'ethereumjs-tx'; |
||||||
import { hexToBn, bnToHex } from '../../../../../app/scripts/lib/util'; |
import { hexToBn, bnToHex } from '../../lib/util'; |
||||||
import TxUtils from '../../../../../app/scripts/controllers/transactions/tx-gas-utils'; |
import TxUtils from './tx-gas-utils'; |
||||||
|
|
||||||
describe('txUtils', function () { |
describe('txUtils', function () { |
||||||
let txUtils; |
let txUtils; |
@ -1,12 +1,12 @@ |
|||||||
import { strict as assert } from 'assert'; |
import { strict as assert } from 'assert'; |
||||||
import sinon from 'sinon'; |
import sinon from 'sinon'; |
||||||
import TxStateManager from '../../../../../app/scripts/controllers/transactions/tx-state-manager'; |
import { TRANSACTION_STATUSES } from '../../../../shared/constants/transaction'; |
||||||
import { snapshotFromTxMeta } from '../../../../../app/scripts/controllers/transactions/lib/tx-state-history-helpers'; |
|
||||||
import { TRANSACTION_STATUSES } from '../../../../../shared/constants/transaction'; |
|
||||||
import { |
import { |
||||||
KOVAN_CHAIN_ID, |
KOVAN_CHAIN_ID, |
||||||
KOVAN_NETWORK_ID, |
KOVAN_NETWORK_ID, |
||||||
} from '../../../../../shared/constants/network'; |
} from '../../../../shared/constants/network'; |
||||||
|
import TxStateManager from './tx-state-manager'; |
||||||
|
import { snapshotFromTxMeta } from './lib/tx-state-history-helpers'; |
||||||
|
|
||||||
const noop = () => true; |
const noop = () => true; |
||||||
|
|
@ -1,6 +1,6 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import { ObservableStore } from '@metamask/obs-store'; |
import { ObservableStore } from '@metamask/obs-store'; |
||||||
import ComposableObservableStore from '../../../app/scripts/lib/ComposableObservableStore'; |
import ComposableObservableStore from './ComposableObservableStore'; |
||||||
|
|
||||||
describe('ComposableObservableStore', function () { |
describe('ComposableObservableStore', function () { |
||||||
it('should register initial state', function () { |
it('should register initial state', function () { |
@ -1,20 +1,26 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import getBuyEthUrl from '../../../app/scripts/lib/buy-eth-url'; |
import { |
||||||
|
KOVAN_CHAIN_ID, |
||||||
|
MAINNET_CHAIN_ID, |
||||||
|
RINKEBY_CHAIN_ID, |
||||||
|
ROPSTEN_CHAIN_ID, |
||||||
|
} from '../../../shared/constants/network'; |
||||||
|
import getBuyEthUrl from './buy-eth-url'; |
||||||
|
|
||||||
describe('buy-eth-url', function () { |
describe('buy-eth-url', function () { |
||||||
const mainnet = { |
const mainnet = { |
||||||
network: '1', |
chainId: MAINNET_CHAIN_ID, |
||||||
amount: 5, |
amount: 5, |
||||||
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', |
address: '0x0dcd5d886577d5081b0c52e242ef29e70be3e7bc', |
||||||
}; |
}; |
||||||
const ropsten = { |
const ropsten = { |
||||||
network: '3', |
chainId: ROPSTEN_CHAIN_ID, |
||||||
}; |
}; |
||||||
const rinkeby = { |
const rinkeby = { |
||||||
network: '4', |
chainId: RINKEBY_CHAIN_ID, |
||||||
}; |
}; |
||||||
const kovan = { |
const kovan = { |
||||||
network: '42', |
chainId: KOVAN_CHAIN_ID, |
||||||
}; |
}; |
||||||
|
|
||||||
it('returns wyre url with address for network 1', function () { |
it('returns wyre url with address for network 1', function () { |
@ -1,5 +1,5 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import cleanErrorStack from '../../../app/scripts/lib/cleanErrorStack'; |
import cleanErrorStack from './cleanErrorStack'; |
||||||
|
|
||||||
describe('Clean Error Stack', function () { |
describe('Clean Error Stack', function () { |
||||||
const testMessage = 'Test Message'; |
const testMessage = 'Test Message'; |
@ -0,0 +1,33 @@ |
|||||||
|
import { ethErrors, serializeError } from 'eth-rpc-errors'; |
||||||
|
|
||||||
|
const createMetaRPCHandler = (api, outStream) => { |
||||||
|
return (data) => { |
||||||
|
if (!api[data.method]) { |
||||||
|
outStream.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
error: ethErrors.rpc.methodNotFound({ |
||||||
|
message: `${data.method} not found`, |
||||||
|
}), |
||||||
|
id: data.id, |
||||||
|
}); |
||||||
|
return; |
||||||
|
} |
||||||
|
api[data.method](...data.params, (err, result) => { |
||||||
|
if (err) { |
||||||
|
outStream.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
error: serializeError(err, { shouldIncludeStack: true }), |
||||||
|
id: data.id, |
||||||
|
}); |
||||||
|
} else { |
||||||
|
outStream.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
result, |
||||||
|
id: data.id, |
||||||
|
}); |
||||||
|
} |
||||||
|
}); |
||||||
|
}; |
||||||
|
}; |
||||||
|
|
||||||
|
export default createMetaRPCHandler; |
@ -0,0 +1,61 @@ |
|||||||
|
import assert from 'assert'; |
||||||
|
import { obj as createThoughStream } from 'through2'; |
||||||
|
import createMetaRPCHandler from './createMetaRPCHandler'; |
||||||
|
|
||||||
|
describe('createMetaRPCHandler', function () { |
||||||
|
it('can call the api when handler receives a JSON-RPC request', function (done) { |
||||||
|
const api = { |
||||||
|
foo: (param1) => { |
||||||
|
assert.strictEqual(param1, 'bar'); |
||||||
|
done(); |
||||||
|
}, |
||||||
|
}; |
||||||
|
const streamTest = createThoughStream(); |
||||||
|
const handler = createMetaRPCHandler(api, streamTest); |
||||||
|
handler({ |
||||||
|
id: 1, |
||||||
|
method: 'foo', |
||||||
|
params: ['bar'], |
||||||
|
}); |
||||||
|
}); |
||||||
|
it('can write the response to the outstream when api callback is called', function (done) { |
||||||
|
const api = { |
||||||
|
foo: (param1, cb) => { |
||||||
|
assert.strictEqual(param1, 'bar'); |
||||||
|
cb(null, 'foobarbaz'); |
||||||
|
}, |
||||||
|
}; |
||||||
|
const streamTest = createThoughStream(); |
||||||
|
const handler = createMetaRPCHandler(api, streamTest); |
||||||
|
handler({ |
||||||
|
id: 1, |
||||||
|
method: 'foo', |
||||||
|
params: ['bar'], |
||||||
|
}); |
||||||
|
streamTest.on('data', (data) => { |
||||||
|
assert.strictEqual(data.result, 'foobarbaz'); |
||||||
|
streamTest.end(); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
it('can write the error to the outstream when api callback is called with an error', function (done) { |
||||||
|
const api = { |
||||||
|
foo: (param1, cb) => { |
||||||
|
assert.strictEqual(param1, 'bar'); |
||||||
|
cb(new Error('foo-error')); |
||||||
|
}, |
||||||
|
}; |
||||||
|
const streamTest = createThoughStream(); |
||||||
|
const handler = createMetaRPCHandler(api, streamTest); |
||||||
|
handler({ |
||||||
|
id: 1, |
||||||
|
method: 'foo', |
||||||
|
params: ['bar'], |
||||||
|
}); |
||||||
|
streamTest.on('data', (data) => { |
||||||
|
assert.strictEqual(data.error.message, 'foo-error'); |
||||||
|
streamTest.end(); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
@ -1,6 +1,6 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import MessageManager from '../../../app/scripts/lib/message-manager'; |
|
||||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'; |
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'; |
||||||
|
import MessageManager from './message-manager'; |
||||||
|
|
||||||
describe('Message Manager', function () { |
describe('Message Manager', function () { |
||||||
let messageManager; |
let messageManager; |
@ -0,0 +1,81 @@ |
|||||||
|
import { EthereumRpcError } from 'eth-rpc-errors'; |
||||||
|
import SafeEventEmitter from 'safe-event-emitter'; |
||||||
|
import createRandomId from '../../../shared/modules/random-id'; |
||||||
|
|
||||||
|
class MetaRPCClient { |
||||||
|
constructor(connectionStream) { |
||||||
|
this.connectionStream = connectionStream; |
||||||
|
this.notificationChannel = new SafeEventEmitter(); |
||||||
|
this.requests = new Map(); |
||||||
|
this.connectionStream.on('data', this.handleResponse.bind(this)); |
||||||
|
this.connectionStream.on('end', this.close.bind(this)); |
||||||
|
} |
||||||
|
|
||||||
|
onNotification(handler) { |
||||||
|
this.notificationChannel.addListener('notification', (data) => { |
||||||
|
handler(data); |
||||||
|
}); |
||||||
|
} |
||||||
|
|
||||||
|
close() { |
||||||
|
this.notificationChannel.removeAllListeners(); |
||||||
|
} |
||||||
|
|
||||||
|
handleResponse(data) { |
||||||
|
const { id, result, error, method, params } = data; |
||||||
|
const cb = this.requests.get(id); |
||||||
|
|
||||||
|
if (method && params && id) { |
||||||
|
// dont handle server-side to client-side requests
|
||||||
|
return; |
||||||
|
} |
||||||
|
if (method && params && !id) { |
||||||
|
// handle servier-side to client-side notification
|
||||||
|
this.notificationChannel.emit('notification', data); |
||||||
|
return; |
||||||
|
} |
||||||
|
if (!cb) { |
||||||
|
// not found in request list
|
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
if (error) { |
||||||
|
const e = new EthereumRpcError(error.code, error.message, error.data); |
||||||
|
// preserve the stack from serializeError
|
||||||
|
e.stack = error.stack; |
||||||
|
this.requests.delete(id); |
||||||
|
cb(e); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
this.requests.delete(id); |
||||||
|
|
||||||
|
cb(null, result); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
const metaRPCClientFactory = (connectionStream) => { |
||||||
|
const metaRPCClient = new MetaRPCClient(connectionStream); |
||||||
|
return new Proxy(metaRPCClient, { |
||||||
|
get: (object, property) => { |
||||||
|
if (object[property]) { |
||||||
|
return object[property]; |
||||||
|
} |
||||||
|
return (...p) => { |
||||||
|
const cb = p[p.length - 1]; |
||||||
|
const params = p.slice(0, -1); |
||||||
|
const id = createRandomId(); |
||||||
|
|
||||||
|
object.requests.set(id, cb); |
||||||
|
object.connectionStream.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
method: property, |
||||||
|
params, |
||||||
|
id, |
||||||
|
}); |
||||||
|
}; |
||||||
|
}, |
||||||
|
}); |
||||||
|
}; |
||||||
|
|
||||||
|
export default metaRPCClientFactory; |
@ -0,0 +1,88 @@ |
|||||||
|
import assert from 'assert'; |
||||||
|
import { obj as createThoughStream } from 'through2'; |
||||||
|
import metaRPCClientFactory from './metaRPCClientFactory'; |
||||||
|
|
||||||
|
describe('metaRPCClientFactory', function () { |
||||||
|
it('should be able to make an rpc request with the method', function (done) { |
||||||
|
const streamTest = createThoughStream((chunk) => { |
||||||
|
assert.strictEqual(chunk.method, 'foo'); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
const metaRPCClient = metaRPCClientFactory(streamTest); |
||||||
|
metaRPCClient.foo(); |
||||||
|
}); |
||||||
|
it('should be able to make an rpc request/response with the method and params and node-style callback', function (done) { |
||||||
|
const streamTest = createThoughStream(); |
||||||
|
const metaRPCClient = metaRPCClientFactory(streamTest); |
||||||
|
|
||||||
|
// make a "foo" method call
|
||||||
|
metaRPCClient.foo('bar', (_, result) => { |
||||||
|
assert.strictEqual(result, 'foobarbaz'); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
|
||||||
|
// fake a response
|
||||||
|
metaRPCClient.requests.forEach((_, key) => { |
||||||
|
streamTest.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
id: key, |
||||||
|
result: 'foobarbaz', |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
||||||
|
it('should be able to make an rpc request/error with the method and params and node-style callback', function (done) { |
||||||
|
const streamTest = createThoughStream(); |
||||||
|
const metaRPCClient = metaRPCClientFactory(streamTest); |
||||||
|
|
||||||
|
// make a "foo" method call
|
||||||
|
metaRPCClient.foo('bar', (err) => { |
||||||
|
assert.strictEqual(err.message, 'foo-message'); |
||||||
|
assert.strictEqual(err.code, 1); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
|
||||||
|
metaRPCClient.requests.forEach((_, key) => { |
||||||
|
streamTest.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
id: key, |
||||||
|
error: { |
||||||
|
code: 1, |
||||||
|
message: 'foo-message', |
||||||
|
}, |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
it('should be able to make an rpc request/response with the method and params and node-style callback with multiple instances of metaRPCClientFactory and the same connectionStream', function (done) { |
||||||
|
const streamTest = createThoughStream(); |
||||||
|
const metaRPCClient = metaRPCClientFactory(streamTest); |
||||||
|
const metaRPCClient2 = metaRPCClientFactory(streamTest); |
||||||
|
|
||||||
|
// make a "foo" method call, followed by "baz" call on metaRPCClient2
|
||||||
|
metaRPCClient.foo('bar', (_, result) => { |
||||||
|
assert.strictEqual(result, 'foobarbaz'); |
||||||
|
metaRPCClient2.baz('bar', (err) => { |
||||||
|
assert.strictEqual(err, null); |
||||||
|
done(); |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// fake a response
|
||||||
|
metaRPCClient.requests.forEach((_, key) => { |
||||||
|
streamTest.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
id: key, |
||||||
|
result: 'foobarbaz', |
||||||
|
}); |
||||||
|
}); |
||||||
|
|
||||||
|
// fake client2's response
|
||||||
|
metaRPCClient2.requests.forEach((_, key) => { |
||||||
|
streamTest.write({ |
||||||
|
jsonrpc: '2.0', |
||||||
|
id: key, |
||||||
|
result: 'foobarbaz', |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
||||||
|
}); |
@ -1,5 +1,5 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import nodeify from '../../../app/scripts/lib/nodeify'; |
import nodeify from './nodeify'; |
||||||
|
|
||||||
describe('nodeify', function () { |
describe('nodeify', function () { |
||||||
const obj = { |
const obj = { |
@ -1,6 +1,6 @@ |
|||||||
import assert from 'assert'; |
import assert from 'assert'; |
||||||
import PersonalMessageManager from '../../../app/scripts/lib/personal-message-manager'; |
|
||||||
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'; |
import { TRANSACTION_STATUSES } from '../../../shared/constants/transaction'; |
||||||
|
import PersonalMessageManager from './personal-message-manager'; |
||||||
|
|
||||||
describe('Personal Message Manager', function () { |
describe('Personal Message Manager', function () { |
||||||
let messageManager; |
let messageManager; |
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in new issue