How to use the long.MAX_VALUE function in long

To help you get started, weā€™ve selected a few long examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hyperledger / fabric-sdk-node / test / unit / channel-event-hub.js View on Github external
t.fail('Should not have called success callback');
			t.end();
		}, (err) =>{
			got_called = true;
			t.pass('Should be called after getting last trans or a shutdown');
			t.equals(err.toString().indexOf('ChannelEventHub has been shutdown'), 7,'Check that we got the correct error message');
		},
		{startBlock: 1, endBlock: 'newest'}
		);
		t.pass('Successfully registered a newest playback transaction event');
	} catch(error) {
		t.fail( 'Failed - Should be able to register with newest replay');
	}
	t.equal(eh._ending_block_newest, true, 'Check the newest state');
	t.equal(eh._allowRegistration, false, 'Check the replay state');
	t.deepEqual(eh._ending_block_number, Long.MAX_VALUE, 'Check the replay end block');

	// this should get some errors posted
	eh.disconnect();
	t.equal(got_called, true, 'Check that error callback was called');

	try {
		eh.unregisterTxEvent('transid');
		eh.registerBlockEvent(() => {
			t.fail('Should not have called success callback');
			t.end();
		}, () =>{
			t.fail('Should not have called error callback');
			t.end();
		},
		{startBlock: 10000000, endBlock: 'newest'}
		);
github hyperledger / fabric-sdk-node / fabric-common / lib / EventService.js View on Github external
behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
			this.replay = true;
		} else if (this.endBlock === OLDEST) {
			const seekOldest = new fabprotos.orderer.SeekOldest();
			seekStop.setOldest(seekOldest);
			behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
			this.replay = true;
		} else {
			const seekSpecifiedStop = new fabprotos.orderer.SeekSpecified();
			if (this.endBlock) {
				seekSpecifiedStop.setNumber(this.endBlock);
				// user should be told that the block does not exist
				behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
				this.replay = true;
			} else {
				seekSpecifiedStop.setNumber(Long.MAX_VALUE);
			}
			seekStop.setSpecified(seekSpecifiedStop);
		}

		// seek info with all parts
		const seekInfo = new fabprotos.orderer.SeekInfo();
		seekInfo.setStart(seekStart);
		seekInfo.setStop(seekStop);
		// BLOCK_UNTIL_READY will mean hold the stream open and keep sending as
		//    the blocks come in
		// FAIL_IF_NOT_READY will mean if the block is not there throw an error
		seekInfo.setBehavior(behavior);

		// build the header for use with the seekInfo payload
		const channelHeader = this.channel.buildChannelHeader(
			fabprotos.common.HeaderType.DELIVER_SEEK_INFO,
github hyperledger / fabric-sdk-node / fabric-client / lib / ChannelEventHub.js View on Github external
this._ending_block_newest = true;
			const seekNewest = new fabprotos.orderer.SeekNewest();
			seekStop.setNewest(seekNewest);
			behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
		} else if (this._ending_block_number === OLDEST) {
			const seekOldest = new fabprotos.orderer.SeekOldest();
			seekStop.setOldest(seekOldest);
			behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
		} else {
			const seekSpecifiedStop = new fabprotos.orderer.SeekSpecified();
			if (this._ending_block_number) {
				seekSpecifiedStop.setNumber(this._ending_block_number);
				// user should be told that the block does not exist
				behavior = fabprotos.orderer.SeekInfo.SeekBehavior.FAIL_IF_NOT_READY;
			} else {
				seekSpecifiedStop.setNumber(Long.MAX_VALUE);
			}
			seekStop.setSpecified(seekSpecifiedStop);
		}

		// seek info with all parts
		const seekInfo = new fabprotos.orderer.SeekInfo();
		seekInfo.setStart(seekStart);
		seekInfo.setStop(seekStop);
		// BLOCK_UNTIL_READY will mean hold the stream open and keep sending as
		//     the blocks come in
		// FAIL_IF_NOT_READY will mean if the block is not there throw an error
		seekInfo.setBehavior(behavior);


		// build the header for use with the seekInfo payload
		const seekInfoHeader = clientUtils.buildChannelHeader(
github hyperledger / fabric-sdk-node / test / unit / channel-event-hub.js View on Github external
eh.registerBlockEvent(() => {
			t.fail('Should not have called success callback');
			t.end();
		}, () =>{
			t.fail('Should not have called error callback');
			t.end();
		},
		{startBlock: 10000000, endBlock: 'newest'}
		);
		t.pass('Successfully registered a newest playback block event');
	} catch(error) {
		t.fail( 'Failed - Should be able to register with newest replay');
	}
	t.equal(eh._ending_block_newest, true, 'Check the newest state');
	t.equal(eh._allowRegistration, false, 'Check the replay state');
	t.deepEqual(eh._ending_block_number, Long.MAX_VALUE, 'Check the replay end block');

	t.end();
});
github stellar / js-xdr / src / hyper.js View on Github external
const result = super.fromBits(low, high, false);
    return new this(result.low, result.high);
  }

  static isValid(value) {
    return value instanceof this;
  }

  constructor(low, high) {
    super(low, high, false);
  }
}

