當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。