本文整理汇总了TypeScript中inversify.Container.rebind方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Container.rebind方法的具体用法?TypeScript Container.rebind怎么用?TypeScript Container.rebind使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inversify.Container
的用法示例。
在下文中一共展示了Container.rebind方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
container = createContainer();
container.rebind(Symbols.generic.zschema).toConstantValue(new z_schema({}));
container.rebind(Symbols.logic.block).to(BlockLogic);
instance = container.get(Symbols.logic.block);
transactionLogicStub = container.get(Symbols.logic.transaction);
transactionLogicStub.stubs.objectNormalize.returns(null);
});
示例2: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
container.rebind(Symbols.generic.appConfig).toConstantValue(appConfig);
container.rebind(Symbols.modules.peers).to(PeersModule);
inst = instR = container.get(Symbols.modules.peers);
peersLogicStub = container.get(Symbols.logic.peers);
});
示例3: it
it('should validate transactions', async () => {
container.rebind(Symbols.generic.zschema).toConstantValue(new z_schema({}));
container.rebind(Symbols.api.transactions).to(TransactionsAPI);
instance = container.get(Symbols.api.transactions);
await expect(instance.put({transactions: 'asd'} as any))
.to.be.rejectedWith('Expected type array');
await expect(instance.put({transactions: new Array(11).fill('miao')} as any))
.to.be.rejectedWith('Array is too long (11)');
});
示例4: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
container.rebind(Symbols.modules.transactions).to(TransactionsModule);
instance = container.get(Symbols.modules.transactions);
accountsModuleStub = container.get(Symbols.modules.accounts);
loggerStub = container.get(Symbols.helpers.logger);
dbHelperStub = container.get(Symbols.helpers.db);
genesisBlock = container.get(Symbols.generic.genesisBlock);
transactionPoolStub = container.get(Symbols.logic.transactionPool);
transactionLogicStub = container.get(Symbols.logic.transaction);
// Reset all stubs
[accountsModuleStub, loggerStub, dbHelperStub, transactionPoolStub, transactionLogicStub].forEach((stub: any) => {
if (typeof stub.reset !== 'undefined') {
stub.reset();
}
if (typeof stub.stubReset !== 'undefined') {
stub.stubReset();
}
});
transactionPoolStub.unconfirmed.reset();
transactionPoolStub.multisignature.reset();
transactionPoolStub.bundled.reset();
});
示例5: it
it('should not throw if data is in correct format', async () => {
container.rebind(Symbols.logic.block).to(BlockLogic).inSingletonScope();
container.rebind(Symbols.logic.transaction).to(TransactionLogic).inSingletonScope();
container.rebind(Symbols.logic.account).to(AccountLogic).inSingletonScope();
container.rebind(Symbols.helpers.protoBuf).to(ProtoBufHelper).inSingletonScope();
const txLogic: TransactionLogic = container.get(Symbols.logic.transaction);
txLogic.attachAssetType(container.get(Symbols.logic.transactions.send));
// container.rebind(Symbols.logic.pro).to(BlockLogic).inSingletonScope();
const pbFactory = container.get<RequestFactoryType<any, PostBlocksRequest>>(requestSymbols.postBlocks);
const data = pbFactory({data: {block: fakeBlock}}).getRequestOptions(true);
expect(Buffer.isBuffer(data.data)).true;
req.body = data.data;
instance = container.get(Symbols.api.transportV2);
await instance.postBlock(req);
});
示例6: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
accountLogicStub = container.get(Symbols.logic.account);
container.rebind<IAccountsModule>(Symbols.modules.accounts).to(AccountsModule).inSingletonScope();
accountModule = container.get<any>(Symbols.modules.accounts);
});
示例7: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
accountLogicStub = container.get(Symbols.logic.account);
accountsModel = container.get(Symbols.models.accounts);
accountLogicStub.enqueueResponse('merge', [{foo: 'bar'}]);
systemModuleStub = container.get(Symbols.modules.system);
systemModuleStub.stubs.getFees.returns({
fees: {
send: 1,
},
});
roundsLogicStub = container.get(Symbols.logic.rounds);
roundsLogicStub.stubs.calcRound.returns(10);
tx = {
amount : 10,
recipientId: '1234567890R',
};
sender = { publicKey: '123' };
block = {
height: 123456,
id : 'blockId',
};
container.rebind(Symbols.logic.transactions.send).to(SendTransaction).inSingletonScope();
instance = container.get(Symbols.logic.transactions.send);
(instance as any).roundsLogic = roundsLogicStub;
(instance as any).systemModule = systemModuleStub;
});
示例8: beforeEach
beforeEach(() => {
container = createContainer();
container.rebind(Symbols.modules.blocksSubModules.chain).to(BlocksModuleChain);
processExitStub = sinon.stub(process, 'exit');
inst = instR = container.get(Symbols.modules.blocksSubModules.chain);
});
示例9: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
zSchemaStub = {
getLastErrors: () => [],
validate : sandbox.stub(),
};
accountLogicStub = container.get(Symbols.logic.account);
roundsLogicStub = container.get(Symbols.logic.rounds);
delegatesModuleStub = container.get(Symbols.modules.delegates);
systemModuleStub = container.get(Symbols.modules.system);
accountsModel = container.get(Symbols.models.accounts);
votesModel = container.get(Symbols.models.votes);
tx = {
amount : 0,
asset : {
votes: [
'-7e58fe36588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b381',
'+05a37e6c6588716f9c9a2bac4bac0a1525e9605abac4153016f95a37e6c6588a',
],
},
fee : 10,
id : '8139741256612355994',
recipientId : '1233456789012345R',
senderId : '1233456789012345R',
senderPublicKey: Buffer.from('6588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b3817e58fe3', 'hex'),
signature : Buffer.from('0a1525e9605a37e6c6588716f9c9a2bac41530c74e3817e58fe3abdf0b27b10b' +
'a2bac0a1525e9605a37e6c6588716f9c7b10b3817e58fe3941530c74eabdf0b2', 'hex'),
timestamp : 0,
type : TransactionType.VOTE,
};
sender = {
address : '1233456789012345R',
balance : 10000000,
publicKey: Buffer.from('6588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b3817e58fe3', 'hex'),
applyDiffArray() {
throw new Error('please stub applyDiffArray');
},
};
block = {
height: 8797,
id : '13191140260435645922',
};
container.rebind(Symbols.logic.transactions.vote).to(VoteTransaction).inSingletonScope();
instance = container.get(Symbols.logic.transactions.vote);
(instance as any).schema = zSchemaStub;
systemModuleStub.stubs.getFees.returns({ fees: { vote: 1 } });
delegatesModuleStub.stubs.checkConfirmedDelegates.resolves();
});
示例10: beforeEach
beforeEach(() => {
container.rebind(Symbols.helpers.slots).to(Slots);
realSlots = container.get(Symbols.helpers.slots);
(inst as any).slots = {
getSlotNumber: realSlots.getSlotNumber,
interval: (realSlots as any).interval,
};
lastBlk = { timestamp: constants.blockTime };
blk = { timestamp: constants.blockTime * 2 };
});
示例11: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
accountsModel = container.get(Symbols.models.accounts);
accounts2MultisigModel = container.get(Symbols.models.accounts2Multisignatures);
accounts2UMultisigModel = container.get(Symbols.models.accounts2U_Multisignatures);
multisigModel = container.get(Symbols.models.multisignatures);
txModel = container.get(Symbols.models.transactions);
socketIOStub = {
sockets: {
emit: sandbox.stub(),
},
};
zSchemaStub = container.get(Symbols.generic.zschema);
accountLogicStub = container.get(Symbols.logic.account);
transactionLogicStub = container.get(Symbols.logic.transaction);
accountsModuleStub = container.get(Symbols.modules.accounts);
systemModuleStub = container.get(Symbols.modules.system);
roundsLogicStub = container.get(Symbols.logic.rounds);
tx = {
amount : 0,
asset : {
multisignature: {
keysgroup: ['+' + new Array(64).fill('a').join(''), '+' + new Array(64).fill('b').join('')],
lifetime : 33,
min : 2,
},
},
fee : 10,
id : '8139741256612355994',
senderId : '1233456789012345R',
senderPublicKey: Buffer.from('6588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b3817e58fe3', 'hex'),
signatures : ['sig1', 'sig2'],
timestamp : 0,
type : TransactionType.MULTI,
};
sender = new accountsModel({
address : '1233456789012345R',
balance : 10000000,
publicKey: Buffer.from('6588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b3817e58fe3', 'hex'),
});
block = {
height: 8797,
id : '13191140260435645922',
};
container.rebind(Symbols.logic.transactions.createmultisig).to(MultiSignatureTransaction).inSingletonScope();
instance = container.get(Symbols.logic.transactions.createmultisig);
(instance as any).io = socketIOStub;
systemModuleStub.stubs.getFees.returns({fees: {multisignature: 123}});
});
示例12: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
container.rebind(Symbols.modules.fork).to(ForkModule);
block = createFakeBlock();
instance = container.get(Symbols.modules.fork);
loggerStub = container.get(Symbols.helpers.logger);
socketIOStub = container.get(Symbols.generic.socketIO);
forksModel = container.get(Symbols.models.forkStats);
});
示例13: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
zSchemaStub = {
getLastErrors: () => [],
validate : sandbox.stub(),
};
accountsModuleStub = container.get(Symbols.modules.accounts);
systemModuleStub = container.get(Symbols.modules.system);
accountsModel = container.get(Symbols.models.accounts);
signaturesModel = container.get(Symbols.models.signatures);
tx = {
amount : 0,
asset : {
signature: {
publicKey: 'a2bac0a1525e9605a37e6c6588716f9c941530c74eabdf0b27b10b3817e58fe3',
},
},
fee : 10,
id : '8139741256612355994',
senderId : '1233456789012345R',
senderPublicKey: Buffer.from('6588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b3817e58fe3', 'hex'),
signature : Buffer.from('0a1525e9605a37e6c6588716f9c9a2bac41530c74e3817e58fe3abdf0b27b10b' +
'a2bac0a1525e9605a37e6c6588716f9c7b10b3817e58fe3941530c74eabdf0b2', 'hex'),
timestamp : 0,
type : TransactionType.SIGNATURE,
};
sender = {
address : '1233456789012345R',
balance : 10000000,
publicKey: Buffer.from('6588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b3817e58fe3', 'hex'),
isMultisignatures() {
return false;
},
applyValues() {
throw new Error('please stub applyValues');
}
};
block = {
height: 8797,
id : '13191140260435645922',
};
container.rebind(Symbols.logic.transactions.secondSignature)
.to(SecondSignatureTransaction).inSingletonScope();
instance = container.get(Symbols.logic.transactions.secondSignature);
(instance as any).schema = zSchemaStub;
systemModuleStub.stubs.getFees.returns({fees: {secondsignature: 1000}});
});
示例14: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
container.rebind(Symbols.logic.account).to(AccountLogic);
loggerStub = container.get(Symbols.helpers.logger);
zSchemaStub = container.get(Symbols.generic.zschema);
account = container.get(Symbols.logic.account);
accountsModel = container.get(Symbols.models.accounts);
accounts2DelegatesModel = container.get(Symbols.models.accounts2Delegates);
roundsModel = container.get(Symbols.models.rounds);
accounts2MultisigModel = container.get(Symbols.models.accounts2Multisignatures);
});
示例15: before
before(() => {
container = createContainer();
constants = {
fees : [
{ height: 1, fees: { send: 1 } },
{ height: 2, fees: { send: 2 } },
{ height: 3, fees: { send: 3 } },
{ height: 40, fees: { send: 4 } },
],
minVersion: [
{ height: 1, ver: '^0.1.0' },
{ height: 2, ver: '^0.1.2' },
{ height: 3, ver: '^0.1.3' },
{ height: 11, ver: '0.1.4b' },
],
} as any;
container.rebind(Symbols.helpers.constants).toConstantValue(constants);
container.rebind(Symbols.generic.appConfig).toConstantValue(appConfig);
container.bind(Symbols.generic.nonce).toConstantValue('nonce');
container.rebind(Symbols.modules.system).to(SystemModule);
});