includeIoMixin(Hyper);

Hyper.MAX_VALUE = new Hyper(Long.MAX_VALUE.low, Long.MAX_VALUE.high);
Hyper.MIN_VALUE = new Hyper(Long.MIN_VALUE.low, Long.MIN_VALUE.high);
github ChatPlug / libfb-js / src / RandomIntGenerator.ts View on Github external
static getAttemptId (): Long {
    const sysTime: Long = Long.fromNumber(Date.now()).shiftLeft(22)
    const randomBit: Long = Long.fromNumber(RandomIntGenerator.generate() & 4194303).and(Long.MAX_VALUE)
    return sysTime.or(randomBit)
  }
github tulios / kafkajs / src / protocol / encoder.spec.js View on Github external
expect(signed64(L('281474976710656'))).toEqual(
        B(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01)
      )
      expect(signed64(L('36028797018963967'))).toEqual(
        B(0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f)
      )
      expect(signed64(L('36028797018963968'))).toEqual(
        B(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01)
      )
      expect(signed64(L('4611686018427387903'))).toEqual(
        B(0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x7f)
      )
      expect(signed64(L('4611686018427387904'))).toEqual(
        B(0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x80, 0x01)
      )
      expect(signed64(Long.MAX_VALUE)).toEqual(
        B(0xfe, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0x01)
      )

      expect(signed64(-1)).toEqual(B(0x01))
      expect(signed64(-64)).toEqual(B(0x7f))
      expect(signed64(-65)).toEqual(B(0x81, 0x01))
      expect(signed64(-8192)).toEqual(B(0xff, 0x7f))
      expect(signed64(-8193)).toEqual(B(0x81, 0x80, 0x01))
      expect(signed64(-1048576)).toEqual(B(0xff, 0xff, 0x7f))
      expect(signed64(-1048577)).toEqual(B(0x81, 0x80, 0x80, 0x01))
      expect(signed64(-134217728)).toEqual(B(0xff, 0xff, 0xff, 0x7f))
      expect(signed64(-134217729)).toEqual(B(0x81, 0x80, 0x80, 0x80, 0x01))
      expect(signed64(MIN_SAFE_NEGATIVE_SIGNED_INT)).toEqual(B(0xff, 0xff, 0xff, 0xff, 0x0f))
      expect(signed64(L('-17179869184'))).toEqual(B(0xff, 0xff, 0xff, 0xff, 0x7f))
      expect(signed64(L('-17179869185'))).toEqual(B(0x81, 0x80, 0x80, 0x80, 0x80, 0x01))
      expect(signed64(L('-2199023255552'))).toEqual(B(0xff, 0xff, 0xff, 0xff, 0xff, 0x7f))
github datastax / nodejs-driver / lib / types / duration.js View on Github external
Builder.prototype._validateNanos = function(units, nanosPerUnit) {
  this._validate64(units, Long.MAX_VALUE.subtract(this._nanoseconds).divide(nanosPerUnit), "nanoseconds");
};
github tulios / kafkajs / src / protocol / encoder.spec.js View on Github external
expect(decode64(signed64(134217727))).toEqual(L(134217727))
      expect(decode64(signed64(134217728))).toEqual(L(134217728))
      expect(decode64(signed64(MAX_SAFE_POSITIVE_SIGNED_INT))).toEqual(
        L(MAX_SAFE_POSITIVE_SIGNED_INT)
      )
      expect(decode64(signed64(L('17179869183')))).toEqual(L('17179869183'))
      expect(decode64(signed64(L('17179869184')))).toEqual(L('17179869184'))
      expect(decode64(signed64(L('2199023255551')))).toEqual(L('2199023255551'))
      expect(decode64(signed64(L('2199023255552')))).toEqual(L('2199023255552'))
      expect(decode64(signed64(L('281474976710655')))).toEqual(L('281474976710655'))
      expect(decode64(signed64(L('281474976710656')))).toEqual(L('281474976710656'))
      expect(decode64(signed64(L('36028797018963967')))).toEqual(L('36028797018963967'))
      expect(decode64(signed64(L('36028797018963968')))).toEqual(L('36028797018963968'))
      expect(decode64(signed64(L('4611686018427387903')))).toEqual(L('4611686018427387903'))
      expect(decode64(signed64(L('4611686018427387904')))).toEqual(L('4611686018427387904'))
      expect(decode64(signed64(Long.MAX_VALUE))).toEqual(Long.MAX_VALUE)
    })
  })