Skip to content
This repository has been archived by the owner on Jan 25, 2024. It is now read-only.

Commit

Permalink
fix(bufferutils): remove pushdata re-exports
Browse files Browse the repository at this point in the history
Remove these exports:

* `bufferutils.pushDataSize`
* `bufferutils.readPushDataInt`
* `bufferutils.writePushDataInt`

They are not needed and are already removed upstream.

While this changes the public API, none of our projects use these
functions.

Issue: BG-16466
  • Loading branch information
OttoAllmendinger committed Jan 15, 2020
1 parent 6ec29e5 commit f48669e
Show file tree
Hide file tree
Showing 4 changed files with 1 addition and 71 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
"scripts": {
"coverage-report": "nyc report --reporter=lcov",
"coverage-html": "nyc report --reporter=html",
"coverage": "BITGO_UTXO_LIB_TEST_EXPECTED_COUNT=3535 nyc --check-coverage --branches 90 --functions 90 mocha --recursive",
"coverage": "BITGO_UTXO_LIB_TEST_EXPECTED_COUNT=3496 nyc --check-coverage --branches 90 --functions 90 mocha --recursive",
"integration": "mocha test/integration/",
"standard": "standard",
"test": "npm run standard && npm run coverage",
Expand Down
4 changes: 0 additions & 4 deletions src/bufferutils.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
var pushdata = require('pushdata-bitcoin')
var varuint = require('varuint-bitcoin')

// https://github.com/feross/buffer/blob/master/index.js#L1127
Expand Down Expand Up @@ -52,14 +51,11 @@ function writeVarInt (buffer, number, offset) {
}

module.exports = {
pushDataSize: pushdata.encodingLength,
readPushDataInt: pushdata.decode,
readUInt64LE: readUInt64LE,
readInt64LE: readInt64LE,
readVarInt: readVarInt,
varIntBuffer: varuint.encode,
varIntSize: varuint.encodingLength,
writePushDataInt: pushdata.encode,
writeUInt64LE: writeUInt64LE,
writeVarInt: writeVarInt
}
52 changes: 0 additions & 52 deletions test/bufferutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,45 +6,6 @@ var bufferutils = require('../src/bufferutils')
var fixtures = require('./fixtures/bufferutils.json')

describe('bufferutils', function () {
describe('pushDataSize', function () {
fixtures.valid.forEach(function (f) {
it('determines the pushDataSize of ' + f.dec + ' correctly', function () {
if (!f.hexPD) return

var size = bufferutils.pushDataSize(f.dec)

assert.strictEqual(size, f.hexPD.length / 2)
})
})
})

describe('readPushDataInt', function () {
fixtures.valid.forEach(function (f) {
if (!f.hexPD) return

it('decodes ' + f.hexPD + ' correctly', function () {
var buffer = Buffer.from(f.hexPD, 'hex')
var d = bufferutils.readPushDataInt(buffer, 0)
var fopcode = parseInt(f.hexPD.substr(0, 2), 16)

assert.strictEqual(d.opcode, fopcode)
assert.strictEqual(d.number, f.dec)
assert.strictEqual(d.size, buffer.length)
})
})

fixtures.invalid.readPushDataInt.forEach(function (f) {
if (!f.hexPD) return

it('decodes ' + f.hexPD + ' as null', function () {
var buffer = Buffer.from(f.hexPD, 'hex')

var n = bufferutils.readPushDataInt(buffer, 0)
assert.strictEqual(n, null)
})
})
})

describe('readInt64LE', function () {
fixtures.negative.forEach(function (f) {
it('decodes ' + f.hex64 + ' correctly', function () {
Expand Down Expand Up @@ -119,19 +80,6 @@ describe('bufferutils', function () {
})
})

describe('writePushDataInt', function () {
fixtures.valid.forEach(function (f) {
if (!f.hexPD) return

it('encodes ' + f.dec + ' correctly', function () {
var buffer = Buffer.alloc(5, 0)

var n = bufferutils.writePushDataInt(buffer, f.dec, 0)
assert.strictEqual(buffer.slice(0, n).toString('hex'), f.hexPD)
})
})
})

describe('writeUInt64LE', function () {
fixtures.valid.forEach(function (f) {
it('encodes ' + f.dec + ' correctly', function () {
Expand Down
14 changes: 0 additions & 14 deletions test/fixtures/bufferutils.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,20 +98,6 @@
"hexVI": "ff0100000000000020",
"dec": 9007199254740993
}
],
"readPushDataInt": [
{
"description": "OP_PUSHDATA1, no size",
"hexPD": "4c"
},
{
"description": "OP_PUSHDATA2, no size",
"hexPD": "4d"
},
{
"description": "OP_PUSHDATA4, no size",
"hexPD": "4e"
}
]
},
"negative": [
Expand Down

0 comments on commit f48669e

Please sign in to comment.