Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
tape('[FastEthereumService]', t => {
class PeerPool extends EventEmitter { }
PeerPool.prototype.open = td.func()
td.replace('../../lib/net/peerpool', PeerPool)
td.replace('../../lib/net/protocol/flowcontrol')
const Chain = td.constructor()
Chain.prototype.open = td.func()
td.replace('../../lib/blockchain', { Chain })
const EthProtocol = td.constructor()
const LesProtocol = td.constructor()
td.replace('../../lib/net/protocol/ethprotocol', EthProtocol)
td.replace('../../lib/net/protocol/lesprotocol', LesProtocol)
class FastSynchronizer extends EventEmitter { }
FastSynchronizer.prototype.start = td.func()
FastSynchronizer.prototype.stop = td.func()
FastSynchronizer.prototype.open = td.func()
td.replace('../../lib/sync/fastsync', FastSynchronizer)
const FastEthereumService = require('../../lib/service/fastethereumservice')
t.test('should initialize correctly', async (t) => {
let service = new FastEthereumService()
t.ok(service.synchronizer instanceof FastSynchronizer, 'fast mode')
t.equals(service.name, 'eth', 'got name')
t.end()
})
beforeEach('create fakes', () => {
FakeOpenStub = td.constructor(OpenStub);
td.replace('../../../../lib/Protocol/Protobuf/Stubs/mysqlx_expect_pb', { Open: FakeOpenStub });
Expect = require('../../../../lib/Protocol/Protobuf/Adapters/Expect');
createCondition = td.replace(Expect, 'createCondition');
});
beforeEach('create fakes', () => {
FakeOkHandler = td.constructor(OkHandler);
network = new PassThrough();
td.replace('../../../lib/Protocol/ResponseHandlers/OkHandler', FakeOkHandler);
});
const tape = require('tape-catch')
const td = require('testdouble')
const EventEmitter = require('events')
const Chain = td.constructor(require('../../lib/blockchain/chain'))
const Flow = td.constructor(require('../../lib/net/protocol/flowcontrol'))
const { LesHandler } = require('../../lib/handler')
const { defaultLogger } = require('../../lib/logging')
defaultLogger.silent = true
tape('[LesHandler]', t => {
const pool = new EventEmitter()
const chain = new Chain()
const flow = new Flow()
const handler = new LesHandler({ pool, chain, flow })
const peer = { les: { send: td.func() } }
const message = {
name: 'GetBlockHeaders',
data: {
reqId: 1,
block: 5,
const tape = require('tape-catch')
const td = require('testdouble')
const EventEmitter = require('events')
const Chain = td.constructor(require('../../lib/blockchain/chain'))
const Flow = td.constructor(require('../../lib/net/protocol/flowcontrol'))
const { LesHandler } = require('../../lib/handler')
const { defaultLogger } = require('../../lib/logging')
defaultLogger.silent = true
tape('[LesHandler]', t => {
const pool = new EventEmitter()
const chain = new Chain()
const flow = new Flow()
const handler = new LesHandler({ pool, chain, flow })
const peer = { les: { send: td.func() } }
const message = {
name: 'GetBlockHeaders',
data: {
reqId: 1,
block: 5,
max: 100,
beforeEach('create fakes', () => {
FakeDeallocateStub = td.constructor(DeallocateStub);
getStatementId = td.function();
td.replace('../../../../lib/Protocol/Protobuf/Stubs/mysqlx_prepare_pb', { Deallocate: FakeDeallocateStub });
Prepare = require('../../../../lib/Protocol/Protobuf/Adapters/Prepare');
});
beforeEach('create fakes', () => {
FakeConditionStub = td.constructor(ConditionStub);
td.replace('../../../../lib/Protocol/Protobuf/Stubs/mysqlx_expect_pb', { Open: { Condition: FakeConditionStub } });
Expect = require('../../../../lib/Protocol/Protobuf/Adapters/Expect');
});
beforeEach(done => {
FakeClient = td.constructor(Client);
FakeResource = td.constructor(Resource);
done();
});
afterEach(done => {
beforeEach('create fakes', () => {
FakeExecuteStub = td.constructor(ExecuteStub);
createPreparedStatementArgs = td.function();
getStatementId = td.function();
getType = td.function();
td.replace('../../../../lib/Protocol/Protobuf/Stubs/mysqlx_prepare_pb', { Execute: FakeExecuteStub, Prepare: PrepareStub });
});
'use strict'
const td = require('testdouble')
const proxyquire = require('proxyquire')
const netrc = td.constructor(require('netrc-parser'))
netrc['@global'] = true
let mockMachines = {}
netrc.default = new class {
constructor () {
this.loadSync = () => {
this.machines = mockMachines
}
}
}()
const cli = proxyquire('heroku-cli-util', {'netrc-parser': netrc})
const cmd = proxyquire('../../../src/commands/auth/token', {'heroku-cli-util': cli})
const expect = require('unexpected')