Skip to content
This repository has been archived by the owner on Apr 6, 2020. It is now read-only.

Commit

Permalink
Replace uses of deprecated new Buffer with Buffer.from
Browse files Browse the repository at this point in the history
    sed -i.bak 's/new Buffer/Buffer.from/' *.js test/*.js && \
    find . -name '*.bak' -delete
  • Loading branch information
whymarrh committed Dec 7, 2018
1 parent 2bda290 commit de8564b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
12 changes: 6 additions & 6 deletions header.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,26 +66,26 @@ var BlockHeader = module.exports = function (data, opts) {
default: utils.zeros(256)
}, {
name: 'difficulty',
default: new Buffer([])
default: Buffer.from([])
}, {
name: 'number',
// TODO: params.homeSteadForkNumber.v left for legacy reasons, replace on future release
default: utils.intToBuffer(1150000)
}, {
name: 'gasLimit',
default: new Buffer('ffffffffffffff', 'hex')
default: Buffer.from('ffffffffffffff', 'hex')
}, {
name: 'gasUsed',
empty: true,
default: new Buffer([])
default: Buffer.from([])
}, {
name: 'timestamp',
default: new Buffer([])
default: Buffer.from([])
}, {
name: 'extraData',
allowZero: true,
empty: true,
default: new Buffer([])
default: Buffer.from([])
}, {
name: 'mixHash',
default: utils.zeros(32)
Expand Down Expand Up @@ -281,5 +281,5 @@ BlockHeader.prototype.setGenesisParams = function () {
this.extraData = this._common.genesis().extraData
this.nonce = this._common.genesis().nonce
this.stateRoot = this._common.genesis().stateRoot
this.number = new Buffer([])
this.number = Buffer.from([])
}
4 changes: 2 additions & 2 deletions tests/block.js
Original file line number Diff line number Diff line change
Expand Up @@ -50,15 +50,15 @@ tape('[Block]: block functions', function (t) {
t.test('should test isGenesis (mainnet default)', function (st) {
var block = new Block()
st.notEqual(block.isGenesis(), true)
block.header.number = new Buffer([])
block.header.number = Buffer.from([])
st.equal(block.isGenesis(), true)
st.end()
})

t.test('should test isGenesis (ropsten)', function (st) {
var block = new Block(null, { 'chain': 'ropsten' })
st.notEqual(block.isGenesis(), true)
block.header.number = new Buffer([])
block.header.number = Buffer.from([])
st.equal(block.isGenesis(), true)
st.end()
})
Expand Down
12 changes: 6 additions & 6 deletions tests/header.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ tape('[Block]: Header functions', function (t) {
st.equal(header.transactionsTrie.toString('hex'), utils.SHA3_RLP_S)
st.equal(header.receiptTrie.toString('hex'), utils.SHA3_RLP_S)
st.deepEqual(header.bloom, utils.zeros(256))
st.deepEqual(header.difficulty, new Buffer([]))
st.deepEqual(header.difficulty, Buffer.from([]))
st.deepEqual(header.number, utils.intToBuffer(1150000))
st.deepEqual(header.gasLimit, new Buffer('ffffffffffffff', 'hex'))
st.deepEqual(header.gasUsed, new Buffer([]))
st.deepEqual(header.timestamp, new Buffer([]))
st.deepEqual(header.extraData, new Buffer([]))
st.deepEqual(header.gasLimit, Buffer.from('ffffffffffffff', 'hex'))
st.deepEqual(header.gasUsed, Buffer.from([]))
st.deepEqual(header.timestamp, Buffer.from([]))
st.deepEqual(header.extraData, Buffer.from([]))
st.deepEqual(header.mixHash, utils.zeros(32))
st.deepEqual(header.nonce, utils.zeros(8))
}
Expand Down Expand Up @@ -60,7 +60,7 @@ tape('[Block]: Header functions', function (t) {
t.test('should test isGenesis', function (st) {
var header = new Header()
st.equal(header.isGenesis(), false)
header.number = new Buffer([])
header.number = Buffer.from([])
st.equal(header.isGenesis(), true)
st.end()
})
Expand Down

0 comments on commit de8564b

Please sign in to comment.