当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SinonSandbox.resetHistory方法代码示例

本文整理汇总了TypeScript中Sinon.SinonSandbox.resetHistory方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonSandbox.resetHistory方法的具体用法?TypeScript SinonSandbox.resetHistory怎么用?TypeScript SinonSandbox.resetHistory使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sinon.SinonSandbox的用法示例。


在下文中一共展示了SinonSandbox.resetHistory方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: async

  const addMixedTransactionsAndFillPool = async (withSignatures?: boolean) => {
    const allTxs = [];
    // Add 50 txs to various queues
    for (let i = 0; i < 50; i++) {
      if (i === 24) {
        await instance.fillPool();
      }
      const newTx = Object.assign({}, tx);

      if (withSignatures) {
        if (i % 2 === 0) {
          newTx.signatures = ['aaa', 'bbb'];
        }
      }

      newTx.id = 'tx_' + i;
      if (i < 12) {
        newTx.type = TransactionType.MULTI;
        newTx.asset = {
          multisignature: {
            timeout: 2,
          },
        };
      }
      const bundled = (i >= 12 && i < 25);
      instance.queueTransaction(newTx, bundled);
      if (newTx.type === TransactionType.MULTI) {
        instance.multisignature.getPayload(newTx).ready = (i % 2 === 0);
      }
      allTxs.push(newTx);
    }
    sandbox.resetHistory();
    loggerStub.stubReset();
    return allTxs;
  };
开发者ID:RiseVision,项目名称:rise-node,代码行数:35,代码来源:transactionPool.spec.ts

示例2: afterEach

 afterEach(() => s.resetHistory());
开发者ID:RiseVision,项目名称:rise-node,代码行数:1,代码来源:peers.spec.ts

示例3: afterEach

 afterEach(() => {
   sandbox.restore();
   sandbox.resetHistory();
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:4,代码来源:transportAPI.spec.ts

示例4: beforeEach

  beforeEach(() => {
    sandbox = sinon.createSandbox();
    container = createContainer();
    instance = new TransactionPool();
    fakeBus = {message: sandbox.stub().resolves()};
    fakeAppState = {get: sandbox.stub()};
    jqStub = container.get(Symbols.helpers.jobsQueue);
    loggerStub = container.get(Symbols.helpers.logger);
    transactionLogicStub = container.get(Symbols.logic.transaction);
    accountsModuleStub = container.get(Symbols.modules.accounts);
    balanceSequenceStub = container.getTagged(Symbols.helpers.sequence,
      Symbols.helpers.sequence, Symbols.tags.helpers.balancesSequence);

    // dependencies
    (instance as any).bus = fakeBus;
    (instance as any).jobsQueue = jqStub;
    (instance as any).logger = loggerStub;
    (instance as any).appState = fakeAppState;
    (instance as any).balancesSequence = balanceSequenceStub;
    (instance as any).transactionLogic = transactionLogicStub;
    (instance as any).accountsModule = accountsModuleStub;
    (instance as any).config = {
      broadcasts: {
        broadcastInterval: 1500,
        releaseLimit: 100,
      },
      transactions: {
        maxTxsPerQueue: 50,
      },
    };
    instance.afterConstruction();
    spiedQueues = {
      bundled: {},
      multisignature: {},
      queued: {},
      unconfirmed: {},
    };
    // we preserve behavior of the inner queues but we spy on all methods.
    ['unconfirmed', 'bundled', 'queued', 'multisignature'].forEach((queueName) => {
      if (typeof spiedQueues[queueName] === 'undefined') {
        spiedQueues[queueName] = {};
      }
      ['has', 'remove', 'add', 'get', 'reindex', 'list', 'listWithPayload'].forEach((method: string) => {
        spiedQueues[queueName][method] = sandbox.spy(instance[queueName], method);
      });
    });

    tx = {
      amount         : 108910891000000,
      asset          : {},
      fee            : 10,
      id             : '8139741256612355994',
      recipientId    : '15256762582730568272R',
      senderId       : '1233456789012345R',
      senderPublicKey: Buffer.from('6588716f9c941530c74eabdf0b27b1a2bac0a1525e9605a37e6c0b3817e58fe3', 'hex'),
      signature      : Buffer.from('f8fbf9b8433bf1bbea971dc8b14c6772d33c7dd285d84c5e6c984b10c4141e9f' +
                       'a56ace902b910e05e98b55898d982b3d5b9bf8bd897083a7d1ca1d5028703e03', 'hex'),
      timestamp      : 0,
      type           : TransactionType.SEND,
    };

    // Clone the tx to separate objects with different IDs
    tx2 = Object.assign({}, tx);
    tx2.id = 'tx2';

    tx3 = Object.assign({}, tx);
    tx3.id = 'tx3';
    sandbox.resetHistory();
  });
开发者ID:RiseVision,项目名称:rise-node,代码行数:69,代码来源:transactionPool.spec.ts


注:本文中的Sinon.SinonSandbox.resetHistory方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。