本文整理汇总了TypeScript中Sinon.SinonSandbox.useFakeTimers方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonSandbox.useFakeTimers方法的具体用法?TypeScript SinonSandbox.useFakeTimers怎么用?TypeScript SinonSandbox.useFakeTimers使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.SinonSandbox
的用法示例。
在下文中一共展示了SinonSandbox.useFakeTimers方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
container = createContainer();
clock = sandbox.useFakeTimers();
fakeConfig = { forging: { secret: ['secret1', 'secret2'] } };
jobsQueueStub = container.get(Symbols.helpers.jobsQueue);
loggerStub = container.get(Symbols.helpers.logger);
edStub = container.get(Symbols.helpers.ed);
slotsStub = container.get(Symbols.helpers.slots);
appStateStub = container.get(Symbols.logic.appState);
broadcasterLogicStub = container.get(Symbols.logic.broadcaster);
accountsModuleStub = container.get(Symbols.modules.accounts);
blocksModuleStub = container.get(Symbols.modules.blocks);
delegatesModuleStub = container.get(Symbols.modules.delegates);
transactionsModuleStub = container.get(Symbols.modules.transactions);
blocksProcessModuleStub = container.get(Symbols.modules.blocksSubModules.process);
sequenceStub = {
addAndPromise: sandbox.spy((w) => {
return Promise.resolve(
w()
);
}),
};
instance = new ForgeModule();
instance = instance as any;
instance.enabledKeys = {};
instance.config = fakeConfig;
instance.constants = constants;
instance.jobsQueue = jobsQueueStub;
instance.logger = loggerStub;
instance.ed = edStub;
instance.defaultSequence = sequenceStub;
instance.slots = slotsStub;
instance.appState = appStateStub;
instance.broadcasterLogic = broadcasterLogicStub;
instance.accountsModule = accountsModuleStub;
instance.blocksModule = blocksModuleStub;
instance.delegatesModule = delegatesModuleStub;
instance.transactionsModule = transactionsModuleStub;
instance.blocksProcessModule = blocksProcessModuleStub;
sha256Spy = sandbox.spy(supersha, 'sha256');
blocksModuleStub.lastBlock = BlocksModel.classFromPOJO({
blockSignature : Buffer.from('blockSignature'),
generatorPublicKey : Buffer.from('pubKey'),
height : 12422,
id : 'blockID',
numberOfTransactions: 0,
payloadHash : Buffer.from('payload'),
payloadLength : 0,
previousBlock : 'previous',
reward : 15,
timestamp : Date.now(),
totalAmount : 0,
totalFee : 0,
version : 1,
});
loadKeypairs = () => {
instance.enabledKeys = {
aaaa: true,
bbbb: true,
cccc: true,
};
instance.keypairs = {
aaaa: { publicKey: Buffer.from('aaaa', 'hex') },
bbbb: { publicKey: Buffer.from('bbbb', 'hex') },
cccc: { publicKey: Buffer.from('cccc', 'hex') },
};
};
});