encoding: rename read int methods to readIx.

This commit is contained in:
Christopher Jeffrey 2017-08-06 03:27:06 -07:00
parent 1df577cb74
commit a290e6880d
No known key found for this signature in database
GPG Key ID: 8962AB9DE6666BBD
13 changed files with 96 additions and 96 deletions

View File

@ -600,8 +600,8 @@ ChainDB.prototype.writeDeployments = function writeDeployments(batch) {
bw.writeU8(deployment.bit);
bw.writeU32(deployment.startTime);
bw.writeU32(deployment.timeout);
bw.write32(deployment.threshold);
bw.write32(deployment.window);
bw.writeI32(deployment.threshold);
bw.writeI32(deployment.window);
}
batch.put(layout.V, bw.render());
@ -627,8 +627,8 @@ ChainDB.prototype.checkDeployments = async function checkDeployments() {
const bit = br.readU8();
const start = br.readU32();
const timeout = br.readU32();
const threshold = br.read32();
const window = br.read32();
const threshold = br.readI32();
const window = br.readI32();
const deployment = this.network.byBit(bit);
if (deployment

View File

@ -254,15 +254,15 @@ VersionPacket.prototype.getSize = function getSize() {
*/
VersionPacket.prototype.toWriter = function toWriter(bw) {
bw.write32(this.version);
bw.writeI32(this.version);
bw.writeU32(this.services);
bw.writeU32(0);
bw.write64(this.time);
bw.writeI64(this.time);
this.remote.toWriter(bw, false);
this.local.toWriter(bw, false);
bw.writeBytes(this.nonce);
bw.writeVarString(this.agent, 'ascii');
bw.write32(this.height);
bw.writeI32(this.height);
bw.writeU8(this.noRelay ? 0 : 1);
return bw;
};
@ -284,14 +284,14 @@ VersionPacket.prototype.toRaw = function toRaw() {
*/
VersionPacket.prototype.fromReader = function fromReader(br) {
this.version = br.read32();
this.version = br.readI32();
this.services = br.readU32();
// Note: hi service bits
// are currently unused.
br.readU32();
this.time = br.read53();
this.time = br.readI53();
this.remote.fromReader(br, false);
if (br.left() > 0) {
@ -303,7 +303,7 @@ VersionPacket.prototype.fromReader = function fromReader(br) {
this.agent = br.readVarString('ascii', 256);
if (br.left() > 0)
this.height = br.read32();
this.height = br.readI32();
if (br.left() > 0)
this.noRelay = br.readU8() === 0;
@ -2091,7 +2091,7 @@ FeeFilterPacket.prototype.getSize = function getSize() {
*/
FeeFilterPacket.prototype.toWriter = function toWriter(bw) {
bw.write64(this.rate);
bw.writeI64(this.rate);
return bw;
};
@ -2111,7 +2111,7 @@ FeeFilterPacket.prototype.toRaw = function toRaw() {
*/
FeeFilterPacket.prototype.fromReader = function fromReader(br) {
this.rate = br.read64();
this.rate = br.readI64();
return this;
};

View File

@ -317,7 +317,7 @@ Coin.prototype.toWriter = function toWriter(bw) {
bw.writeU32(this.version);
bw.writeU32(height);
bw.write64(this.value);
bw.writeI64(this.value);
bw.writeVarBytes(this.script.toRaw());
bw.writeU8(this.coinbase ? 1 : 0);
@ -343,7 +343,7 @@ Coin.prototype.toRaw = function toRaw() {
Coin.prototype.fromReader = function fromReader(br) {
this.version = br.readU32();
this.height = br.readU32();
this.value = br.read64();
this.value = br.readI64();
this.script.fromRaw(br.readVarBytes());
this.coinbase = br.readU8() === 1;

View File

@ -271,7 +271,7 @@ Output.fromJSON = function fromJSON(json) {
*/
Output.prototype.toWriter = function toWriter(bw) {
bw.write64(this.value);
bw.writeI64(this.value);
bw.writeVarBytes(this.script.toRaw());
return bw;
};
@ -294,7 +294,7 @@ Output.prototype.toRaw = function toRaw() {
*/
Output.prototype.fromReader = function fromReader(br) {
this.value = br.read64();
this.value = br.readI64();
this.script.fromRaw(br.readVarBytes());
return this;
};

View File

@ -525,7 +525,7 @@ TX.prototype.signatureHashV0 = function signatureHashV0(index, prev, type) {
for (let i = 0; i < index; i++) {
// Null all outputs not at
// current input index.
bw.write64(-1);
bw.writeI64(-1);
bw.writeVarint(0);
}
@ -684,7 +684,7 @@ TX.prototype.signatureHashV1 = function signatureHashV1(index, prev, value, type
bw.writeHash(input.prevout.hash);
bw.writeU32(input.prevout.index);
bw.writeVarBytes(prev.toRaw());
bw.write64(value);
bw.writeI64(value);
bw.writeU32(input.sequence);
bw.writeBytes(outputs);
bw.writeU32(this.locktime);

View File

@ -254,7 +254,7 @@ encoding.readU53BE = function readU53BE(data, off) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding._read64 = function _read64(data, off, force53, be) {
encoding._readI64 = function _readI64(data, off, force53, be) {
let hi, lo;
if (be) {
@ -293,8 +293,8 @@ encoding._read64 = function _read64(data, off, force53, be) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding.read64 = function read64(data, off) {
return encoding._read64(data, off, false, false);
encoding.readI64 = function readI64(data, off) {
return encoding._readI64(data, off, false, false);
};
/**
@ -305,8 +305,8 @@ encoding.read64 = function read64(data, off) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding.read64BE = function read64BE(data, off) {
return encoding._read64(data, off, false, true);
encoding.readI64BE = function readI64BE(data, off) {
return encoding._readI64(data, off, false, true);
};
/**
@ -317,8 +317,8 @@ encoding.read64BE = function read64BE(data, off) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding.read53 = function read53(data, off) {
return encoding._read64(data, off, true, false);
encoding.readI53 = function readI53(data, off) {
return encoding._readI64(data, off, true, false);
};
/**
@ -329,8 +329,8 @@ encoding.read53 = function read53(data, off) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding.read53BE = function read53BE(data, off) {
return encoding._read64(data, off, true, true);
encoding.readI53BE = function readI53BE(data, off) {
return encoding._readI64(data, off, true, true);
};
/**
@ -344,7 +344,7 @@ encoding.read53BE = function read53BE(data, off) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding._write64 = function _write64(dst, num, off, be) {
encoding._writeI64 = function _writeI64(dst, num, off, be) {
const negative = num < 0;
if (negative) {
@ -397,7 +397,7 @@ encoding._write64 = function _write64(dst, num, off, be) {
*/
encoding.writeU64 = function writeU64(dst, num, off) {
return encoding._write64(dst, num, off, false);
return encoding._writeI64(dst, num, off, false);
};
/**
@ -410,7 +410,7 @@ encoding.writeU64 = function writeU64(dst, num, off) {
*/
encoding.writeU64BE = function writeU64BE(dst, num, off) {
return encoding._write64(dst, num, off, true);
return encoding._writeI64(dst, num, off, true);
};
/**
@ -422,8 +422,8 @@ encoding.writeU64BE = function writeU64BE(dst, num, off) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding.write64 = function write64(dst, num, off) {
return encoding._write64(dst, num, off, false);
encoding.writeI64 = function writeI64(dst, num, off) {
return encoding._writeI64(dst, num, off, false);
};
/**
@ -435,8 +435,8 @@ encoding.write64 = function write64(dst, num, off) {
* @throws on num > MAX_SAFE_INTEGER
*/
encoding.write64BE = function write64BE(dst, num, off) {
return encoding._write64(dst, num, off, true);
encoding.writeI64BE = function writeI64BE(dst, num, off) {
return encoding._writeI64(dst, num, off, true);
};
/**
@ -470,7 +470,7 @@ encoding.readU64BEBN = function readU64BEBN(data, off) {
* @returns {BN}
*/
encoding.read64BN = function read64BN(data, off) {
encoding.readI64BN = function readI64BN(data, off) {
const num = data.slice(off, off + 8);
if (num[num.length - 1] & 0x80)
@ -485,7 +485,7 @@ encoding.read64BN = function read64BN(data, off) {
* @returns {BN}
*/
encoding.read64BEBN = function read64BEBN(data, off) {
encoding.readI64BEBN = function readI64BEBN(data, off) {
const num = data.slice(off, off + 8);
if (num[0] & 0x80)
@ -504,11 +504,11 @@ encoding.read64BEBN = function read64BEBN(data, off) {
* @returns {Number} Buffer offset.
*/
encoding._write64BN = function _write64BN(dst, num, off, be) {
encoding._writeI64BN = function _writeI64BN(dst, num, off, be) {
const bits = num.bitLength();
if (bits <= 53)
return encoding._write64(dst, num.toNumber(), off, be);
return encoding._writeI64(dst, num.toNumber(), off, be);
if (bits > 64)
num = num.maskn(64);
@ -533,7 +533,7 @@ encoding._write64BN = function _write64BN(dst, num, off, be) {
*/
encoding.writeU64BN = function writeU64BN(dst, num, off) {
return encoding._write64BN(dst, num, off, false);
return encoding._writeI64BN(dst, num, off, false);
};
/**
@ -545,7 +545,7 @@ encoding.writeU64BN = function writeU64BN(dst, num, off) {
*/
encoding.writeU64BEBN = function writeU64BEBN(dst, num, off) {
return encoding._write64BN(dst, num, off, true);
return encoding._writeI64BN(dst, num, off, true);
};
/**
@ -556,8 +556,8 @@ encoding.writeU64BEBN = function writeU64BEBN(dst, num, off) {
* @returns {Number} Buffer offset.
*/
encoding.write64BN = function write64BN(dst, num, off) {
return encoding._write64BN(dst, num, off, false);
encoding.writeI64BN = function writeI64BN(dst, num, off) {
return encoding._writeI64BN(dst, num, off, false);
};
/**
@ -568,8 +568,8 @@ encoding.write64BN = function write64BN(dst, num, off) {
* @returns {Number} Buffer offset.
*/
encoding.write64BEBN = function write64BEBN(dst, num, off) {
return encoding._write64BN(dst, num, off, true);
encoding.writeI64BEBN = function writeI64BEBN(dst, num, off) {
return encoding._writeI64BN(dst, num, off, true);
};
/**

View File

@ -266,7 +266,7 @@ BufferReader.prototype.readU53BE = function readU53BE() {
* @returns {Number}
*/
BufferReader.prototype.read8 = function read8() {
BufferReader.prototype.readI8 = function readI8() {
this.assert(this.offset + 1 <= this.data.length);
const ret = this.data.readInt8(this.offset, true);
this.offset += 1;
@ -278,7 +278,7 @@ BufferReader.prototype.read8 = function read8() {
* @returns {Number}
*/
BufferReader.prototype.read16 = function read16() {
BufferReader.prototype.readI16 = function readI16() {
this.assert(this.offset + 2 <= this.data.length);
const ret = this.data.readInt16LE(this.offset, true);
this.offset += 2;
@ -290,7 +290,7 @@ BufferReader.prototype.read16 = function read16() {
* @returns {Number}
*/
BufferReader.prototype.read16BE = function read16BE() {
BufferReader.prototype.readI16BE = function readI16BE() {
this.assert(this.offset + 2 <= this.data.length);
const ret = this.data.readInt16BE(this.offset, true);
this.offset += 2;
@ -302,7 +302,7 @@ BufferReader.prototype.read16BE = function read16BE() {
* @returns {Number}
*/
BufferReader.prototype.read32 = function read32() {
BufferReader.prototype.readI32 = function readI32() {
this.assert(this.offset + 4 <= this.data.length);
const ret = this.data.readInt32LE(this.offset, true);
this.offset += 4;
@ -314,7 +314,7 @@ BufferReader.prototype.read32 = function read32() {
* @returns {Number}
*/
BufferReader.prototype.read32BE = function read32BE() {
BufferReader.prototype.readI32BE = function readI32BE() {
this.assert(this.offset + 4 <= this.data.length);
const ret = this.data.readInt32BE(this.offset, true);
this.offset += 4;
@ -327,9 +327,9 @@ BufferReader.prototype.read32BE = function read32BE() {
* @throws on num > MAX_SAFE_INTEGER
*/
BufferReader.prototype.read64 = function read64() {
BufferReader.prototype.readI64 = function readI64() {
this.assert(this.offset + 8 <= this.data.length);
const ret = encoding.read64(this.data, this.offset);
const ret = encoding.readI64(this.data, this.offset);
this.offset += 8;
return ret;
};
@ -340,9 +340,9 @@ BufferReader.prototype.read64 = function read64() {
* @throws on num > MAX_SAFE_INTEGER
*/
BufferReader.prototype.read64BE = function read64BE() {
BufferReader.prototype.readI64BE = function readI64BE() {
this.assert(this.offset + 8 <= this.data.length);
const ret = encoding.read64BE(this.data, this.offset);
const ret = encoding.readI64BE(this.data, this.offset);
this.offset += 8;
return ret;
};
@ -353,9 +353,9 @@ BufferReader.prototype.read64BE = function read64BE() {
* @returns {Number}
*/
BufferReader.prototype.read53 = function read53() {
BufferReader.prototype.readI53 = function readI53() {
this.assert(this.offset + 8 <= this.data.length);
const ret = encoding.read53(this.data, this.offset);
const ret = encoding.readI53(this.data, this.offset);
this.offset += 8;
return ret;
};
@ -366,9 +366,9 @@ BufferReader.prototype.read53 = function read53() {
* @returns {Number}
*/
BufferReader.prototype.read53BE = function read53BE() {
BufferReader.prototype.readI53BE = function readI53BE() {
this.assert(this.offset + 8 <= this.data.length);
const ret = encoding.read53BE(this.data, this.offset);
const ret = encoding.readI53BE(this.data, this.offset);
this.offset += 8;
return ret;
};
@ -402,9 +402,9 @@ BufferReader.prototype.readU64BEBN = function readU64BEBN() {
* @returns {BN}
*/
BufferReader.prototype.read64BN = function read64BN() {
BufferReader.prototype.readI64BN = function readI64BN() {
this.assert(this.offset + 8 <= this.data.length);
const ret = encoding.read64BN(this.data, this.offset);
const ret = encoding.readI64BN(this.data, this.offset);
this.offset += 8;
return ret;
};
@ -414,9 +414,9 @@ BufferReader.prototype.read64BN = function read64BN() {
* @returns {BN}
*/
BufferReader.prototype.read64BEBN = function read64BEBN() {
BufferReader.prototype.readI64BEBN = function readI64BEBN() {
this.assert(this.offset + 8 <= this.data.length);
const ret = encoding.read64BEBN(this.data, this.offset);
const ret = encoding.readI64BEBN(this.data, this.offset);
this.offset += 8;
return ret;
};

View File

@ -155,7 +155,7 @@ StaticWriter.prototype.writeU64BEBN = function writeU64BEBN(value) {
* @param {Number} value
*/
StaticWriter.prototype.write8 = function write8(value) {
StaticWriter.prototype.writeI8 = function writeI8(value) {
this.written = this.data.writeInt8(value, this.written, true);
};
@ -164,7 +164,7 @@ StaticWriter.prototype.write8 = function write8(value) {
* @param {Number} value
*/
StaticWriter.prototype.write16 = function write16(value) {
StaticWriter.prototype.writeI16 = function writeI16(value) {
this.written = this.data.writeInt16LE(value, this.written, true);
};
@ -173,7 +173,7 @@ StaticWriter.prototype.write16 = function write16(value) {
* @param {Number} value
*/
StaticWriter.prototype.write16BE = function write16BE(value) {
StaticWriter.prototype.writeI16BE = function writeI16BE(value) {
this.written = this.data.writeInt16BE(value, this.written, true);
};
@ -182,7 +182,7 @@ StaticWriter.prototype.write16BE = function write16BE(value) {
* @param {Number} value
*/
StaticWriter.prototype.write32 = function write32(value) {
StaticWriter.prototype.writeI32 = function writeI32(value) {
this.written = this.data.writeInt32LE(value, this.written, true);
};
@ -191,7 +191,7 @@ StaticWriter.prototype.write32 = function write32(value) {
* @param {Number} value
*/
StaticWriter.prototype.write32BE = function write32BE(value) {
StaticWriter.prototype.writeI32BE = function writeI32BE(value) {
this.written = this.data.writeInt32BE(value, this.written, true);
};
@ -200,8 +200,8 @@ StaticWriter.prototype.write32BE = function write32BE(value) {
* @param {Number} value
*/
StaticWriter.prototype.write64 = function write64(value) {
this.written = encoding.write64(this.data, value, this.written);
StaticWriter.prototype.writeI64 = function writeI64(value) {
this.written = encoding.writeI64(this.data, value, this.written);
};
/**
@ -209,8 +209,8 @@ StaticWriter.prototype.write64 = function write64(value) {
* @param {Number} value
*/
StaticWriter.prototype.write64BE = function write64BE(value) {
this.written = encoding.write64BE(this.data, value, this.written);
StaticWriter.prototype.writeI64BE = function writeI64BE(value) {
this.written = encoding.writeI64BE(this.data, value, this.written);
};
/**
@ -218,7 +218,7 @@ StaticWriter.prototype.write64BE = function write64BE(value) {
* @param {BN} value
*/
StaticWriter.prototype.write64BN = function write64BN(value) {
StaticWriter.prototype.writeI64BN = function writeI64BN(value) {
assert(false, 'Not implemented.');
};
@ -227,7 +227,7 @@ StaticWriter.prototype.write64BN = function write64BN(value) {
* @param {BN} value
*/
StaticWriter.prototype.write64BEBN = function write64BEBN(value) {
StaticWriter.prototype.writeI64BEBN = function writeI64BEBN(value) {
assert(false, 'Not implemented.');
};

View File

@ -115,10 +115,10 @@ BufferWriter.prototype.render = function render(keep) {
off = data.writeInt32BE(op.value, off, true);
break;
case I64:
off = encoding.write64(data, op.value, off);
off = encoding.writeI64(data, op.value, off);
break;
case I64BE:
off = encoding.write64BE(data, op.value, off);
off = encoding.writeI64BE(data, op.value, off);
break;
case FL:
off = data.writeFloatLE(op.value, off, true);
@ -287,7 +287,7 @@ BufferWriter.prototype.writeU64BEBN = function writeU64BEBN(value) {
* @param {Number} value
*/
BufferWriter.prototype.write8 = function write8(value) {
BufferWriter.prototype.writeI8 = function writeI8(value) {
this.written += 1;
this.ops.push(new WriteOp(I8, value));
};
@ -297,7 +297,7 @@ BufferWriter.prototype.write8 = function write8(value) {
* @param {Number} value
*/
BufferWriter.prototype.write16 = function write16(value) {
BufferWriter.prototype.writeI16 = function writeI16(value) {
this.written += 2;
this.ops.push(new WriteOp(I16, value));
};
@ -307,7 +307,7 @@ BufferWriter.prototype.write16 = function write16(value) {
* @param {Number} value
*/
BufferWriter.prototype.write16BE = function write16BE(value) {
BufferWriter.prototype.writeI16BE = function writeI16BE(value) {
this.written += 2;
this.ops.push(new WriteOp(I16BE, value));
};
@ -317,7 +317,7 @@ BufferWriter.prototype.write16BE = function write16BE(value) {
* @param {Number} value
*/
BufferWriter.prototype.write32 = function write32(value) {
BufferWriter.prototype.writeI32 = function writeI32(value) {
this.written += 4;
this.ops.push(new WriteOp(I32, value));
};
@ -327,7 +327,7 @@ BufferWriter.prototype.write32 = function write32(value) {
* @param {Number} value
*/
BufferWriter.prototype.write32BE = function write32BE(value) {
BufferWriter.prototype.writeI32BE = function writeI32BE(value) {
this.written += 4;
this.ops.push(new WriteOp(I32BE, value));
};
@ -337,7 +337,7 @@ BufferWriter.prototype.write32BE = function write32BE(value) {
* @param {Number} value
*/
BufferWriter.prototype.write64 = function write64(value) {
BufferWriter.prototype.writeI64 = function writeI64(value) {
this.written += 8;
this.ops.push(new WriteOp(I64, value));
};
@ -347,7 +347,7 @@ BufferWriter.prototype.write64 = function write64(value) {
* @param {Number} value
*/
BufferWriter.prototype.write64BE = function write64BE(value) {
BufferWriter.prototype.writeI64BE = function writeI64BE(value) {
this.written += 8;
this.ops.push(new WriteOp(I64BE, value));
};
@ -357,7 +357,7 @@ BufferWriter.prototype.write64BE = function write64BE(value) {
* @param {BN} value
*/
BufferWriter.prototype.write64BN = function write64BN(value) {
BufferWriter.prototype.writeI64BN = function writeI64BN(value) {
assert(false, 'Not implemented.');
};
@ -366,7 +366,7 @@ BufferWriter.prototype.write64BN = function write64BN(value) {
* @param {BN} value
*/
BufferWriter.prototype.write64BEBN = function write64BEBN(value) {
BufferWriter.prototype.writeI64BEBN = function writeI64BEBN(value) {
assert(false, 'Not implemented.');
};

View File

@ -154,7 +154,7 @@ Path.prototype.fromRaw = function fromRaw(data) {
break;
}
this.version = br.read8();
this.version = br.readI8();
this.type = br.readU8();
if (this.type === 129 || this.type === 130)
@ -232,7 +232,7 @@ Path.prototype.toRaw = function toRaw() {
break;
}
bw.write8(this.version);
bw.writeI8(this.version);
bw.writeU8(this.type);
return bw.render();

View File

@ -205,7 +205,7 @@ ErrorPacket.prototype.toWriter = function toWriter(bw) {
switch (typeof this.error.code) {
case 'number':
bw.writeU8(2);
bw.write32(this.error.code);
bw.writeI32(this.error.code);
break;
case 'string':
bw.writeU8(1);
@ -227,7 +227,7 @@ ErrorPacket.fromRaw = function fromRaw(data) {
switch (br.readU8()) {
case 2:
packet.error.code = br.read32();
packet.error.code = br.readI32();
break;
case 1:
packet.error.code = br.readVarString('utf8');
@ -276,7 +276,7 @@ CheckPacket.prototype.getSize = function getSize() {
CheckPacket.prototype.toWriter = function toWriter(bw) {
this.tx.toWriter(bw);
this.view.toWriter(bw, this.tx);
bw.write32(this.flags != null ? this.flags : -1);
bw.writeI32(this.flags != null ? this.flags : -1);
};
CheckPacket.fromRaw = function fromRaw(data) {
@ -285,7 +285,7 @@ CheckPacket.fromRaw = function fromRaw(data) {
packet.tx = TX.fromReader(br);
packet.view = CoinView.fromReader(br, packet.tx);
packet.flags = br.read32();
packet.flags = br.readI32();
if (packet.flags === -1)
packet.flags = null;
@ -543,7 +543,7 @@ CheckInputPacket.prototype.toWriter = function toWriter(bw) {
bw.writeVarint(this.index);
bw.writeVarint(this.coin.value);
this.coin.script.toWriter(bw);
bw.write32(this.flags != null ? this.flags : -1);
bw.writeI32(this.flags != null ? this.flags : -1);
};
CheckInputPacket.fromRaw = function fromRaw(data) {
@ -557,7 +557,7 @@ CheckInputPacket.fromRaw = function fromRaw(data) {
packet.coin.value = br.readVarint();
packet.coin.script.fromReader(br);
packet.flags = br.read32();
packet.flags = br.readI32();
if (packet.flags === -1)
packet.flags = null;

View File

@ -216,7 +216,7 @@ function pathFromRaw(data) {
break;
}
path.version = p.read8();
path.version = p.readI8();
path.type = p.readU8();
return path;

View File

@ -229,12 +229,12 @@ describe('Utils', function() {
it(`should write+read a ${bits} bit ${sign} int`, () => {
const buf1 = Buffer.allocUnsafe(8);
const buf2 = Buffer.allocUnsafe(8);
encoding.write64BN(buf1, num, 0);
encoding.write64(buf2, num.toNumber(), 0);
encoding.writeI64BN(buf1, num, 0);
encoding.writeI64(buf2, num.toNumber(), 0);
assert.deepEqual(buf1, buf2);
const n1 = encoding.read64BN(buf1, 0);
const n2 = encoding.read64(buf2, 0);
const n1 = encoding.readI64BN(buf1, 0);
const n2 = encoding.readI64(buf2, 0);
assert.equal(n1.toNumber(), n2);
});