From 146fbe2997c25b1b77f4342714c074c0f1a3a492 Mon Sep 17 00:00:00 2001
From: Matias Alejo Garcia <ematiu@gmail.com>
Date: Fri, 8 Nov 2019 16:39:50 -0300
Subject: [PATCH] rm new Buffer warning from bitcore-lib

---
 .../bitcore-lib-cash/lib/script/script.js     |  4 +-
 .../bitcore-lib/lib/encoding/base58check.js   |  4 +-
 packages/bitcore-lib/lib/hdprivatekey.js      |  6 +-
 packages/bitcore-lib/lib/script/script.js     |  4 +-
 .../lib/transaction/input/input.js            |  6 +-
 .../bitcore-lib/lib/transaction/output.js     |  4 +-
 .../bitcore-lib/lib/transaction/sighash.js    |  2 +-
 packages/bitcore-lib/lib/util/buffer.js       |  4 +-
 packages/bitcore-lib/test/address.js          | 12 +--
 packages/bitcore-lib/test/address_witness.js  |  2 +-
 packages/bitcore-lib/test/block/block.js      | 12 +--
 .../bitcore-lib/test/block/blockheader.js     |  8 +-
 .../bitcore-lib/test/block/merkleblock.js     |  8 +-
 packages/bitcore-lib/test/crypto/bn.js        |  6 +-
 packages/bitcore-lib/test/crypto/ecdsa.js     | 32 ++++----
 packages/bitcore-lib/test/crypto/hash.js      | 22 +++---
 packages/bitcore-lib/test/crypto/point.js     |  4 +-
 packages/bitcore-lib/test/crypto/signature.js | 30 ++++----
 packages/bitcore-lib/test/encoding/base58.js  |  6 +-
 .../bitcore-lib/test/encoding/base58check.js  |  2 +-
 .../bitcore-lib/test/encoding/bufferreader.js | 68 ++++++++---------
 .../bitcore-lib/test/encoding/bufferwriter.js | 14 ++--
 packages/bitcore-lib/test/encoding/varint.js  |  4 +-
 packages/bitcore-lib/test/hdkeys.js           | 24 +++---
 packages/bitcore-lib/test/hdprivatekey.js     |  2 +-
 packages/bitcore-lib/test/hdpublickey.js      |  2 +-
 packages/bitcore-lib/test/message.js          |  4 +-
 packages/bitcore-lib/test/networks.js         |  2 +-
 packages/bitcore-lib/test/opcode.js           |  2 +-
 packages/bitcore-lib/test/privatekey.js       | 12 +--
 packages/bitcore-lib/test/publickey.js        | 28 +++----
 .../bitcore-lib/test/script/interpreter.js    | 54 ++++++-------
 packages/bitcore-lib/test/script/script.js    | 76 +++++++++----------
 .../bitcore-lib/test/transaction/output.js    |  6 +-
 .../bitcore-lib/test/transaction/sighash.js   |  6 +-
 .../test/transaction/sighashwitness.js        |  4 +-
 .../bitcore-lib/test/transaction/signature.js |  2 +-
 .../test/transaction/transaction.js           | 26 +++----
 packages/bitcore-lib/test/util/buffer.js      | 26 +++----
 39 files changed, 270 insertions(+), 270 deletions(-)

diff --git a/packages/bitcore-lib-cash/lib/script/script.js b/packages/bitcore-lib-cash/lib/script/script.js
index 3d341cfcb..7e28c210d 100644
--- a/packages/bitcore-lib-cash/lib/script/script.js
+++ b/packages/bitcore-lib-cash/lib/script/script.js
@@ -172,12 +172,12 @@ Script.fromASM = function(str) {
 };
 
 Script.fromHex = function(str) {
-  return new Script(new buffer.Buffer(str, 'hex'));
+  return new Script(Buffer.from(str, 'hex'));
 };
 
 Script.fromString = function(str) {
   if (JSUtil.isHexa(str) || str.length === 0) {
-    return new Script(new buffer.Buffer(str, 'hex'));
+    return new Script(Buffer.from(str, 'hex'));
   }
   var script = new Script();
   script.chunks = [];
diff --git a/packages/bitcore-lib/lib/encoding/base58check.js b/packages/bitcore-lib/lib/encoding/base58check.js
index 6372eb974..d768ec3c9 100644
--- a/packages/bitcore-lib/lib/encoding/base58check.js
+++ b/packages/bitcore-lib/lib/encoding/base58check.js
@@ -26,10 +26,10 @@ Base58Check.prototype.set = function(obj) {
 
 Base58Check.validChecksum = function validChecksum(data, checksum) {
   if (_.isString(data)) {
-    data = new buffer.Buffer(Base58.decode(data));
+    data = Buffer.from(Base58.decode(data));
   }
   if (_.isString(checksum)) {
-    checksum = new buffer.Buffer(Base58.decode(checksum));
+    checksum =  Buffer.from(Base58.decode(checksum));
   }
   if (!checksum) {
     checksum = data.slice(-4);
diff --git a/packages/bitcore-lib/lib/hdprivatekey.js b/packages/bitcore-lib/lib/hdprivatekey.js
index f213fa57c..8fc3f6c66 100644
--- a/packages/bitcore-lib/lib/hdprivatekey.js
+++ b/packages/bitcore-lib/lib/hdprivatekey.js
@@ -239,12 +239,12 @@ HDPrivateKey.prototype._deriveWithNumber = function(index, hardened, nonComplian
     // The private key serialization in this case will not be exactly 32 bytes and can be
     // any value less, and the value is not zero-padded.
     var nonZeroPadded = this.privateKey.bn.toBuffer();
-    data = BufferUtil.concat([new buffer.Buffer([0]), nonZeroPadded, indexBuffer]);
+    data = BufferUtil.concat([Buffer.from([0]), nonZeroPadded, indexBuffer]);
   } else if (hardened) {
     // This will use a 32 byte zero padded serialization of the private key
     var privateKeyBuffer = this.privateKey.bn.toBuffer({size: 32});
     assert(privateKeyBuffer.length === 32, 'length of private key buffer is expected to be 32 bytes');
-    data = BufferUtil.concat([new buffer.Buffer([0]), privateKeyBuffer, indexBuffer]);
+    data = BufferUtil.concat([Buffer.from([0]), privateKeyBuffer, indexBuffer]);
   } else {
     data = BufferUtil.concat([this.publicKey.toBuffer(), indexBuffer]);
   }
@@ -417,7 +417,7 @@ HDPrivateKey.fromSeed = function(hexa, network) {
   if (hexa.length > MAXIMUM_ENTROPY_BITS * BITS_TO_BYTES) {
     throw new hdErrors.InvalidEntropyArgument.TooMuchEntropy(hexa);
   }
-  var hash = Hash.sha512hmac(hexa, new buffer.Buffer('Bitcoin seed'));
+  var hash = Hash.sha512hmac(hexa, Buffer.from('Bitcoin seed'));
 
   return new HDPrivateKey({
     network: Network.get(network) || Network.defaultNetwork,
diff --git a/packages/bitcore-lib/lib/script/script.js b/packages/bitcore-lib/lib/script/script.js
index 89b618f09..72f2109ce 100644
--- a/packages/bitcore-lib/lib/script/script.js
+++ b/packages/bitcore-lib/lib/script/script.js
@@ -172,12 +172,12 @@ Script.fromASM = function(str) {
 };
 
 Script.fromHex = function(str) {
-  return new Script(new buffer.Buffer(str, 'hex'));
+  return new Script(Buffer.from(str, 'hex'));
 };
 
 Script.fromString = function(str) {
   if (JSUtil.isHexa(str) || str.length === 0) {
-    return new Script(new buffer.Buffer(str, 'hex'));
+    return new Script(Buffer.from(str, 'hex'));
   }
   var script = new Script();
   script.chunks = [];
diff --git a/packages/bitcore-lib/lib/transaction/input/input.js b/packages/bitcore-lib/lib/transaction/input/input.js
index 1c27a2e08..48e43412b 100644
--- a/packages/bitcore-lib/lib/transaction/input/input.js
+++ b/packages/bitcore-lib/lib/transaction/input/input.js
@@ -54,7 +54,7 @@ Input.fromObject = function(obj) {
 Input.prototype._fromObject = function(params) {
   var prevTxId;
   if (_.isString(params.prevTxId) && JSUtil.isHexa(params.prevTxId)) {
-    prevTxId = new buffer.Buffer(params.prevTxId, 'hex');
+    prevTxId = Buffer.from(params.prevTxId, 'hex');
   } else {
     prevTxId = params.prevTxId;
   }
@@ -121,7 +121,7 @@ Input.prototype.setScript = function(script) {
     this._scriptBuffer = script.toBuffer();
   } else if (JSUtil.isHexa(script)) {
     // hex string script
-    this._scriptBuffer = new buffer.Buffer(script, 'hex');
+    this._scriptBuffer = Buffer.from(script, 'hex');
   } else if (_.isString(script)) {
     // human readable string script
     this._script = new Script(script);
@@ -129,7 +129,7 @@ Input.prototype.setScript = function(script) {
     this._scriptBuffer = this._script.toBuffer();
   } else if (BufferUtil.isBuffer(script)) {
     // buffer script
-    this._scriptBuffer = new buffer.Buffer(script);
+    this._scriptBuffer = Buffer.from(script);
   } else {
     throw new TypeError('Invalid argument type: script');
   }
diff --git a/packages/bitcore-lib/lib/transaction/output.js b/packages/bitcore-lib/lib/transaction/output.js
index a54454abe..4fcdce4b2 100644
--- a/packages/bitcore-lib/lib/transaction/output.js
+++ b/packages/bitcore-lib/lib/transaction/output.js
@@ -23,7 +23,7 @@ function Output(args) {
     } else {
       var script;
       if (_.isString(args.script) && JSUtil.isHexa(args.script)) {
-        script = new buffer.Buffer(args.script, 'hex');
+        script = Buffer.from(args.script, 'hex');
       } else {
         script = args.script;
       }
@@ -149,7 +149,7 @@ Output.fromBufferReader = function(br) {
   if (size !== 0) {
     obj.script = br.read(size);
   } else {
-    obj.script = new buffer.Buffer([]);
+    obj.script = Buffer.from([]);
   }
   return new Output(obj);
 };
diff --git a/packages/bitcore-lib/lib/transaction/sighash.js b/packages/bitcore-lib/lib/transaction/sighash.js
index aad681643..8085594c7 100644
--- a/packages/bitcore-lib/lib/transaction/sighash.js
+++ b/packages/bitcore-lib/lib/transaction/sighash.js
@@ -70,7 +70,7 @@ var sighash = function sighash(transaction, sighashType, inputNumber, subscript)
 
     for (i = 0; i < inputNumber; i++) {
       txcopy.outputs[i] = new Output({
-        satoshis: BN.fromBuffer(new buffer.Buffer(BITS_64_ON, 'hex')),
+        satoshis: BN.fromBuffer(Buffer.from(BITS_64_ON, 'hex')),
         script: Script.empty()
       });
     }
diff --git a/packages/bitcore-lib/lib/util/buffer.js b/packages/bitcore-lib/lib/util/buffer.js
index f7f2ceba5..66775fdea 100644
--- a/packages/bitcore-lib/lib/util/buffer.js
+++ b/packages/bitcore-lib/lib/util/buffer.js
@@ -68,7 +68,7 @@ module.exports = {
    */
   emptyBuffer: function emptyBuffer(bytes) {
     $.checkArgumentType(bytes, 'number', 'bytes');
-    var result = new buffer.Buffer(bytes);
+    var result = Buffer.alloc(bytes);
     for (var i = 0; i < bytes; i++) {
       result.write('\0', i);
     }
@@ -93,7 +93,7 @@ module.exports = {
    */
   integerAsSingleByteBuffer: function integerAsSingleByteBuffer(integer) {
     $.checkArgumentType(integer, 'number', 'integer');
-    return new buffer.Buffer([integer & 0xff]);
+    return Buffer.from([integer & 0xff]);
   },
 
   /**
diff --git a/packages/bitcore-lib/test/address.js b/packages/bitcore-lib/test/address.js
index 52b916bb9..3f34ce229 100644
--- a/packages/bitcore-lib/test/address.js
+++ b/packages/bitcore-lib/test/address.js
@@ -17,8 +17,8 @@ var invalidbase58 = require('./data/bitcoind/base58_keys_invalid.json');
 
 describe('Address', function() {
 
-  var pubkeyhash = new Buffer('3c3fa3d4adcaf8f52d5b1843975e122548269937', 'hex');
-  var buf = Buffer.concat([new Buffer([0]), pubkeyhash]);
+  var pubkeyhash = Buffer.from('3c3fa3d4adcaf8f52d5b1843975e122548269937', 'hex');
+  var buf = Buffer.concat([Buffer.from([0]), pubkeyhash]);
   var str = '16VZnHwRhwrExfeHFHGjwrgEMq8VcYPs9r';
 
   it('can\'t build without data', function() {
@@ -289,25 +289,25 @@ describe('Address', function() {
 
     it('should error because of incorrect length buffer for transform buffer', function() {
       (function() {
-        return Address._transformBuffer(new Buffer(20));
+        return Address._transformBuffer(Buffer.alloc(20));
       }).should.throw('Address buffer is incorrect length.');
     });
 
     it('should error because of incorrect type for pubkey transform', function() {
       (function() {
-        return Address._transformPublicKey(new Buffer(20));
+        return Address._transformPublicKey(Buffer.alloc(20));
       }).should.throw('Address must be an instance of PublicKey.');
     });
 
     it('should error because of incorrect type for script transform', function() {
       (function() {
-        return Address._transformScript(new Buffer(20));
+        return Address._transformScript(Buffer.alloc(20));
       }).should.throw('Invalid Argument: script must be a Script instance');
     });
 
     it('should error because of incorrect type for string transform', function() {
       (function() {
-        return Address._transformString(new Buffer(20));
+        return Address._transformString(Buffer.alloc(20));
       }).should.throw('data parameter supplied is not a string.');
     });
 
diff --git a/packages/bitcore-lib/test/address_witness.js b/packages/bitcore-lib/test/address_witness.js
index 703313e66..e9f4315e2 100644
--- a/packages/bitcore-lib/test/address_witness.js
+++ b/packages/bitcore-lib/test/address_witness.js
@@ -14,7 +14,7 @@ var Networks = bitcore.Networks;
 
 describe('Witness Address', function() {
 
-  var pubkeyhash = new Buffer('2a9540f5cd929bf742d16b4e1bf1b0e874c907c9', 'hex');
+  var pubkeyhash = Buffer.from('2a9540f5cd929bf742d16b4e1bf1b0e874c907c9', 'hex');
   var str = 'bc1q9225pawdj2dlwsk3dd8phudsap6vjp7fg3nwdl';
   var buf = Buffer.from(str, 'utf8');
 
diff --git a/packages/bitcore-lib/test/block/block.js b/packages/bitcore-lib/test/block/block.js
index c39d25b9c..a8a06c4a0 100644
--- a/packages/bitcore-lib/test/block/block.js
+++ b/packages/bitcore-lib/test/block/block.js
@@ -33,8 +33,8 @@ describe('Block', function() {
 
   before(function () {
     blockhex = data.blockhex;
-    blockbuf = new Buffer(blockhex, 'hex');
-    bh = BlockHeader.fromBuffer(new Buffer(data.blockheaderhex, 'hex'));
+    blockbuf = Buffer.from(blockhex, 'hex');
+    bh = BlockHeader.fromBuffer(Buffer.from(data.blockheaderhex, 'hex'));
     txs = [];
     JSON.parse(dataJson).transactions.forEach(function(tx) {
       txs.push(new Transaction().fromObject(tx));
@@ -42,10 +42,10 @@ describe('Block', function() {
     json = dataJson;
 
     genesishex = '0100000000000000000000000000000000000000000000000000000000000000000000003ba3edfd7a7b12b27ac72c3e67768f617fc81bc3888a51323a9fb8aa4b1e5e4a29ab5f49ffff001d1dac2b7c0101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000';
-    genesisbuf = new Buffer(genesishex, 'hex');
+    genesisbuf =  Buffer.from(genesishex, 'hex');
     genesisidhex = '000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f';
     blockOneHex = '010000006fe28c0ab6f1b372c1a6a246ae63f74f931e8365e15a089c68d6190000000000982051fd1e4ba744bbbe680e1fee14677ba1a3c3540bf7b1cdb606e857233e0e61bc6649ffff001d01e362990101000000010000000000000000000000000000000000000000000000000000000000000000ffffffff0704ffff001d0104ffffffff0100f2052a0100000043410496b538e853519c726a2c91e61ec11600ae1390813a627c66fb8be7947be63c52da7589379515d4e0a604f8141781e62294721166bf621e73a82cbf2342c858eeac00000000';
-    blockOneBuf = new Buffer(blockOneHex, 'hex');
+    blockOneBuf = Buffer.from(blockOneHex, 'hex');
     blockOneId = '00000000839a8e6886ab5951d76f411475428afc90947ee320161bbf18eb6048';
   });
 
@@ -73,7 +73,7 @@ describe('Block', function() {
 
     it('should properly deserialize blocks', function() {
       dataBlocks.forEach(function(block) {
-        var b = Block.fromBuffer(new Buffer(block.data, 'hex'));
+        var b = Block.fromBuffer(Buffer.from(block.data, 'hex'));
         b.transactions.length.should.equal(block.transactions);
       });
     });
@@ -227,7 +227,7 @@ describe('Block', function() {
 
     it('should return the correct hash of the genesis block', function() {
       var block = Block.fromBuffer(genesisbuf);
-      var blockhash = new Buffer(Array.apply([], new Buffer(genesisidhex, 'hex')).reverse());
+      var blockhash = Buffer.from(Array.apply([], Buffer.from(genesisidhex, 'hex')).reverse());
       block._getHash().toString('hex').should.equal(blockhash.toString('hex'));
     });
   });
diff --git a/packages/bitcore-lib/test/block/blockheader.js b/packages/bitcore-lib/test/block/blockheader.js
index 90db1368e..a95631035 100644
--- a/packages/bitcore-lib/test/block/blockheader.js
+++ b/packages/bitcore-lib/test/block/blockheader.js
@@ -28,8 +28,8 @@ describe('BlockHeader', function() {
 
   before(function () {
     version = data.version;
-    prevblockidbuf = new Buffer(data.prevblockidhex, 'hex');
-    merklerootbuf = new Buffer(data.merkleroothex, 'hex');
+    prevblockidbuf =  Buffer.from(data.prevblockidhex, 'hex');
+    merklerootbuf = Buffer.from(data.merkleroothex, 'hex');
     time = data.time;
     bits = data.bits;
     nonce = data.nonce;
@@ -42,7 +42,7 @@ describe('BlockHeader', function() {
       nonce: nonce
     });
     bhhex = data.blockheaderhex;
-    bhbuf = new Buffer(bhhex, 'hex');
+    bhbuf = Buffer.from(bhhex, 'hex');
   });
 
   it('should make a new blockheader', function() {
@@ -93,7 +93,7 @@ describe('BlockHeader', function() {
   describe('version', function() {
     it('is interpreted as an int32le', function() {
       var hex = 'ffffffff00000000000000000000000000000000000000000000000000000000000000004141414141414141414141414141414141414141414141414141414141414141010000000200000003000000';
-      var header = BlockHeader.fromBuffer(new Buffer(hex, 'hex'));
+      var header = BlockHeader.fromBuffer(Buffer.from(hex, 'hex'));
       header.version.should.equal(-1);
       header.timestamp.should.equal(1);
     });
diff --git a/packages/bitcore-lib/test/block/merkleblock.js b/packages/bitcore-lib/test/block/merkleblock.js
index 0db73cb62..823fd5325 100644
--- a/packages/bitcore-lib/test/block/merkleblock.js
+++ b/packages/bitcore-lib/test/block/merkleblock.js
@@ -19,7 +19,7 @@ describe('MerkleBlock', function() {
 
   before(function() {
     blockhex  = data.HEX[0];
-    blockbuf  = new Buffer(blockhex,'hex');
+    blockbuf  =  Buffer.from(blockhex,'hex');
     blockJSON = JSON.stringify(data.JSON[0]);
     blockObject = JSON.parse(JSON.stringify(data.JSON[0]));
   });
@@ -193,7 +193,7 @@ describe('MerkleBlock', function() {
 
     it('should find transactions via hash string', function() {
       var jsonData = data.JSON[0];
-      var txId = new Buffer(jsonData.hashes[1],'hex').toString('hex');
+      var txId =  Buffer.from(jsonData.hashes[1],'hex').toString('hex');
       var b = MerkleBlock(jsonData);
       b.hasTransaction(txId).should.equal(true);
       b.hasTransaction(txId + 'abcd').should.equal(false);
@@ -201,7 +201,7 @@ describe('MerkleBlock', function() {
 
     it('should find transactions via Transaction object', function() {
       var jsonData = data.JSON[0];
-      var txBuf = new Buffer(data.TXHEX[0][0],'hex');
+      var txBuf =  Buffer.from(data.TXHEX[0][0],'hex');
       var tx = new Transaction().fromBuffer(txBuf);
       var b = MerkleBlock(jsonData);
       b.hasTransaction(tx).should.equal(true);
@@ -210,7 +210,7 @@ describe('MerkleBlock', function() {
     it('should not find non-existant Transaction object', function() {
       // Reuse another transaction already in data/ dir
       var serialized = transactionVector[0][7];
-      var tx = new Transaction().fromBuffer(new Buffer(serialized, 'hex'));
+      var tx = new Transaction().fromBuffer( Buffer.from(serialized, 'hex'));
       var b = MerkleBlock(data.JSON[0]);
       b.hasTransaction(tx).should.equal(false);
     });
diff --git a/packages/bitcore-lib/test/crypto/bn.js b/packages/bitcore-lib/test/crypto/bn.js
index 085b40c81..22a192133 100644
--- a/packages/bitcore-lib/test/crypto/bn.js
+++ b/packages/bitcore-lib/test/crypto/bn.js
@@ -94,21 +94,21 @@ describe('BN', function() {
   describe('@fromBuffer', function() {
 
     it('should work with big endian', function() {
-      var bn = BN.fromBuffer(new Buffer('0001', 'hex'), {
+      var bn = BN.fromBuffer( Buffer.from('0001', 'hex'), {
         endian: 'big'
       });
       bn.toString().should.equal('1');
     });
 
     it('should work with big endian 256', function() {
-      var bn = BN.fromBuffer(new Buffer('0100', 'hex'), {
+      var bn = BN.fromBuffer( Buffer.from('0100', 'hex'), {
         endian: 'big'
       });
       bn.toString().should.equal('256');
     });
 
     it('should work with little endian if we specify the size', function() {
-      var bn = BN.fromBuffer(new Buffer('0100', 'hex'), {
+      var bn = BN.fromBuffer( Buffer.from('0100', 'hex'), {
         size: 2,
         endian: 'little'
       });
diff --git a/packages/bitcore-lib/test/crypto/ecdsa.js b/packages/bitcore-lib/test/crypto/ecdsa.js
index 1ddae968a..73e92a3ba 100644
--- a/packages/bitcore-lib/test/crypto/ecdsa.js
+++ b/packages/bitcore-lib/test/crypto/ecdsa.js
@@ -18,9 +18,9 @@ describe('ECDSA', function() {
   });
 
   var ecdsa = new ECDSA();
-  ecdsa.hashbuf = Hash.sha256(new Buffer('test data'));
+  ecdsa.hashbuf = Hash.sha256(Buffer.from('test data'));
   ecdsa.privkey = new Privkey(BN.fromBuffer(
-    new Buffer('fee0a1f7afebf9d2a5a80c0c98a31c709681cce195cbcd06342b517970c0be1e', 'hex')
+    Buffer.from('fee0a1f7afebf9d2a5a80c0c98a31c709681cce195cbcd06342b517970c0be1e', 'hex')
   ));
   ecdsa.privkey2pubkey();
 
@@ -41,11 +41,11 @@ describe('ECDSA', function() {
     });
 
     it('calulates this known i', function() {
-      var hashbuf = Hash.sha256(new Buffer('some data'));
+      var hashbuf = Hash.sha256(Buffer.from('some data'));
       var r = new BN('71706645040721865894779025947914615666559616020894583599959600180037551395766', 10);
       var s = new BN('109412465507152403114191008482955798903072313614214706891149785278625167723646', 10);
       var ecdsa = new ECDSA({
-        privkey: new Privkey(BN.fromBuffer(Hash.sha256(new Buffer('test')))),
+        privkey: new Privkey(BN.fromBuffer(Hash.sha256(Buffer.from('test')))),
         hashbuf: hashbuf,
         sig: new Signature({
           r: r,
@@ -109,7 +109,7 @@ describe('ECDSA', function() {
       // test fixture from bitcoinjs
       // https://github.com/bitcoinjs/bitcoinjs-lib/blob/10630873ebaa42381c5871e20336fbfb46564ac8/test/fixtures/ecdsa.json#L6
       var ecdsa = new ECDSA();
-      ecdsa.hashbuf = Hash.sha256(new Buffer('Everything should be made as simple as possible, but not simpler.'));
+      ecdsa.hashbuf = Hash.sha256(Buffer.from('Everything should be made as simple as possible, but not simpler.'));
       ecdsa.privkey = new Privkey(new BN(1));
       ecdsa.privkey2pubkey();
       ecdsa.deterministicK();
@@ -162,8 +162,8 @@ describe('ECDSA', function() {
 
     it('should return an error if r, s are invalid', function() {
       var ecdsa = new ECDSA();
-      ecdsa.hashbuf = Hash.sha256(new Buffer('test'));
-      var pk = Pubkey.fromDER(new Buffer('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49' +
+      ecdsa.hashbuf = Hash.sha256(Buffer.from('test'));
+      var pk = Pubkey.fromDER(Buffer.from('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49' +
         '710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
       ecdsa.pubkey = pk;
       ecdsa.sig = new Signature();
@@ -212,9 +212,9 @@ describe('ECDSA', function() {
     });
 
     it('should generate right K', function() {
-      var msg1 = new Buffer('52204d20fd0131ae1afd173fd80a3a746d2dcc0cddced8c9dc3d61cc7ab6e966', 'hex');
-      var msg2 = [].reverse.call(new Buffer(msg1))
-      var pk = new Buffer('16f243e962c59e71e54189e67e66cf2440a1334514c09c00ddcc21632bac9808', 'hex');
+      var msg1 = Buffer.from('52204d20fd0131ae1afd173fd80a3a746d2dcc0cddced8c9dc3d61cc7ab6e966', 'hex');
+      var msg2 = [].reverse.call(Buffer.from(msg1))
+      var pk = Buffer.from('16f243e962c59e71e54189e67e66cf2440a1334514c09c00ddcc21632bac9808', 'hex');
       var signature1 = ECDSA.sign(msg1, Privkey.fromBuffer(pk)).toBuffer().toString('hex');
       var signature2 = ECDSA.sign(msg2, Privkey.fromBuffer(pk), 'little').toBuffer().toString('hex');
       signature1.should.equal(signature2);
@@ -275,9 +275,9 @@ describe('ECDSA', function() {
       vectors.valid.forEach(function(obj, i) {
         it('should validate valid vector ' + i, function() {
           var ecdsa = ECDSA().set({
-            privkey: new Privkey(BN.fromBuffer(new Buffer(obj.d, 'hex'))),
-            k: BN.fromBuffer(new Buffer(obj.k, 'hex')),
-            hashbuf: Hash.sha256(new Buffer(obj.message)),
+            privkey: new Privkey(BN.fromBuffer(Buffer.from(obj.d, 'hex'))),
+            k: BN.fromBuffer(Buffer.from(obj.k, 'hex')),
+            hashbuf: Hash.sha256(Buffer.from(obj.message)),
             sig: new Signature().set({
               r: new BN(obj.signature.r),
               s: new BN(obj.signature.s),
@@ -300,7 +300,7 @@ describe('ECDSA', function() {
           var ecdsa = ECDSA().set({
             pubkey: Pubkey.fromPoint(point.fromX(true, 1)),
             sig: new Signature(new BN(obj.signature.r), new BN(obj.signature.s)),
-            hashbuf: Hash.sha256(new Buffer(obj.message))
+            hashbuf: Hash.sha256(Buffer.from(obj.message))
           });
           ecdsa.sigError().should.equal(obj.exception);
         });
@@ -308,8 +308,8 @@ describe('ECDSA', function() {
 
       vectors.deterministicK.forEach(function(obj, i) {
         it('should validate deterministicK vector ' + i, function() {
-          var hashbuf = Hash.sha256(new Buffer(obj.message));
-          var privkey = Privkey(BN.fromBuffer(new Buffer(obj.privkey, 'hex')), 'mainnet');
+          var hashbuf = Hash.sha256(Buffer.from(obj.message));
+          var privkey = Privkey(BN.fromBuffer(Buffer.from(obj.privkey, 'hex')), 'mainnet');
           var ecdsa = ECDSA({
             privkey: privkey,
             hashbuf: hashbuf
diff --git a/packages/bitcore-lib/test/crypto/hash.js b/packages/bitcore-lib/test/crypto/hash.js
index c079feee2..7dc89f2f4 100644
--- a/packages/bitcore-lib/test/crypto/hash.js
+++ b/packages/bitcore-lib/test/crypto/hash.js
@@ -5,7 +5,7 @@ var bitcore = require('../..');
 var Hash = bitcore.crypto.Hash;
 
 describe('Hash', function() {
-  var buf = new Buffer([0, 1, 2, 3, 253, 254, 255]);
+  var buf = Buffer.from([0, 1, 2, 3, 253, 254, 255]);
   var str = 'test string';
 
   describe('@sha1', function() {
@@ -13,7 +13,7 @@ describe('Hash', function() {
     it('calculates the hash of this buffer correctly', function() {
       var hash = Hash.sha1(buf);
       hash.toString('hex').should.equal('de69b8a4a5604d0486e6420db81e39eb464a17b2');
-      hash = Hash.sha1(new Buffer(0));
+      hash = Hash.sha1(Buffer.alloc(0));
       hash.toString('hex').should.equal('da39a3ee5e6b4b0d3255bfef95601890afd80709');
     });
 
@@ -39,25 +39,25 @@ describe('Hash', function() {
   describe('#sha256hmac', function() {
 
     it('computes this known big key correctly', function() {
-      var key = new Buffer('b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad' +
+      var key = Buffer.from('b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad' +
         'b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad' +
         'b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad' +
         'b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad');
-      var data = new Buffer('');
+      var data = Buffer.alloc(0);
       Hash.sha256hmac(data, key).toString('hex')
         .should.equal('fb1f87218671f1c0c4593a88498e02b6dfe8afd814c1729e89a1f1f6600faa23');
     });
 
     it('computes this known empty test vector correctly', function() {
-      var key = new Buffer('');
-      var data = new Buffer('');
+      var key =  Buffer.alloc(0);
+      var data =  Buffer.alloc(0);
       Hash.sha256hmac(data, key).toString('hex')
         .should.equal('b613679a0814d9ec772f95d778c35fc5ff1697c493715653c6c712144292c5ad');
     });
 
     it('computes this known non-empty test vector correctly', function() {
-      var key = new Buffer('key');
-      var data = new Buffer('The quick brown fox jumps over the lazy dog');
+      var key = Buffer.from('key');
+      var data =  Buffer.from('The quick brown fox jumps over the lazy dog');
       Hash.sha256hmac(data, key).toString('hex')
         .should.equal('f7bc83f430538424b13298e6aa6fb143ef4d59a14946175997479dbc2d1a3cd8');
     });
@@ -123,14 +123,14 @@ describe('Hash', function() {
     it('calculates this known empty test vector correctly', function() {
       var hex = 'b936cee86c9f87aa5d3c6f2e84cb5a4239a5fe50480a6ec66b70ab5b1f4a' +
         'c6730c6c515421b327ec1d69402e53dfb49ad7381eb067b338fd7b0cb22247225d47';
-      Hash.sha512hmac(new Buffer([]), new Buffer([])).toString('hex').should.equal(hex);
+      Hash.sha512hmac(Buffer.alloc(0), Buffer.alloc(0)).toString('hex').should.equal(hex);
     });
 
     it('calculates this known non-empty test vector correctly', function() {
       var hex = 'c40bd7c15aa493b309c940e08a73ffbd28b2e4cb729eb94480d727e4df577' +
         'b13cc403a78e6150d83595f3b17c4cc331f12ca5952691de3735a63c1d4c69a2bac';
-      var data = new Buffer('test1');
-      var key = new Buffer('test2');
+      var data = Buffer.from('test1');
+      var key = Buffer.from('test2');
       Hash.sha512hmac(data, key).toString('hex').should.equal(hex);
     });
 
diff --git a/packages/bitcore-lib/test/crypto/point.js b/packages/bitcore-lib/test/crypto/point.js
index 95f5b5370..7ac299554 100644
--- a/packages/bitcore-lib/test/crypto/point.js
+++ b/packages/bitcore-lib/test/crypto/point.js
@@ -39,7 +39,7 @@ describe('Point', function() {
       var p = Point(valid.x,valid.y);
       var a = p.getX().toBuffer({size: 32});
       a.length.should.equal(32);
-      a.should.deep.equal(new Buffer(valid.x, 'hex'));
+      a.should.deep.equal( Buffer.from(valid.x, 'hex'));
     });
 
   });
@@ -55,7 +55,7 @@ describe('Point', function() {
       var p = Point(valid.x,valid.y);
       var a = p.getY().toBuffer({size: 32});
       a.length.should.equal(32);
-      a.should.deep.equal(new Buffer(valid.y, 'hex'));
+      a.should.deep.equal( Buffer.from(valid.y, 'hex'));
     });
 
   });
diff --git a/packages/bitcore-lib/test/crypto/signature.js b/packages/bitcore-lib/test/crypto/signature.js
index 5ea73c033..0f65f3c3d 100644
--- a/packages/bitcore-lib/test/crypto/signature.js
+++ b/packages/bitcore-lib/test/crypto/signature.js
@@ -51,10 +51,10 @@ describe('Signature', function() {
   describe('#fromCompact', function() {
 
     it('should create a signature from a compressed signature', function() {
-      var blank = new Buffer(32);
+      var blank = Buffer.alloc(32);
       blank.fill(0);
       var compressed = Buffer.concat([
-        new Buffer([0 + 27 + 4]),
+        Buffer.from([0 + 27 + 4]),
         blank,
         blank
       ]);
@@ -67,7 +67,7 @@ describe('Signature', function() {
     it('should create a signature from an uncompressed signature', function() {
       var sigHexaStr = '1cd5e61ab5bfd0d1450997894cb1a53e917f89d82eb43f06fa96f32c96e061aec12fc1188e8b' +
         '0dc553a2588be2b5b68dbbd7f092894aa3397786e9c769c5348dc6';
-      var sig = Signature.fromCompact(new Buffer(sigHexaStr, 'hex'));
+      var sig = Signature.fromCompact(Buffer.from(sigHexaStr, 'hex'));
       var r = 'd5e61ab5bfd0d1450997894cb1a53e917f89d82eb43f06fa96f32c96e061aec1';
       var s = '2fc1188e8b0dc553a2588be2b5b68dbbd7f092894aa3397786e9c769c5348dc6';
       sig.r.toString('hex').should.equal(r);
@@ -79,7 +79,7 @@ describe('Signature', function() {
 
   describe('#fromDER', function() {
 
-    var buf = new Buffer('3044022075fc517e541bd54769c080b64397e32161c850f6c1b2b67a5c433affbb3e62770220729e85cc46ffab881065ec07694220e71d4df9b2b8c8fd12c3122cf3a5efbcf2', 'hex');
+    var buf = Buffer.from('3044022075fc517e541bd54769c080b64397e32161c850f6c1b2b67a5c433affbb3e62770220729e85cc46ffab881065ec07694220e71d4df9b2b8c8fd12c3122cf3a5efbcf2', 'hex');
 
     it('should parse this DER format signature', function() {
       var sig = Signature.fromDER(buf);
@@ -95,7 +95,7 @@ describe('Signature', function() {
 
   describe('#fromString', function() {
 
-    var buf = new Buffer('3044022075fc517e541bd54769c080b64397e32161c850f6c1b2b67a5c433affbb3e62770220729e85cc46ffab881065ec07694220e71d4df9b2b8c8fd12c3122cf3a5efbcf2', 'hex');
+    var buf =  Buffer.from('3044022075fc517e541bd54769c080b64397e32161c850f6c1b2b67a5c433affbb3e62770220729e85cc46ffab881065ec07694220e71d4df9b2b8c8fd12c3122cf3a5efbcf2', 'hex');
 
     it('should parse this DER format signature in hex', function() {
       var sig = Signature.fromString(buf.toString('hex'));
@@ -113,7 +113,7 @@ describe('Signature', function() {
 
     it('should parse this known signature and rebuild it with updated zero-padded sighash types', function() {
       var original = '30450221008bab1f0a2ff2f9cb8992173d8ad73c229d31ea8e10b0f4d4ae1a0d8ed76021fa02200993a6ec81755b9111762fc2cf8e3ede73047515622792110867d12654275e7201';
-      var buf = new Buffer(original, 'hex');
+      var buf =  Buffer.from(original, 'hex');
       var sig = Signature.fromTxFormat(buf);
       sig.nhashtype.should.equal(Signature.SIGHASH_ALL);
       sig.set({
@@ -131,7 +131,7 @@ describe('Signature', function() {
   describe('#fromTxFormat', function() {
 
     it('should convert from this known tx-format buffer', function() {
-      var buf = new Buffer('30450221008bab1f0a2ff2f9cb8992173d8ad73c229d31ea8e10b0f4d4ae1a0d8ed76021fa02200993a6ec81755b9111762fc2cf8e3ede73047515622792110867d12654275e7201', 'hex');
+      var buf =  Buffer.from('30450221008bab1f0a2ff2f9cb8992173d8ad73c229d31ea8e10b0f4d4ae1a0d8ed76021fa02200993a6ec81755b9111762fc2cf8e3ede73047515622792110867d12654275e7201', 'hex');
       var sig = Signature.fromTxFormat(buf);
       sig.r.toString().should.equal('63173831029936981022572627018246571655303050627048489594159321588908385378810');
       sig.s.toString().should.equal('4331694221846364448463828256391194279133231453999942381442030409253074198130');
@@ -140,7 +140,7 @@ describe('Signature', function() {
 
     it('should parse this known signature and rebuild it', function() {
       var hex = '3044022007415aa37ce7eaa6146001ac8bdefca0ddcba0e37c5dc08c4ac99392124ebac802207d382307fd53f65778b07b9c63b6e196edeadf0be719130c5db21ff1e700d67501';
-      var buf = new Buffer(hex, 'hex');
+      var buf = Buffer.from(hex, 'hex');
       var sig = Signature.fromTxFormat(buf);
       sig.toTxFormat().toString('hex').should.equal(hex);
     });
@@ -151,7 +151,7 @@ describe('Signature', function() {
 
     it('should parse this signature generated in node', function() {
       var sighex = '30450221008bab1f0a2ff2f9cb8992173d8ad73c229d31ea8e10b0f4d4ae1a0d8ed76021fa02200993a6ec81755b9111762fc2cf8e3ede73047515622792110867d12654275e72';
-      var sig = new Buffer(sighex, 'hex');
+      var sig = Buffer.from(sighex, 'hex');
       var parsed = Signature.parseDER(sig);
       parsed.header.should.equal(0x30);
       parsed.length.should.equal(69);
@@ -167,7 +167,7 @@ describe('Signature', function() {
 
     it('should parse this 69 byte signature', function() {
       var sighex = '3043021f59e4705959cc78acbfcf8bd0114e9cc1b389a4287fb33152b73a38c319b50302202f7428a27284c757e409bf41506183e9e49dfb54d5063796dfa0d403a4deccfa';
-      var sig = new Buffer(sighex, 'hex');
+      var sig = Buffer.from(sighex, 'hex');
       var parsed = Signature.parseDER(sig);
       parsed.header.should.equal(0x30);
       parsed.length.should.equal(67);
@@ -183,7 +183,7 @@ describe('Signature', function() {
 
     it('should parse this 68 byte signature', function() {
       var sighex = '3042021e17cfe77536c3fb0526bd1a72d7a8e0973f463add210be14063c8a9c37632022061bfa677f825ded82ba0863fb0c46ca1388dd3e647f6a93c038168b59d131a51';
-      var sig = new Buffer(sighex, 'hex');
+      var sig = Buffer.from(sighex, 'hex');
       var parsed = Signature.parseDER(sig);
       parsed.header.should.equal(0x30);
       parsed.length.should.equal(66);
@@ -199,7 +199,7 @@ describe('Signature', function() {
 
     it('should parse this signature from script_valid.json', function() {
       var sighex = '304502203e4516da7253cf068effec6b95c41221c0cf3a8e6ccb8cbf1725b562e9afde2c022100ab1e3da73d67e32045a20e0b999e049978ea8d6ee5480d485fcf2ce0d03b2ef051';
-      var sig = Buffer(sighex, 'hex');
+      var sig = Buffer.from(sighex, 'hex');
       var parsed = Signature.parseDER(sig, false);
       should.exist(parsed);
     });
@@ -238,14 +238,14 @@ describe('Signature', function() {
   describe('@isTxDER', function() {
     it('should know this is a DER signature', function() {
       var sighex = '3042021e17cfe77536c3fb0526bd1a72d7a8e0973f463add210be14063c8a9c37632022061bfa677f825ded82ba0863fb0c46ca1388dd3e647f6a93c038168b59d131a5101';
-      var sigbuf = new Buffer(sighex, 'hex');
+      var sigbuf =  Buffer.from(sighex, 'hex');
       Signature.isTxDER(sigbuf).should.equal(true);
     });
 
     it('should know this is not a DER signature', function() {
       //for more extensive tests, see the script interpreter
       var sighex = '3042021e17cfe77536c3fb0526bd1a72d7a8e0973f463add210be14063c8a9c37632022061bfa677f825ded82ba0863fb0c46ca1388dd3e647f6a93c038168b59d131a5101';
-      var sigbuf = new Buffer(sighex, 'hex');
+      var sigbuf = Buffer.from(sighex, 'hex');
       sigbuf[0] = 0x31;
       Signature.isTxDER(sigbuf).should.equal(false);
     });
@@ -264,7 +264,7 @@ describe('Signature', function() {
             var interp = Interpreter();
             interp.flags = Interpreter.SCRIPT_VERIFY_DERSIG |
               Interpreter.SCRIPT_VERIFY_STRICTENC;
-            var result = interp.checkSignatureEncoding(new Buffer(sighex, 'hex'));
+            var result = interp.checkSignatureEncoding(Buffer.from(sighex, 'hex'));
             result.should.equal(expected);
           });
           i++;
diff --git a/packages/bitcore-lib/test/encoding/base58.js b/packages/bitcore-lib/test/encoding/base58.js
index fc0a7e858..447692ae5 100644
--- a/packages/bitcore-lib/test/encoding/base58.js
+++ b/packages/bitcore-lib/test/encoding/base58.js
@@ -6,7 +6,7 @@ var buffer = require('buffer');
 var Base58 = bitcore.encoding.Base58;
 
 describe('Base58', function() {
-  var buf = new buffer.Buffer([0, 1, 2, 3, 253, 254, 255]);
+  var buf = Buffer.from([0, 1, 2, 3, 253, 254, 255]);
   var enc = '1W7N4RuG';
 
   it('should make an instance with "new"', function() {
@@ -21,7 +21,7 @@ describe('Base58', function() {
   });
   it('validates characters from buffer', function() {
     Base58.validCharacters(
-      new buffer.Buffer('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')
+      Buffer.from('123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz')
     ).should.equal(true);
   });
 
@@ -43,7 +43,7 @@ describe('Base58', function() {
 
     it('should set a blank buffer', function() {
       Base58().set({
-        buf: new buffer.Buffer([])
+        buf: Buffer.from([])
       });
     });
 
diff --git a/packages/bitcore-lib/test/encoding/base58check.js b/packages/bitcore-lib/test/encoding/base58check.js
index c2cc622bd..38647ebad 100644
--- a/packages/bitcore-lib/test/encoding/base58check.js
+++ b/packages/bitcore-lib/test/encoding/base58check.js
@@ -6,7 +6,7 @@ var Base58Check = bitcore.encoding.Base58Check;
 var Base58 = bitcore.encoding.Base58;
 
 describe('Base58Check', function() {
-  var buf = new Buffer([0, 1, 2, 3, 253, 254, 255]);
+  var buf = Buffer.from([0, 1, 2, 3, 253, 254, 255]);
   var enc = '14HV44ipwoaqfg';
 
   it('should make an instance with "new"', function() {
diff --git a/packages/bitcore-lib/test/encoding/bufferreader.js b/packages/bitcore-lib/test/encoding/bufferreader.js
index 78e4c764c..e8d313fb6 100644
--- a/packages/bitcore-lib/test/encoding/bufferreader.js
+++ b/packages/bitcore-lib/test/encoding/bufferreader.js
@@ -16,7 +16,7 @@ describe('BufferReader', function() {
   });
 
   it('should create a new bufferreader with a buffer', function() {
-    var buf = new Buffer(0);
+    var buf =  Buffer.alloc(0);
     var br = new BufferReader(buf);
     should.exist(br);
     Buffer.isBuffer(br.buf).should.equal(true);
@@ -41,7 +41,7 @@ describe('BufferReader', function() {
   describe('#eof', function() {
 
     it('should return true for a blank br', function() {
-      var br = new BufferReader(new Buffer([]));
+      var br = new BufferReader( Buffer.alloc(0));
       br.finished().should.equal(true);
     });
 
@@ -50,13 +50,13 @@ describe('BufferReader', function() {
   describe('read', function() {
 
     it('should return the same buffer', function() {
-      var buf = new Buffer([0]);
+      var buf =  Buffer.alloc(0);
       var br = new BufferReader(buf);
       br.readAll().toString('hex').should.equal(buf.toString('hex'));
     });
 
     it('should return a buffer of this length', function() {
-      var buf = new Buffer(10);
+      var buf =  Buffer.alloc(10);
       buf.fill(0);
       var br = new BufferReader(buf);
       var buf2 = br.read(2);
@@ -66,7 +66,7 @@ describe('BufferReader', function() {
     });
 
     it('should work with 0 length', function() {
-      var buf = new Buffer(10);
+      var buf =  Buffer.alloc(10);
       buf.fill(1);
       var br = new BufferReader(buf);
       var buf2 = br.read(0);
@@ -80,7 +80,7 @@ describe('BufferReader', function() {
   describe('readVarLengthBuffer', function() {
 
     it('returns correct buffer', function() {
-      var buf = new Buffer('73010000003766404f00000000b305434f00000000f203' +
+      var buf =  Buffer.from('73010000003766404f00000000b305434f00000000f203' +
         '0000f1030000001027000048ee00000064000000004653656520626974636f696' +
         'e2e6f72672f666562323020696620796f7520686176652074726f75626c652063' +
         '6f6e6e656374696e6720616674657220323020466562727561727900473045022' +
@@ -99,7 +99,7 @@ describe('BufferReader', function() {
         '6b684bde2b3f573060d5b70c3a46723326e4e8a4f1');
     });
     it('fails on length too big', function() {
-      var buf = new Buffer('0a00', 'hex');
+      var buf = Buffer.from('0a00', 'hex');
       var br = new BufferReader(buf);
       br.readVarLengthBuffer.bind(br).should.throw('Invalid length while reading varlength buffer');
     });
@@ -109,7 +109,7 @@ describe('BufferReader', function() {
   describe('#readUInt8', function() {
 
     it('should return 1', function() {
-      var buf = new Buffer(1);
+      var buf = Buffer.alloc(1);
       buf.writeUInt8(1, 0);
       var br = new BufferReader(buf);
       br.readUInt8().should.equal(1);
@@ -120,7 +120,7 @@ describe('BufferReader', function() {
   describe('#readUInt16BE', function() {
 
     it('should return 1', function() {
-      var buf = new Buffer(2);
+      var buf =  Buffer.alloc(2);
       buf.writeUInt16BE(1, 0);
       var br = new BufferReader(buf);
       br.readUInt16BE().should.equal(1);
@@ -131,7 +131,7 @@ describe('BufferReader', function() {
   describe('#readUInt16LE', function() {
 
     it('should return 1', function() {
-      var buf = new Buffer(2);
+      var buf = Buffer.alloc(2);
       buf.writeUInt16LE(1, 0);
       var br = new BufferReader(buf);
       br.readUInt16LE().should.equal(1);
@@ -142,7 +142,7 @@ describe('BufferReader', function() {
   describe('#readUInt32BE', function() {
 
     it('should return 1', function() {
-      var buf = new Buffer(4);
+      var buf = Buffer.alloc(4);
       buf.writeUInt32BE(1, 0);
       var br = new BufferReader(buf);
       br.readUInt32BE().should.equal(1);
@@ -153,7 +153,7 @@ describe('BufferReader', function() {
   describe('#readUInt32LE', function() {
 
     it('should return 1', function() {
-      var buf = new Buffer(4);
+      var buf = Buffer.alloc(4);
       buf.writeUInt32LE(1, 0);
       var br = new BufferReader(buf);
       br.readUInt32LE().should.equal(1);
@@ -164,7 +164,7 @@ describe('BufferReader', function() {
   describe('#readUInt64BEBN', function() {
 
     it('should return 1', function() {
-      var buf = new Buffer(8);
+      var buf = Buffer.alloc(8);
       buf.fill(0);
       buf.writeUInt32BE(1, 4);
       var br = new BufferReader(buf);
@@ -172,7 +172,7 @@ describe('BufferReader', function() {
     });
 
     it('should return 2^64', function() {
-      var buf = new Buffer(8);
+      var buf = Buffer.alloc(8);
       buf.fill(0xff);
       var br = new BufferReader(buf);
       br.readUInt64BEBN().toNumber().should.equal(Math.pow(2, 64));
@@ -183,7 +183,7 @@ describe('BufferReader', function() {
   describe('#readUInt64LEBN', function() {
 
     it('should return 1', function() {
-      var buf = new Buffer(8);
+      var buf = Buffer.alloc(8);
       buf.fill(0);
       buf.writeUInt32LE(1, 0);
       var br = new BufferReader(buf);
@@ -192,13 +192,13 @@ describe('BufferReader', function() {
 
     it('should return 10BTC', function() {
       var tenbtc = 10 * 1e8;
-      var tenbtcBuffer = new Buffer('00ca9a3b00000000', 'hex');
+      var tenbtcBuffer = Buffer.from('00ca9a3b00000000', 'hex');
       var br = new BufferReader(tenbtcBuffer);
       br.readUInt64LEBN().toNumber().should.equal(tenbtc);
     });
 
     it('should return 2^30', function() {
-      var buf = new Buffer(8);
+      var buf = Buffer.alloc(8);
       buf.fill(0);
       buf.writeUInt32LE(Math.pow(2, 30), 0);
       var br = new BufferReader(buf);
@@ -207,42 +207,42 @@ describe('BufferReader', function() {
 
     it('should return 2^32 + 1', function() {
       var num = Math.pow(2, 32) + 1;
-      var numBuffer = new Buffer('0100000001000000', 'hex');
+      var numBuffer =  Buffer.from('0100000001000000', 'hex');
       var br = new BufferReader(numBuffer);
       br.readUInt64LEBN().toNumber().should.equal(num);
     });
 
     it('should return max number of satoshis', function() {
       var maxSatoshis = 21000000 * 1e8;
-      var maxSatoshisBuffer = new Buffer('0040075af0750700', 'hex');
+      var maxSatoshisBuffer = Buffer.from('0040075af0750700', 'hex');
       var br = new BufferReader(maxSatoshisBuffer);
       br.readUInt64LEBN().toNumber().should.equal(maxSatoshis);
     });
 
     it('should return 2^53 - 1', function() {
       var maxSafe = Math.pow(2, 53) - 1;
-      var maxSafeBuffer = new Buffer('ffffffffffff1f00', 'hex');
+      var maxSafeBuffer = Buffer.from('ffffffffffff1f00', 'hex');
       var br = new BufferReader(maxSafeBuffer);
       br.readUInt64LEBN().toNumber().should.equal(maxSafe);
     });
 
     it('should return 2^53', function() {
       var bn = new BN('20000000000000', 16);
-      var bnBuffer = new Buffer('0000000000002000', 'hex');
+      var bnBuffer =  Buffer.from('0000000000002000', 'hex');
       var br = new BufferReader(bnBuffer);
       var readbn = br.readUInt64LEBN();
       readbn.cmp(bn).should.equal(0);
     });
 
     it('should return 0', function() {
-      var buf = new Buffer(8);
+      var buf = Buffer.alloc(8);
       buf.fill(0);
       var br = new BufferReader(buf);
       br.readUInt64LEBN().toNumber().should.equal(0);
     });
 
     it('should return 2^64', function() {
-      var buf = new Buffer(8);
+      var buf = Buffer.alloc(8);
       buf.fill(0xff);
       var br = new BufferReader(buf);
       br.readUInt64LEBN().toNumber().should.equal(Math.pow(2, 64));
@@ -253,19 +253,19 @@ describe('BufferReader', function() {
   describe('#readVarintBuf', function() {
 
     it('should read a 1 byte varint', function() {
-      var buf = new Buffer([50]);
+      var buf = Buffer.from([50]);
       var br = new BufferReader(buf);
       br.readVarintBuf().length.should.equal(1);
     });
 
     it('should read a 3 byte varint', function() {
-      var buf = new Buffer([253, 253, 0]);
+      var buf = Buffer.from([253, 253, 0]);
       var br = new BufferReader(buf);
       br.readVarintBuf().length.should.equal(3);
     });
 
     it('should read a 5 byte varint', function() {
-      var buf = new Buffer([254, 0, 0, 0, 0]);
+      var buf = Buffer.from([254, 0, 0, 0, 0]);
       buf.writeUInt32LE(50000, 1);
       var br = new BufferReader(buf);
       br.readVarintBuf().length.should.equal(5);
@@ -282,19 +282,19 @@ describe('BufferReader', function() {
   describe('#readVarintNum', function() {
 
     it('should read a 1 byte varint', function() {
-      var buf = new Buffer([50]);
+      var buf = Buffer.from([50]);
       var br = new BufferReader(buf);
       br.readVarintNum().should.equal(50);
     });
 
     it('should read a 3 byte varint', function() {
-      var buf = new Buffer([253, 253, 0]);
+      var buf = Buffer.from([253, 253, 0]);
       var br = new BufferReader(buf);
       br.readVarintNum().should.equal(253);
     });
 
     it('should read a 5 byte varint', function() {
-      var buf = new Buffer([254, 0, 0, 0, 0]);
+      var buf = Buffer.from([254, 0, 0, 0, 0]);
       buf.writeUInt32LE(50000, 1);
       var br = new BufferReader(buf);
       br.readVarintNum().should.equal(50000);
@@ -321,26 +321,26 @@ describe('BufferReader', function() {
   describe('#readVarintBN', function() {
 
     it('should read a 1 byte varint', function() {
-      var buf = new Buffer([50]);
+      var buf = Buffer.from([50]);
       var br = new BufferReader(buf);
       br.readVarintBN().toNumber().should.equal(50);
     });
 
     it('should read a 3 byte varint', function() {
-      var buf = new Buffer([253, 253, 0]);
+      var buf = Buffer.from([253, 253, 0]);
       var br = new BufferReader(buf);
       br.readVarintBN().toNumber().should.equal(253);
     });
 
     it('should read a 5 byte varint', function() {
-      var buf = new Buffer([254, 0, 0, 0, 0]);
+      var buf = Buffer.from([254, 0, 0, 0, 0]);
       buf.writeUInt32LE(50000, 1);
       var br = new BufferReader(buf);
       br.readVarintBN().toNumber().should.equal(50000);
     });
 
     it('should read a 9 byte varint', function() {
-      var buf = Buffer.concat([new Buffer([255]), new Buffer('ffffffffffffffff', 'hex')]);
+      var buf = Buffer.concat([Buffer.from([255]), Buffer.from('ffffffffffffffff', 'hex')]);
       var br = new BufferReader(buf);
       br.readVarintBN().toNumber().should.equal(Math.pow(2, 64));
     });
@@ -350,7 +350,7 @@ describe('BufferReader', function() {
   describe('#reverse', function() {
 
     it('should reverse this [0, 1]', function() {
-      var buf = new Buffer([0, 1]);
+      var buf = Buffer.from([0, 1]);
       var br = new BufferReader(buf);
       br.reverse().readAll().toString('hex').should.equal('0100');
     });
diff --git a/packages/bitcore-lib/test/encoding/bufferwriter.js b/packages/bitcore-lib/test/encoding/bufferwriter.js
index 85ed3c158..ca4aacc67 100644
--- a/packages/bitcore-lib/test/encoding/bufferwriter.js
+++ b/packages/bitcore-lib/test/encoding/bufferwriter.js
@@ -16,8 +16,8 @@ describe('BufferWriter', function() {
   describe('#set', function() {
     
     it('set bufs', function() {
-      var buf1 = new Buffer([0]);
-      var buf2 = new Buffer([1]);
+      var buf1 = Buffer.from([0]);
+      var buf2 = Buffer.from([1]);
       var bw = new BufferWriter().set({bufs: [buf1, buf2]});
       bw.concat().toString('hex').should.equal('0001');
     });
@@ -27,8 +27,8 @@ describe('BufferWriter', function() {
   describe('#toBuffer', function() {
     
     it('should concat these two bufs', function() {
-      var buf1 = new Buffer([0]);
-      var buf2 = new Buffer([1]);
+      var buf1 = Buffer.from([0]);
+      var buf2 =  Buffer.from([1]);
       var bw = new BufferWriter({bufs: [buf1, buf2]});
       bw.toBuffer().toString('hex').should.equal('0001');
     });
@@ -38,8 +38,8 @@ describe('BufferWriter', function() {
   describe('#concat', function() {
     
     it('should concat these two bufs', function() {
-      var buf1 = new Buffer([0]);
-      var buf2 = new Buffer([1]);
+      var buf1 =  Buffer.from([0]);
+      var buf2 =  Buffer.from([1]);
       var bw = new BufferWriter({bufs: [buf1, buf2]});
       bw.concat().toString('hex').should.equal('0001');
     });
@@ -49,7 +49,7 @@ describe('BufferWriter', function() {
   describe('#write', function() {
 
     it('should write a buffer', function() {
-      var buf = new Buffer([0]);
+      var buf =  Buffer.from([0]);
       var bw = new BufferWriter();
       bw.write(buf);
       bw.concat().toString('hex').should.equal('00');
diff --git a/packages/bitcore-lib/test/encoding/varint.js b/packages/bitcore-lib/test/encoding/varint.js
index 47e722c08..30b783e10 100644
--- a/packages/bitcore-lib/test/encoding/varint.js
+++ b/packages/bitcore-lib/test/encoding/varint.js
@@ -10,7 +10,7 @@ var Varint = bitcore.encoding.Varint;
 describe('Varint', function() {
 
   it('should make a new varint', function() {
-    var buf = new Buffer('00', 'hex');
+    var buf = Buffer.from('00', 'hex');
     var varint = new Varint(buf);
     should.exist(varint);
     varint.buf.toString('hex').should.equal('00');
@@ -27,7 +27,7 @@ describe('Varint', function() {
   describe('#set', function() {
     
     it('should set a buffer', function() {
-      var buf = new Buffer('00', 'hex');
+      var buf =  Buffer.from('00', 'hex');
       var varint = Varint().set({buf: buf});
       varint.buf.toString('hex').should.equal('00');
       varint.set({});
diff --git a/packages/bitcore-lib/test/hdkeys.js b/packages/bitcore-lib/test/hdkeys.js
index 8a0f53cca..0cc0d9edc 100644
--- a/packages/bitcore-lib/test/hdkeys.js
+++ b/packages/bitcore-lib/test/hdkeys.js
@@ -224,8 +224,8 @@ describe('BIP32 compliance', function() {
 
   it('should use full 32 bytes for private key data that is hashed (as per bip32)', function() {
     // https://github.com/bitcoin/bips/blob/master/bip-0032.mediawiki
-    var privateKeyBuffer = new Buffer('00000055378cf5fafb56c711c674143f9b0ee82ab0ba2924f19b64f5ae7cdbfd', 'hex');
-    var chainCodeBuffer = new Buffer('9c8a5c863e5941f3d99453e6ba66b328bb17cf0b8dec89ed4fc5ace397a1c089', 'hex');
+    var privateKeyBuffer = Buffer.from('00000055378cf5fafb56c711c674143f9b0ee82ab0ba2924f19b64f5ae7cdbfd', 'hex');
+    var chainCodeBuffer = Buffer.from('9c8a5c863e5941f3d99453e6ba66b328bb17cf0b8dec89ed4fc5ace397a1c089', 'hex');
     var key = HDPrivateKey.fromObject({
       network: 'testnet',
       depth: 0,
@@ -240,8 +240,8 @@ describe('BIP32 compliance', function() {
 
   it('should NOT use full 32 bytes for private key data that is hashed with nonCompliant flag', function() {
     // This is to test that the previously implemented non-compliant to BIP32
-    var privateKeyBuffer = new Buffer('00000055378cf5fafb56c711c674143f9b0ee82ab0ba2924f19b64f5ae7cdbfd', 'hex');
-    var chainCodeBuffer = new Buffer('9c8a5c863e5941f3d99453e6ba66b328bb17cf0b8dec89ed4fc5ace397a1c089', 'hex');
+    var privateKeyBuffer = Buffer.from('00000055378cf5fafb56c711c674143f9b0ee82ab0ba2924f19b64f5ae7cdbfd', 'hex');
+    var chainCodeBuffer = Buffer.from('9c8a5c863e5941f3d99453e6ba66b328bb17cf0b8dec89ed4fc5ace397a1c089', 'hex');
     var key = HDPrivateKey.fromObject({
       network: 'testnet',
       depth: 0,
@@ -256,8 +256,8 @@ describe('BIP32 compliance', function() {
 
   it('should NOT use full 32 bytes for private key data that is hashed with the nonCompliant derive method', function() {
     // This is to test that the previously implemented non-compliant to BIP32
-    var privateKeyBuffer = new Buffer('00000055378cf5fafb56c711c674143f9b0ee82ab0ba2924f19b64f5ae7cdbfd', 'hex');
-    var chainCodeBuffer = new Buffer('9c8a5c863e5941f3d99453e6ba66b328bb17cf0b8dec89ed4fc5ace397a1c089', 'hex');
+    var privateKeyBuffer = Buffer.from('00000055378cf5fafb56c711c674143f9b0ee82ab0ba2924f19b64f5ae7cdbfd', 'hex');
+    var chainCodeBuffer = Buffer.from('9c8a5c863e5941f3d99453e6ba66b328bb17cf0b8dec89ed4fc5ace397a1c089', 'hex');
     var key = HDPrivateKey.fromObject({
       network: 'testnet',
       depth: 0,
@@ -271,14 +271,14 @@ describe('BIP32 compliance', function() {
   });
 
   describe('edge cases', function() {
-    var sandbox = sinon.sandbox.create();
+    var sandbox = sinon.createSandbox();
     afterEach(function() {
       sandbox.restore();
     });
     it('will handle edge case that derived private key is invalid', function() {
-      var invalid = new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex');
-      var privateKeyBuffer = new Buffer('5f72914c48581fc7ddeb944a9616389200a9560177d24f458258e5b04527bcd1', 'hex');
-      var chainCodeBuffer = new Buffer('39816057bba9d952fe87fe998b7fd4d690a1bb58c2ff69141469e4d1dffb4b91', 'hex');
+      var invalid =  Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex');
+      var privateKeyBuffer =  Buffer.from('5f72914c48581fc7ddeb944a9616389200a9560177d24f458258e5b04527bcd1', 'hex');
+      var chainCodeBuffer =  Buffer.from('39816057bba9d952fe87fe998b7fd4d690a1bb58c2ff69141469e4d1dffb4b91', 'hex');
       var unstubbed = bitcore.crypto.BN.prototype.toBuffer;
       var count = 0;
       var stub = sandbox.stub(bitcore.crypto.BN.prototype, 'toBuffer').callsFake(function (args) {
@@ -305,8 +305,8 @@ describe('BIP32 compliance', function() {
       bitcore.PrivateKey.isValid.callCount.should.equal(2);
     });
     it('will handle edge case that a derive public key is invalid', function() {
-      var publicKeyBuffer = new Buffer('029e58b241790284ef56502667b15157b3fc58c567f044ddc35653860f9455d099', 'hex');
-      var chainCodeBuffer = new Buffer('39816057bba9d952fe87fe998b7fd4d690a1bb58c2ff69141469e4d1dffb4b91', 'hex');
+      var publicKeyBuffer = Buffer.from('029e58b241790284ef56502667b15157b3fc58c567f044ddc35653860f9455d099', 'hex');
+      var chainCodeBuffer = Buffer.from('39816057bba9d952fe87fe998b7fd4d690a1bb58c2ff69141469e4d1dffb4b91', 'hex');
       var key = new HDPublicKey({
         network: 'testnet',
         depth: 0,
diff --git a/packages/bitcore-lib/test/hdprivatekey.js b/packages/bitcore-lib/test/hdprivatekey.js
index 6b63e6279..7947f826e 100644
--- a/packages/bitcore-lib/test/hdprivatekey.js
+++ b/packages/bitcore-lib/test/hdprivatekey.js
@@ -140,7 +140,7 @@ describe('HDPrivate key interface', function() {
   });
 
   it('returns InvalidLength if data of invalid length is given to getSerializedError', function() {
-    var b58s = Base58Check.encode(new buffer.Buffer('onestring'));
+    var b58s = Base58Check.encode(Buffer.from('onestring'));
     expect(
       HDPrivateKey.getSerializedError(b58s) instanceof hdErrors.InvalidLength
     ).to.equal(true);
diff --git a/packages/bitcore-lib/test/hdpublickey.js b/packages/bitcore-lib/test/hdpublickey.js
index d51ee3532..29369d2b9 100644
--- a/packages/bitcore-lib/test/hdpublickey.js
+++ b/packages/bitcore-lib/test/hdpublickey.js
@@ -78,7 +78,7 @@ describe('HDPublicKey interface', function() {
     describe('xpubkey string serialization errors', function() {
       it('fails on invalid length', function() {
         expectFailBuilding(
-          Base58Check.encode(new buffer.Buffer([1, 2, 3])),
+          Base58Check.encode(Buffer.from([1, 2, 3])),
           hdErrors.InvalidLength
         );
       });
diff --git a/packages/bitcore-lib/test/message.js b/packages/bitcore-lib/test/message.js
index a94985e4a..9f60bdd3b 100644
--- a/packages/bitcore-lib/test/message.js
+++ b/packages/bitcore-lib/test/message.js
@@ -21,8 +21,8 @@ describe('Message', function() {
 
   var badSignatureString = 'H69qZ4mbZCcvXk7CWjptD5ypnYVLvQ3eMXLM8+1gX21SLH/GaFnAjQrDn37+TDw79i9zHhbiMMwhtvTwnPigZ6k=';
 
-  var signature = Signature.fromCompact(new Buffer(signatureString, 'base64'));
-  var badSignature = Signature.fromCompact(new Buffer(badSignatureString, 'base64'));
+  var signature = Signature.fromCompact(Buffer.from(signatureString, 'base64'));
+  var badSignature = Signature.fromCompact(Buffer.from(badSignatureString, 'base64'));
 
   var publicKey = privateKey.toPublicKey();
 
diff --git a/packages/bitcore-lib/test/networks.js b/packages/bitcore-lib/test/networks.js
index 07423726c..d710c0ddd 100644
--- a/packages/bitcore-lib/test/networks.js
+++ b/packages/bitcore-lib/test/networks.js
@@ -57,7 +57,7 @@ describe('Networks', function() {
       if (key !== 'networkMagic') {
         customnet[key].should.equal(custom[key]);
       } else {
-        var expected = new Buffer('e7beb4d4', 'hex');
+        var expected = Buffer.from('e7beb4d4', 'hex');
         customnet[key].should.deep.equal(expected);
       }
     }
diff --git a/packages/bitcore-lib/test/opcode.js b/packages/bitcore-lib/test/opcode.js
index 4ea18abd0..e28fc511b 100644
--- a/packages/bitcore-lib/test/opcode.js
+++ b/packages/bitcore-lib/test/opcode.js
@@ -54,7 +54,7 @@ describe('Opcode', function() {
 
   describe('#buffer', function() {
     it('should correctly input/output a buffer', function() {
-      var buf = new Buffer('a6', 'hex');
+      var buf = Buffer.from('a6', 'hex');
       Opcode.fromBuffer(buf).toBuffer().should.deep.equal(buf);
     });
   });
diff --git a/packages/bitcore-lib/test/privatekey.js b/packages/bitcore-lib/test/privatekey.js
index db45f6080..d67b708f0 100644
--- a/packages/bitcore-lib/test/privatekey.js
+++ b/packages/bitcore-lib/test/privatekey.js
@@ -17,7 +17,7 @@ var invalidbase58 = require('./data/bitcoind/base58_keys_invalid.json');
 describe('PrivateKey', function() {
   var hex = '96c132224121b509b7d0a16245e957d9192609c5637c6228311287b1be21627a';
   var hex2 = '8080808080808080808080808080808080808080808080808080808080808080';
-  var buf = new Buffer(hex, 'hex');
+  var buf = Buffer.from(hex, 'hex');
   var wifTestnet = 'cSdkPxkAjA4HDr5VHgsebAPDEh9Gyub4HK8UJr2DFGGqKKy4K5sG';
   var wifTestnetUncompressed = '92jJzK4tbURm1C7udQXxeCBvXHoHJstDXRxAMouPG1k1XUaXdsu';
   var wifLivenet = 'L2Gkw3kKJ6N24QcDuH4XDqt9cTqsKTVNDGz1CRZhk9cq4auDUbJy';
@@ -127,7 +127,7 @@ describe('PrivateKey', function() {
     it('should not be able to instantiate private key WIF is too long', function() {
       expect(function() {
         var buf = Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m');
-        var buf2 = Buffer.concat([buf, new Buffer(0x01)]);
+        var buf2 = Buffer.concat([buf, Buffer.from([0x01])]);
         return new PrivateKey(buf2);
       }).to.throw('Length of buffer must be 33 (uncompressed) or 34 (compressed');
     });
@@ -135,7 +135,7 @@ describe('PrivateKey', function() {
     it('should not be able to instantiate private key WIF because of unknown network byte', function() {
       expect(function() {
         var buf = Base58Check.decode('L3T1s1TYP9oyhHpXgkyLoJFGniEgkv2Jhi138d7R2yJ9F4QdDU2m');
-        var buf2 = Buffer.concat([new Buffer('ff', 'hex'), buf.slice(1, 33)]);
+        var buf2 = Buffer.concat([ Buffer.from('ff', 'hex'), buf.slice(1, 33)]);
         return new PrivateKey(buf2);
       }).to.throw('Invalid network');
     });
@@ -332,7 +332,7 @@ describe('PrivateKey', function() {
     });
 
     it('will output a 31 byte buffer', function() {
-      var bn = BN.fromBuffer(new Buffer('9b5a0e8fee1835e21170ce1431f9b6f19b487e67748ed70d8a4462bc031915', 'hex'));
+      var bn = BN.fromBuffer(Buffer.from('9b5a0e8fee1835e21170ce1431f9b6f19b487e67748ed70d8a4462bc031915', 'hex'));
       var privkey = new PrivateKey(bn);
       var buffer = privkey.toBufferNoPadding();
       buffer.length.should.equal(31);
@@ -416,7 +416,7 @@ describe('PrivateKey', function() {
     it('should convert this known PrivateKey to known PublicKey', function() {
       var privhex = '906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff';
       var pubhex = '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc';
-      var privkey = new PrivateKey(new BN(new Buffer(privhex, 'hex')));
+      var privkey = new PrivateKey(new BN(Buffer.from(privhex, 'hex')));
       var pubkey = privkey.toPublicKey();
       pubkey.toString().should.equal(pubhex);
     });
@@ -424,7 +424,7 @@ describe('PrivateKey', function() {
     it('should have a "publicKey" property', function() {
       var privhex = '906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff';
       var pubhex = '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc';
-      var privkey = new PrivateKey(new BN(new Buffer(privhex, 'hex')));
+      var privkey = new PrivateKey(new BN(Buffer.from(privhex, 'hex')));
       privkey.publicKey.toString().should.equal(pubhex);
     });
 
diff --git a/packages/bitcore-lib/test/publickey.js b/packages/bitcore-lib/test/publickey.js
index d0a52a6a1..0d20c01e2 100644
--- a/packages/bitcore-lib/test/publickey.js
+++ b/packages/bitcore-lib/test/publickey.js
@@ -49,7 +49,7 @@ describe('PublicKey', function() {
     it('from a private key', function() {
       var privhex = '906977a061af29276e40bf377042ffbde414e496ae2260bbf1fa9d085637bfff';
       var pubhex = '02a1633cafcc01ebfb6d78e39f687a1f0995c62fc95f51ead10a02ee0be551b5dc';
-      var privkey = new PrivateKey(new BN(new Buffer(privhex, 'hex')));
+      var privkey = new PrivateKey(new BN(Buffer.from(privhex, 'hex')));
       var pk = new PublicKey(privkey);
       pk.toString().should.equal(pubhex);
     });
@@ -109,7 +109,7 @@ describe('PublicKey', function() {
     });
 
     it('from a hex encoded DER buffer', function() {
-      var pk = new PublicKey(new Buffer('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
+      var pk = new PublicKey(Buffer.from('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
       should.exist(pk.point);
       pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
     });
@@ -220,20 +220,20 @@ describe('PublicKey', function() {
   describe('#fromBuffer', function() {
 
     it('should parse this uncompressed public key', function() {
-      var pk = PublicKey.fromBuffer(new Buffer('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
+      var pk = PublicKey.fromBuffer(Buffer.from('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
       pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
       pk.point.getY().toString(16).should.equal('7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');
     });
 
     it('should parse this compressed public key', function() {
-      var pk = PublicKey.fromBuffer(new Buffer('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+      var pk = PublicKey.fromBuffer(Buffer.from('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
       pk.point.getY().toString(16).should.equal('7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');
     });
 
     it('should throw an error on this invalid public key', function() {
       (function() {
-        PublicKey.fromBuffer(new Buffer('091ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+        PublicKey.fromBuffer(Buffer.from('091ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       }).should.throw();
     });
 
@@ -245,7 +245,7 @@ describe('PublicKey', function() {
 
     it('should throw error because buffer is the incorrect length', function() {
       (function() {
-        PublicKey.fromBuffer(new Buffer('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a34112', 'hex'));
+        PublicKey.fromBuffer(Buffer.from('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a34112', 'hex'));
       }).should.throw('Length of x and y must be 32 bytes');
     });
 
@@ -254,20 +254,20 @@ describe('PublicKey', function() {
   describe('#fromDER', function() {
 
     it('should parse this uncompressed public key', function() {
-      var pk = PublicKey.fromDER(new Buffer('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
+      var pk = PublicKey.fromDER(Buffer.from('041ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341', 'hex'));
       pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
       pk.point.getY().toString(16).should.equal('7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');
     });
 
     it('should parse this compressed public key', function() {
-      var pk = PublicKey.fromDER(new Buffer('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+      var pk = PublicKey.fromDER(Buffer.from('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
       pk.point.getY().toString(16).should.equal('7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');
     });
 
     it('should throw an error on this invalid public key', function() {
       (function() {
-        PublicKey.fromDER(new Buffer('091ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+        PublicKey.fromDER(Buffer.from('091ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       }).should.throw();
     });
 
@@ -286,7 +286,7 @@ describe('PublicKey', function() {
   describe('#fromX', function() {
 
     it('should create this known public key', function() {
-      var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+      var x = BN.fromBuffer(Buffer.from('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       var pk = PublicKey.fromX(true, x);
       pk.point.getX().toString(16).should.equal('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
       pk.point.getY().toString(16).should.equal('7baad41d04514751e6851f5304fd243751703bed21b914f6be218c0fa354a341');
@@ -294,7 +294,7 @@ describe('PublicKey', function() {
 
 
     it('should error because odd was not included as a param', function() {
-      var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+      var x = BN.fromBuffer(Buffer.from('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       (function() {
         return PublicKey.fromX(null, x);
       }).should.throw('Must specify whether y is odd or not (true or false)');
@@ -305,13 +305,13 @@ describe('PublicKey', function() {
   describe('#toBuffer', function() {
 
     it('should return this compressed DER format', function() {
-      var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+      var x = BN.fromBuffer(Buffer.from('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       var pk = PublicKey.fromX(true, x);
       pk.toBuffer().toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
     });
 
     it('should return this uncompressed DER format', function() {
-      var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+      var x = BN.fromBuffer(Buffer.from('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       var pk = PublicKey.fromX(true, x);
       pk.toBuffer().toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
     });
@@ -321,7 +321,7 @@ describe('PublicKey', function() {
   describe('#toDER', function() {
 
     it('should return this compressed DER format', function() {
-      var x = BN.fromBuffer(new Buffer('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
+      var x = BN.fromBuffer(Buffer.from('1ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a', 'hex'));
       var pk = PublicKey.fromX(true, x);
       pk.toDER().toString('hex').should.equal('031ff0fe0f7b15ffaa85ff9f4744d539139c252a49710fb053bb9f2b933173ff9a');
     });
diff --git a/packages/bitcore-lib/test/script/interpreter.js b/packages/bitcore-lib/test/script/interpreter.js
index 25d145ace..8dc48090e 100644
--- a/packages/bitcore-lib/test/script/interpreter.js
+++ b/packages/bitcore-lib/test/script/interpreter.js
@@ -31,10 +31,10 @@ Script.fromBitcoindString = function(str) {
     var tbuf;
     if (token[0] === '0' && token[1] === 'x') {
       var hex = token.slice(2);
-      bw.write(new Buffer(hex, 'hex'));
+      bw.write(Buffer.from(hex, 'hex'));
     } else if (token[0] === '\'') {
       var tstr = token.slice(1, token.length - 1);
-      var cbuf = new Buffer(tstr);
+      var cbuf = Buffer.from(tstr);
       tbuf = Script().add(cbuf).toBuffer();
       bw.write(tbuf);
     } else if (typeof Opcode['OP_' + token] !== 'undefined') {
@@ -80,7 +80,7 @@ describe('Interpreter', function() {
       Interpreter.castToBool(new BN(0).toSM({
         endian: 'little'
       })).should.equal(false);
-      Interpreter.castToBool(new Buffer('0080', 'hex')).should.equal(false); //negative 0
+      Interpreter.castToBool(Buffer.from('0080', 'hex')).should.equal(false); //negative 0
       Interpreter.castToBool(new BN(1).toSM({
         endian: 'little'
       })).should.equal(true);
@@ -88,7 +88,7 @@ describe('Interpreter', function() {
         endian: 'little'
       })).should.equal(true);
 
-      var buf = new Buffer('00', 'hex');
+      var buf = Buffer.from('00', 'hex');
       var bool = BN.fromSM(buf, {
         endian: 'little'
       }).cmp(BN.Zero) !== 0;
@@ -101,8 +101,8 @@ describe('Interpreter', function() {
     it('will return true if witness program greater than 0', function() {
       var si = Interpreter();
       var version = 1;
-      var program = new Buffer('bcbd1db07ce89d1f4050645c26c90ce78b67eff78460002a4d5c10410958e064', 'hex');
-      var witness = [new Buffer('bda0eeeb166c8bfeaee88dedc8efa82d3bea35aac5be253902f59d52908bfe25', 'hex')];
+      var program = Buffer.from('bcbd1db07ce89d1f4050645c26c90ce78b67eff78460002a4d5c10410958e064', 'hex');
+      var witness = [Buffer.from('bda0eeeb166c8bfeaee88dedc8efa82d3bea35aac5be253902f59d52908bfe25', 'hex')];
       var satoshis = 1;
       var flags = 0;
       si.verifyWitnessProgram(version, program, witness, satoshis, flags).should.equal(true);
@@ -110,7 +110,7 @@ describe('Interpreter', function() {
     it('will return false with error if witness length is 0', function() {
       var si = Interpreter();
       var version = 0;
-      var program = new Buffer('bcbd1db07ce89d1f4050645c26c90ce78b67eff78460002a4d5c10410958e064', 'hex');
+      var program = Buffer.from('bcbd1db07ce89d1f4050645c26c90ce78b67eff78460002a4d5c10410958e064', 'hex');
       var witness = [];
       var satoshis = 1;
       var flags = 0;
@@ -120,10 +120,10 @@ describe('Interpreter', function() {
     it('will return false if program hash mismatch (version 0, 32 byte program)', function() {
       var si = Interpreter();
       var version = 0;
-      var program = new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex');
+      var program = Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex');
       var witness = [
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
+         Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
       ];
       var satoshis = 1;
       var flags = 0;
@@ -133,11 +133,11 @@ describe('Interpreter', function() {
     it('will return false if witness stack doesn\'t have two items (version 0, 20 byte program)', function() {
       var si = Interpreter();
       var version = 0;
-      var program = new Buffer('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
+      var program = Buffer.from('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
       var witness = [
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
       ];
       var satoshis = 1;
       var flags = 0;
@@ -147,9 +147,9 @@ describe('Interpreter', function() {
     it('will return false if program wrong length for version 0', function() {
       var si = Interpreter();
       var version = 0;
-      var program = new Buffer('b8bcb07f6344b42ab04250c86a6e8b75d3', 'hex');
+      var program = Buffer.from('b8bcb07f6344b42ab04250c86a6e8b75d3', 'hex');
       var witness = [
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
       ];
       var satoshis = 1;
       var flags = 0;
@@ -159,10 +159,10 @@ describe('Interpreter', function() {
     it('will return false with discourage upgradable witness program', function() {
       var si = Interpreter();
       var version = 1;
-      var program = new Buffer('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
+      var program = Buffer.from('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
       var witness = [
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
       ];
       var satoshis = 1;
       var flags = Interpreter.SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM;
@@ -173,10 +173,10 @@ describe('Interpreter', function() {
       var si = Interpreter();
       si.evaluate = sinon.stub().returns(true);
       var version = 0;
-      var program = new Buffer('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
+      var program = Buffer.from('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
       var witness = [
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
       ];
       var satoshis = 1;
       var flags = 0;
@@ -186,14 +186,14 @@ describe('Interpreter', function() {
     it('will return false if last item in stack casts to false', function() {
       var si = Interpreter();
       si.evaluate = function() {
-        si.stack = [new Buffer('00', 'hex')];
+        si.stack = [Buffer.from('00', 'hex')];
         return true;
       };
       var version = 0;
-      var program = new Buffer('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
+      var program = Buffer.from('b8bcb07f6344b42ab04250c86a6e8b75d3fdbbc6', 'hex');
       var witness = [
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
-        new Buffer('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex'),
+        Buffer.from('0000000000000000000000000000000000000000000000000000000000000000', 'hex')
       ];
       var satoshis = 1;
       var flags = 0;
@@ -331,7 +331,7 @@ describe('Interpreter', function() {
     var scriptPubkey = Script.fromBitcoindString(vector[1]);
     var flags = getFlags(vector[2]);
 
-    var hashbuf = new Buffer(32);
+    var hashbuf = Buffer.alloc(32);
     hashbuf.fill(0);
     var credtx = new Transaction();
     credtx.uncheckedAddInput(new Transaction.Input({
diff --git a/packages/bitcore-lib/test/script/script.js b/packages/bitcore-lib/test/script/script.js
index e635ec778..839244059 100644
--- a/packages/bitcore-lib/test/script/script.js
+++ b/packages/bitcore-lib/test/script/script.js
@@ -49,7 +49,7 @@ describe('Script', function() {
   describe('#fromBuffer', function() {
 
     it('should parse this buffer containing an OP code', function() {
-      var buf = new Buffer(1);
+      var buf = Buffer.alloc(1);
       buf[0] = Opcode.OP_0;
       var script = Script.fromBuffer(buf);
       script.chunks.length.should.equal(1);
@@ -57,7 +57,7 @@ describe('Script', function() {
     });
 
     it('should parse this buffer containing another OP code', function() {
-      var buf = new Buffer(1);
+      var buf = Buffer.alloc(1);
       buf[0] = Opcode.OP_CHECKMULTISIG;
       var script = Script.fromBuffer(buf);
       script.chunks.length.should.equal(1);
@@ -65,14 +65,14 @@ describe('Script', function() {
     });
 
     it('should parse this buffer containing three bytes of data', function() {
-      var buf = new Buffer([3, 1, 2, 3]);
+      var buf = Buffer.from([3, 1, 2, 3]);
       var script = Script.fromBuffer(buf);
       script.chunks.length.should.equal(1);
       script.chunks[0].buf.toString('hex').should.equal('010203');
     });
 
     it('should parse this buffer containing OP_PUSHDATA1 and three bytes of data', function() {
-      var buf = new Buffer([0, 0, 1, 2, 3]);
+      var buf = Buffer.from([0, 0, 1, 2, 3]);
       buf[0] = Opcode.OP_PUSHDATA1;
       buf.writeUInt8(3, 1);
       var script = Script.fromBuffer(buf);
@@ -81,7 +81,7 @@ describe('Script', function() {
     });
 
     it('should parse this buffer containing OP_PUSHDATA2 and three bytes of data', function() {
-      var buf = new Buffer([0, 0, 0, 1, 2, 3]);
+      var buf = Buffer.from([0, 0, 0, 1, 2, 3]);
       buf[0] = Opcode.OP_PUSHDATA2;
       buf.writeUInt16LE(3, 1);
       var script = Script.fromBuffer(buf);
@@ -90,7 +90,7 @@ describe('Script', function() {
     });
 
     it('should parse this buffer containing OP_PUSHDATA4 and three bytes of data', function() {
-      var buf = new Buffer([0, 0, 0, 0, 0, 1, 2, 3]);
+      var buf = Buffer.from([0, 0, 0, 0, 0, 1, 2, 3]);
       buf[0] = Opcode.OP_PUSHDATA4;
       buf.writeUInt16LE(3, 1);
       var script = Script.fromBuffer(buf);
@@ -99,7 +99,7 @@ describe('Script', function() {
     });
 
     it('should parse this buffer an OP code, data, and another OP code', function() {
-      var buf = new Buffer([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
+      var buf = Buffer.from([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
       buf[0] = Opcode.OP_0;
       buf[1] = Opcode.OP_PUSHDATA4;
       buf.writeUInt16LE(3, 2);
@@ -116,7 +116,7 @@ describe('Script', function() {
   describe('#toBuffer', function() {
 
     it('should output this buffer containing an OP code', function() {
-      var buf = new Buffer(1);
+      var buf = Buffer.alloc(1);
       buf[0] = Opcode.OP_0;
       var script = Script.fromBuffer(buf);
       script.chunks.length.should.equal(1);
@@ -125,7 +125,7 @@ describe('Script', function() {
     });
 
     it('should output this buffer containing another OP code', function() {
-      var buf = new Buffer(1);
+      var buf = Buffer.alloc(1);
       buf[0] = Opcode.OP_CHECKMULTISIG;
       var script = Script.fromBuffer(buf);
       script.chunks.length.should.equal(1);
@@ -134,7 +134,7 @@ describe('Script', function() {
     });
 
     it('should output this buffer containing three bytes of data', function() {
-      var buf = new Buffer([3, 1, 2, 3]);
+      var buf = Buffer.from([3, 1, 2, 3]);
       var script = Script.fromBuffer(buf);
       script.chunks.length.should.equal(1);
       script.chunks[0].buf.toString('hex').should.equal('010203');
@@ -142,7 +142,7 @@ describe('Script', function() {
     });
 
     it('should output this buffer containing OP_PUSHDATA1 and three bytes of data', function() {
-      var buf = new Buffer([0, 0, 1, 2, 3]);
+      var buf = Buffer.from([0, 0, 1, 2, 3]);
       buf[0] = Opcode.OP_PUSHDATA1;
       buf.writeUInt8(3, 1);
       var script = Script.fromBuffer(buf);
@@ -152,7 +152,7 @@ describe('Script', function() {
     });
 
     it('should output this buffer containing OP_PUSHDATA2 and three bytes of data', function() {
-      var buf = new Buffer([0, 0, 0, 1, 2, 3]);
+      var buf = Buffer.from([0, 0, 0, 1, 2, 3]);
       buf[0] = Opcode.OP_PUSHDATA2;
       buf.writeUInt16LE(3, 1);
       var script = Script.fromBuffer(buf);
@@ -162,7 +162,7 @@ describe('Script', function() {
     });
 
     it('should output this buffer containing OP_PUSHDATA4 and three bytes of data', function() {
-      var buf = new Buffer([0, 0, 0, 0, 0, 1, 2, 3]);
+      var buf = Buffer.from([0, 0, 0, 0, 0, 1, 2, 3]);
       buf[0] = Opcode.OP_PUSHDATA4;
       buf.writeUInt16LE(3, 1);
       var script = Script.fromBuffer(buf);
@@ -172,7 +172,7 @@ describe('Script', function() {
     });
 
     it('should output this buffer an OP code, data, and another OP code', function() {
-      var buf = new Buffer([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
+      var buf = Buffer.from([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
       buf[0] = Opcode.OP_0;
       buf[1] = Opcode.OP_PUSHDATA4;
       buf.writeUInt16LE(3, 2);
@@ -219,7 +219,7 @@ describe('Script', function() {
     });
 
     it('should output this buffer an OP code, data, and another OP code', function() {
-      var buf = new Buffer([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
+      var buf = Buffer.from([0, 0, 0, 0, 0, 0, 1, 2, 3, 0]);
       buf[0] = Opcode.OP_0;
       buf[1] = Opcode.OP_PUSHDATA4;
       buf.writeUInt16LE(3, 2);
@@ -253,7 +253,7 @@ describe('Script', function() {
 
   describe('toHex', function() {
     it('should return an hexa string "03010203" as expected from [3, 1, 2, 3]', function() {
-      var buf = new Buffer([3, 1, 2, 3]);
+      var buf = Buffer.from([3, 1, 2, 3]);
       var script = Script.fromBuffer(buf);
       script.toHex().should.equal('03010203');
     });
@@ -266,24 +266,24 @@ describe('Script', function() {
     });
 
     it('validates that this 40-byte OP_RETURN is standard', function() {
-      var buf = new Buffer(40);
+      var buf = Buffer.alloc(40);
       buf.fill(0);
       Script('OP_RETURN 40 0x' + buf.toString('hex')).isDataOut().should.equal(true);
     });
     it('validates that this 80-byte OP_RETURN is standard', function() {
-      var buf = new Buffer(80);
+      var buf = Buffer.alloc(80);
       buf.fill(0);
       Script('OP_RETURN OP_PUSHDATA1 80 0x' + buf.toString('hex')).isDataOut().should.equal(true);
     });
 
     it('validates that this 40-byte long OP_CHECKMULTISIG is not standard op_return', function() {
-      var buf = new Buffer(40);
+      var buf = Buffer.alloc(40);
       buf.fill(0);
       Script('OP_CHECKMULTISIG 40 0x' + buf.toString('hex')).isDataOut().should.equal(false);
     });
 
     it('validates that this 81-byte OP_RETURN is not a valid standard OP_RETURN', function() {
-      var buf = new Buffer(81);
+      var buf = Buffer.alloc(81);
       buf.fill(0);
       Script('OP_RETURN OP_PUSHDATA1 81 0x' + buf.toString('hex')).isDataOut().should.equal(false);
     });
@@ -293,7 +293,7 @@ describe('Script', function() {
     it('correctly identify scriptSig as a public key in', function() {
       // from txid: 5c85ed63469aa9971b5d01063dbb8bcdafd412b2f51a3d24abf2e310c028bbf8
       // and input index: 5
-      var scriptBuffer = new Buffer('483045022050eb59c79435c051f45003d9f82865c8e4df5699d7722e77113ef8cadbd92109022100d4ab233e070070eb8e0e62e3d2d2eb9474a5bf135c9eda32755acb0875a6c20601', 'hex');
+      var scriptBuffer = Buffer.from('483045022050eb59c79435c051f45003d9f82865c8e4df5699d7722e77113ef8cadbd92109022100d4ab233e070070eb8e0e62e3d2d2eb9474a5bf135c9eda32755acb0875a6c20601', 'hex');
       var script = bitcore.Script.fromBuffer(scriptBuffer);
       script.isPublicKeyIn().should.equal(true);
     });
@@ -656,16 +656,16 @@ describe('Script', function() {
     });
 
     it('should add these push data', function() {
-      var buf = new Buffer(1);
+      var buf = Buffer.alloc(1);
       buf.fill(0);
       Script().add(buf).toString().should.equal('1 0x00');
-      buf = new Buffer(255);
+      buf = Buffer.alloc(255);
       buf.fill(0);
       Script().add(buf).toString().should.equal('OP_PUSHDATA1 255 0x' + buf.toString('hex'));
-      buf = new Buffer(256);
+      buf = Buffer.alloc(256);
       buf.fill(0);
       Script().add(buf).toString().should.equal('OP_PUSHDATA2 256 0x' + buf.toString('hex'));
-      buf = new Buffer(Math.pow(2, 16));
+      buf = Buffer.alloc(Math.pow(2, 16));
       buf.fill(0);
       Script().add(buf).toString().should.equal('OP_PUSHDATA4 ' + Math.pow(2, 16) + ' 0x' + buf.toString('hex'));
     });
@@ -673,13 +673,13 @@ describe('Script', function() {
     it('should add both pushdata and non-pushdata chunks', function() {
       Script().add('OP_CHECKMULTISIG').toString().should.equal('OP_CHECKMULTISIG');
       Script().add(Opcode.map.OP_CHECKMULTISIG).toString().should.equal('OP_CHECKMULTISIG');
-      var buf = new Buffer(1);
+      var buf = Buffer.alloc(1);
       buf.fill(0);
       Script().add(buf).toString().should.equal('1 0x00');
     });
 
     it('should work for no data OP_RETURN', function() {
-      Script().add(Opcode.OP_RETURN).add(new Buffer('')).toString().should.equal('OP_RETURN');
+      Script().add(Opcode.OP_RETURN).add(Buffer.from('')).toString().should.equal('OP_RETURN');
     });
     it('works with objects', function() {
       Script().add({
@@ -807,14 +807,14 @@ describe('Script', function() {
       s.isDataOut().should.equal(true);
     });
     it('should create script from empty data', function() {
-      var data = new Buffer('');
+      var data = Buffer.from('');
       var s = Script.buildDataOut(data);
       should.exist(s);
       s.toString().should.equal('OP_RETURN');
       s.isDataOut().should.equal(true);
     });
     it('should create script from some data', function() {
-      var data = new Buffer('bacacafe0102030405', 'hex');
+      var data = Buffer.from('bacacafe0102030405', 'hex');
       var s = Script.buildDataOut(data);
       should.exist(s);
       s.toString().should.equal('OP_RETURN 9 0xbacacafe0102030405');
@@ -899,17 +899,17 @@ describe('Script', function() {
       Script().add(1000).checkMinimalPush(0).should.equal(true);
       Script().add(0xffffffff).checkMinimalPush(0).should.equal(true);
       Script().add(0xffffffffffffffff).checkMinimalPush(0).should.equal(true);
-      Script().add(new Buffer([0])).checkMinimalPush(0).should.equal(true);
+      Script().add(Buffer.from([0])).checkMinimalPush(0).should.equal(true);
 
-      var buf = new Buffer(75);
+      var buf = Buffer.alloc(75);
       buf.fill(1);
       Script().add(buf).checkMinimalPush(0).should.equal(true);
 
-      buf = new Buffer(76);
+      buf = Buffer.alloc(76);
       buf.fill(1);
       Script().add(buf).checkMinimalPush(0).should.equal(true);
 
-      buf = new Buffer(256);
+      buf = Buffer.alloc(256);
       buf.fill(1);
       Script().add(buf).checkMinimalPush(0).should.equal(true);
     });
@@ -920,11 +920,11 @@ describe('Script', function() {
     it('works with this testnet transaction', function() {
       // testnet block: 00000000a36400fc06440512354515964bc36ecb0020bd0b0fd48ae201965f54
       // txhash: e362e21ff1d2ef78379d401d89b42ce3e0ce3e245f74b1f4cb624a8baa5d53ad (output 0);
-      var script = Script.fromBuffer(new Buffer('6a', 'hex'));
+      var script = Script.fromBuffer(Buffer.from('6a', 'hex'));
       var dataout = script.isDataOut();
       dataout.should.equal(true);
       var data = script.getData();
-      data.should.deep.equal(new Buffer(0));
+      data.should.deep.equal(Buffer.alloc(0));
     });
     it('for a P2PKH address', function() {
       var address = Address.fromString('1NaTVwXDDUJaXDQajoa9MqHhz4uTxtgK14');
@@ -937,7 +937,7 @@ describe('Script', function() {
       expect(BufferUtil.equal(script.getData(), address.hashBuffer)).to.be.equal(true);
     });
     it('for a standard opreturn output', function() {
-      expect(BufferUtil.equal(Script('OP_RETURN 1 0xFF').getData(), new Buffer([255]))).to.be.equal(true);
+      expect(BufferUtil.equal(Script('OP_RETURN 1 0xFF').getData(), Buffer.from([255]))).to.be.equal(true);
     });
     it('fails if content is not recognized', function() {
       expect(function() {
@@ -1027,10 +1027,10 @@ describe('Script', function() {
       Script('OP_TRUE OP_TRUE').equals(Script('OP_TRUE OP_FALSE')).should.equal(false);
     });
     it('returns false for different data', function() {
-      Script().add(new Buffer('a')).equals(Script('OP_TRUE')).should.equal(false);
+      Script().add(Buffer.from('a')).equals(Script('OP_TRUE')).should.equal(false);
     });
     it('returns false for different data', function() {
-      Script().add(new Buffer('a')).equals(Script().add(new Buffer('b'))).should.equal(false);
+      Script().add(Buffer.from('a')).equals(Script().add(Buffer.from('b'))).should.equal(false);
     });
   });
 
diff --git a/packages/bitcore-lib/test/transaction/output.js b/packages/bitcore-lib/test/transaction/output.js
index de5d9209c..51f5af609 100644
--- a/packages/bitcore-lib/test/transaction/output.js
+++ b/packages/bitcore-lib/test/transaction/output.js
@@ -155,7 +155,7 @@ describe("Output", function() {
   });
 
   it("#toObject roundtrip will handle an invalid (null) script", function() {
-    var invalidOutputScript = new Buffer("0100000000000000014c", "hex");
+    var invalidOutputScript = Buffer.from("0100000000000000014c", "hex");
     var br = new bitcore.encoding.BufferReader(invalidOutputScript);
     var output = Output.fromBufferReader(br);
     var output2 = new Output(output.toObject());
@@ -164,7 +164,7 @@ describe("Output", function() {
   });
 
   it("inspect will work with an invalid (null) script", function() {
-    var invalidOutputScript = new Buffer("0100000000000000014c", "hex");
+    var invalidOutputScript = Buffer.from("0100000000000000014c", "hex");
     var br = new bitcore.encoding.BufferReader(invalidOutputScript);
     var output = Output.fromBufferReader(br);
     output.inspect().should.equal("<Output (1 sats) 4c>");
@@ -184,7 +184,7 @@ describe("Output", function() {
   it("sets script to null if it is an InvalidBuffer", function() {
     var output = new Output({
       satoshis: 1000,
-      script: new Buffer("4c", "hex")
+      script: Buffer.from("4c", "hex")
     });
     should.equal(output.script, null);
   });
diff --git a/packages/bitcore-lib/test/transaction/sighash.js b/packages/bitcore-lib/test/transaction/sighash.js
index d5fbc16e7..bbaf32535 100644
--- a/packages/bitcore-lib/test/transaction/sighash.js
+++ b/packages/bitcore-lib/test/transaction/sighash.js
@@ -19,12 +19,12 @@ describe('sighash', function() {
       return;
     }
     it('test vector from bitcoind #' + i + ' (' + vector[4].substring(0, 16) + ')', function() {
-      var txbuf = new buffer.Buffer(vector[0], 'hex');
-      var scriptbuf = new buffer.Buffer(vector[1], 'hex');
+      var txbuf = Buffer.from(vector[0], 'hex');
+      var scriptbuf = Buffer.from(vector[1], 'hex');
       var subscript = Script(scriptbuf);
       var nin = vector[2];
       var nhashtype = vector[3];
-      var sighashbuf = new buffer.Buffer(vector[4], 'hex');
+      var sighashbuf = Buffer.from(vector[4], 'hex');
       var tx = new Transaction(txbuf);
 
       //make sure transacion to/from buffer is isomorphic
diff --git a/packages/bitcore-lib/test/transaction/sighashwitness.js b/packages/bitcore-lib/test/transaction/sighashwitness.js
index 4ea76f310..13d1c814d 100644
--- a/packages/bitcore-lib/test/transaction/sighashwitness.js
+++ b/packages/bitcore-lib/test/transaction/sighashwitness.js
@@ -13,8 +13,8 @@ describe('Sighash Witness Program Version 0', function() {
     // https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki
     var unsignedTx = bitcore.Transaction('0100000002fff7f7881a8099afa6940d42d1e7f6362bec38171ea3edf433541db4e4ad969f0000000000eeffffffef51e1b804cc89d182d279655c3aa89e815b1b309fe287d9b2b55d57b90ec68a0100000000ffffffff02202cb206000000001976a9148280b37df378db99f66f85c95a783a76ac7a6d5988ac9093510d000000001976a9143bde42dbee7e4dbe6a21b2d50ce2f0167faa815988ac11000000');
 
-    var scriptCode = new Buffer('1976a9141d0f172a0ecb48aee1be1f2687d2963ae33f71a188ac', 'hex');
-    var satoshisBuffer = new Buffer('0046c32300000000', 'hex');
+    var scriptCode = Buffer.from('1976a9141d0f172a0ecb48aee1be1f2687d2963ae33f71a188ac', 'hex');
+    var satoshisBuffer = Buffer.from('0046c32300000000', 'hex');
 
     var hash = SighashWitness.sighash(unsignedTx, Signature.SIGHASH_ALL, 1, scriptCode, satoshisBuffer);
 
diff --git a/packages/bitcore-lib/test/transaction/signature.js b/packages/bitcore-lib/test/transaction/signature.js
index 51727e0ee..f0d52bed7 100644
--- a/packages/bitcore-lib/test/transaction/signature.js
+++ b/packages/bitcore-lib/test/transaction/signature.js
@@ -104,7 +104,7 @@ describe('TransactionSignature', function() {
     it('can deserialize when signature is a buffer', function() {
       var signature = getSignatureFromTransaction();
       var serialized = signature.toObject();
-      serialized.signature = new Buffer(serialized.signature, 'hex');
+      serialized.signature = Buffer.from(serialized.signature, 'hex');
       expect(TransactionSignature.fromObject(serialized).toObject()).to.deep.equal(signature.toObject());
     });
 
diff --git a/packages/bitcore-lib/test/transaction/transaction.js b/packages/bitcore-lib/test/transaction/transaction.js
index 04df9825a..92400fe90 100644
--- a/packages/bitcore-lib/test/transaction/transaction.js
+++ b/packages/bitcore-lib/test/transaction/transaction.js
@@ -1302,35 +1302,35 @@ describe('Transaction', function() {
   describe('Segregated Witness', function() {
     it('identify as segwit transaction', function() {
       // https://github.com/bitcoin/bips/blob/master/bip-0144.mediawiki
-      var version = new Buffer('01000000', 'hex');
-      var marker = new Buffer('00', 'hex'); //always zero
-      var flag = new Buffer('01', 'hex'); //non zero
-      var inputCount = new Buffer('01', 'hex');
-      var inputDummy = new Buffer('2052cda8bc0c2cb743f154881fc85cb675527dcf2f7a5938241020c33341b3f70000000000ffffffff', 'hex');
-      var outputCount = new Buffer('00', 'hex');
-      var witness = new Buffer('01', 'hex');
-      var witnessItems = new Buffer('00', 'hex');
-      var locktime = new Buffer('00000000', 'hex');
+      var version = Buffer.from('01000000', 'hex');
+      var marker = Buffer.from('00', 'hex'); //always zero
+      var flag = Buffer.from('01', 'hex'); //non zero
+      var inputCount = Buffer.from('01', 'hex');
+      var inputDummy = Buffer.from('2052cda8bc0c2cb743f154881fc85cb675527dcf2f7a5938241020c33341b3f70000000000ffffffff', 'hex');
+      var outputCount = Buffer.from('00', 'hex');
+      var witness = Buffer.from('01', 'hex');
+      var witnessItems =  Buffer.from('00', 'hex');
+      var locktime =  Buffer.from('00000000', 'hex');
       var txBuffer = Buffer.concat([version, marker, flag, inputCount, inputDummy, outputCount, witness,
                                     witnessItems, locktime]);
       var tx = bitcore.Transaction().fromBuffer(txBuffer);
       tx.hasWitnesses().should.equal(true);
     });
     it('correctly calculate hash for segwit transaction', function() {
-      var txBuffer = new Buffer('01000000000101b0e5caa7e37d4b8530c3e1071a36dd5e05d1065cf7224ddff42c69e3387689870000000000ffffffff017b911100000000001600144ff831574da8bef07f8bc97244a1666147b071570247304402203fcbcfddbd6ca3a90252610dd63f1be50b2d926b8d87c912da0a3e42bb03fba002202a90c8aad75da22b0549c72618b754114583e934c0b0d2ccd6c13fcd859ba4ed01210363f3f47f4555779de405eab8d0dc8c2a4f3e09f4171a3fa47c7a77715795319800000000', 'hex');
+      var txBuffer = Buffer.from('01000000000101b0e5caa7e37d4b8530c3e1071a36dd5e05d1065cf7224ddff42c69e3387689870000000000ffffffff017b911100000000001600144ff831574da8bef07f8bc97244a1666147b071570247304402203fcbcfddbd6ca3a90252610dd63f1be50b2d926b8d87c912da0a3e42bb03fba002202a90c8aad75da22b0549c72618b754114583e934c0b0d2ccd6c13fcd859ba4ed01210363f3f47f4555779de405eab8d0dc8c2a4f3e09f4171a3fa47c7a77715795319800000000', 'hex');
       var tx = bitcore.Transaction().fromBuffer(txBuffer);
       tx.hash.should.equal('7f1a2d46746f1bfbb22ab797d5aad1fd9723477b417fa34dff73d8a7dbb14570');
       tx.witnessHash.should.equal('3c26fc8b5cfe65f96d955cecfe4d11db2659d052171f9f31af043e9f5073e46b');
     });
     it('round trip nested witness p2sh', function() {
-      var txBuffer = new Buffer('010000000001010894bb2bbfd5249b1c55f7bc64352bb64894938bc6439f43f28a58bfa7c73205000000002322002077b16b966ee6a4b8a0901351221d279afd31d3f90df52a3fc53436ea9abde5b0ffffffff01010000000000000000030047304402200fa23efa9a8d6ae285cfc82f81e6c2196d14167553b10da1845abd2c9fe38dc502207a40a58ee5b739e902b275018dfa1bee0d608736ff4317b028fbc29391f4554f01475221037b8dc5861a0ef7b0a97b41d2d1e27186f019d4834dbc99f24952b6f5080f5cce21027152378182102b68b5fce42f9f365ec272c48afda6b0816e735c1dc4b96dd45a52ae00000000', 'hex');
+      var txBuffer = Buffer.from('010000000001010894bb2bbfd5249b1c55f7bc64352bb64894938bc6439f43f28a58bfa7c73205000000002322002077b16b966ee6a4b8a0901351221d279afd31d3f90df52a3fc53436ea9abde5b0ffffffff01010000000000000000030047304402200fa23efa9a8d6ae285cfc82f81e6c2196d14167553b10da1845abd2c9fe38dc502207a40a58ee5b739e902b275018dfa1bee0d608736ff4317b028fbc29391f4554f01475221037b8dc5861a0ef7b0a97b41d2d1e27186f019d4834dbc99f24952b6f5080f5cce21027152378182102b68b5fce42f9f365ec272c48afda6b0816e735c1dc4b96dd45a52ae00000000', 'hex');
       var tx = bitcore.Transaction().fromBuffer(txBuffer);
       tx.toBuffer().toString('hex').should.equal(txBuffer.toString('hex'));
     });
     describe('verifying', function() {
       it('will verify these signatures', function() {
-        var signedTxBuffer = new Buffer('0100000000010103752b9d2baadb95480e2571a4854a68ffd8264462168346461b7cdda76beac20000000023220020fde78ea47ae10cc93c6a850d8a86d8575ddacff38ee9b0bc6535dc016a197068ffffffff010100000000000000000400483045022100ea1508225a6d37c0545d22acaee88d29d1675696953f93d657a419613bcee9b802207b8d80ca8176586878f51e001cb9e92f7640b8c9dc530fabf9087142c752de89014830450221008c6f4a9ebdee89968ec00ecc12fda67442b589296e86bf3e9bde19f4ba923406022048c3409831a55bf61f2d5defffd3b91767643b6c5981cb32338dd7e9f02821b1014752210236c8204d62fd70e7ca206a36d39f9674fa832964d787c60d44250624242bada4210266cd5a3507d6df5346aa42bd23d4c44c079aef0d7a59534758a0dabb82345c2052ae00000000', 'hex');
-        var unsignedBuffer = new Buffer('0100000000010103752b9d2baadb95480e2571a4854a68ffd8264462168346461b7cdda76beac20000000023220020fde78ea47ae10cc93c6a850d8a86d8575ddacff38ee9b0bc6535dc016a197068ffffffff010100000000000000000300483045022100ea1508225a6d37c0545d22acaee88d29d1675696953f93d657a419613bcee9b802207b8d80ca8176586878f51e001cb9e92f7640b8c9dc530fabf9087142c752de89014752210236c8204d62fd70e7ca206a36d39f9674fa832964d787c60d44250624242bada4210266cd5a3507d6df5346aa42bd23d4c44c079aef0d7a59534758a0dabb82345c2052ae00000000', 'hex');
+        var signedTxBuffer = Buffer.from('0100000000010103752b9d2baadb95480e2571a4854a68ffd8264462168346461b7cdda76beac20000000023220020fde78ea47ae10cc93c6a850d8a86d8575ddacff38ee9b0bc6535dc016a197068ffffffff010100000000000000000400483045022100ea1508225a6d37c0545d22acaee88d29d1675696953f93d657a419613bcee9b802207b8d80ca8176586878f51e001cb9e92f7640b8c9dc530fabf9087142c752de89014830450221008c6f4a9ebdee89968ec00ecc12fda67442b589296e86bf3e9bde19f4ba923406022048c3409831a55bf61f2d5defffd3b91767643b6c5981cb32338dd7e9f02821b1014752210236c8204d62fd70e7ca206a36d39f9674fa832964d787c60d44250624242bada4210266cd5a3507d6df5346aa42bd23d4c44c079aef0d7a59534758a0dabb82345c2052ae00000000', 'hex');
+        var unsignedBuffer = Buffer.from('0100000000010103752b9d2baadb95480e2571a4854a68ffd8264462168346461b7cdda76beac20000000023220020fde78ea47ae10cc93c6a850d8a86d8575ddacff38ee9b0bc6535dc016a197068ffffffff010100000000000000000300483045022100ea1508225a6d37c0545d22acaee88d29d1675696953f93d657a419613bcee9b802207b8d80ca8176586878f51e001cb9e92f7640b8c9dc530fabf9087142c752de89014752210236c8204d62fd70e7ca206a36d39f9674fa832964d787c60d44250624242bada4210266cd5a3507d6df5346aa42bd23d4c44c079aef0d7a59534758a0dabb82345c2052ae00000000', 'hex');
         var signedTx = bitcore.Transaction().fromBuffer(signedTxBuffer);
 
         var signatures = [
diff --git a/packages/bitcore-lib/test/util/buffer.js b/packages/bitcore-lib/test/util/buffer.js
index 297ee0c83..801a3d7fd 100644
--- a/packages/bitcore-lib/test/util/buffer.js
+++ b/packages/bitcore-lib/test/util/buffer.js
@@ -12,23 +12,23 @@ describe('buffer utils', function() {
 
   describe('equals', function() {
     it('recognizes these two equal buffers', function() {
-      var bufferA = new Buffer([1, 2, 3]);
-      var bufferB = new Buffer('010203', 'hex');
+      var bufferA = Buffer.from([1, 2, 3]);
+      var bufferB = Buffer.from('010203', 'hex');
       BufferUtil.equal(bufferA, bufferB).should.equal(true);
     });
     it('no false positive: returns false with two different buffers', function() {
-      var bufferA = new Buffer([1, 2, 3]);
-      var bufferB = new Buffer('010204', 'hex');
+      var bufferA = Buffer.from([1, 2, 3]);
+      var bufferB = Buffer.from('010204', 'hex');
       BufferUtil.equal(bufferA, bufferB).should.equal(false);
     });
     it('coverage: quickly realizes a difference in size and returns false', function() {
-      var bufferA = new Buffer([1, 2, 3]);
-      var bufferB = new Buffer([]);
+      var bufferA = Buffer.from([1, 2, 3]);
+      var bufferB = Buffer.from([]);
       BufferUtil.equal(bufferA, bufferB).should.equal(false);
     });
     it('"equals" is an an alias for "equal"', function() {
-      var bufferA = new Buffer([1, 2, 3]);
-      var bufferB = new Buffer([1, 2, 3]);
+      var bufferA = Buffer.from([1, 2, 3]);
+      var bufferB = Buffer.from([1, 2, 3]);
       BufferUtil.equal(bufferA, bufferB).should.equal(true);
       BufferUtil.equals(bufferA, bufferB).should.equal(true);
     });
@@ -40,11 +40,11 @@ describe('buffer utils', function() {
         BufferUtil.fill('something');
       }).to.throw(errors.InvalidArgumentType);
       expect(function() {
-        BufferUtil.fill(new Buffer([0, 0, 0]), 'invalid');
+        BufferUtil.fill(Buffer.from([0, 0, 0]), 'invalid');
       }).to.throw(errors.InvalidArgumentType);
     });
     it('works correctly for a small buffer', function() {
-      var buffer = BufferUtil.fill(new Buffer(10), 6);
+      var buffer = BufferUtil.fill(Buffer.alloc(10), 6);
       for (var i = 0; i < 10; i++) {
         buffer[i].should.equal(6);
       }
@@ -56,7 +56,7 @@ describe('buffer utils', function() {
       expect(BufferUtil.isBuffer(1)).to.equal(false);
     });
     it('has no false negative', function() {
-      expect(BufferUtil.isBuffer(new Buffer(0))).to.equal(true);
+      expect(BufferUtil.isBuffer(Buffer.alloc(0))).to.equal(true);
     });
   });
 
@@ -93,7 +93,7 @@ describe('buffer utils', function() {
     });
     it('does a round trip', function() {
       expect(BufferUtil.integerAsSingleByteBuffer(
-        BufferUtil.integerFromSingleByteBuffer(new Buffer([255]))
+        BufferUtil.integerFromSingleByteBuffer(Buffer.from([255]))
       )[0]).to.equal(255);
     });
   });
@@ -129,7 +129,7 @@ describe('buffer utils', function() {
   describe('reverse', function() {
     it('reverses a buffer', function() {
       // http://bit.ly/1J2Ai4x
-      var original = new Buffer([255, 0, 128]);
+      var original = Buffer.from([255, 0, 128]);
       var reversed = BufferUtil.reverse(original);
       original[0].should.equal(reversed[2]);
       original[1].should.equal(reversed[1]);
-- 
2.19.0

