From 77bb5f9bf8aa55f8b8f864aa9bb1612adf36bd6a Mon Sep 17 00:00:00 2001
From: Daniel Cousens <github@dcousens.com>
Date: Tue, 21 Aug 2018 18:09:20 +1000
Subject: [PATCH 1/2] test/integration/addresses: add missing extra timeout

---
 test/integration/addresses.js | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/test/integration/addresses.js b/test/integration/addresses.js
index 412e792..9575201 100644
--- a/test/integration/addresses.js
+++ b/test/integration/addresses.js
@@ -102,6 +102,8 @@ describe('bitcoinjs-lib (addresses)', function () {
   })
 
   it('can support the retrieval of transactions for an address (via 3PBP)', function (done) {
+    this.timeout(30000)
+
     const keyPair = bitcoin.ECPair.makeRandom()
     const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey })
 

From ad6fa57a6dc919b19407d89392ed1895ccae49d0 Mon Sep 17 00:00:00 2001
From: Daniel Cousens <github@dcousens.com>
Date: Tue, 21 Aug 2018 18:11:35 +1000
Subject: [PATCH 2/2] 1 timeout to rule them all

---
 package.json                     |  2 +-
 test/integration/addresses.js    |  2 --
 test/integration/cltv.js         |  9 ---------
 test/integration/crypto.js       |  2 --
 test/integration/csv.js          |  5 -----
 test/integration/payments.js     |  2 --
 test/integration/transactions.js | 14 --------------
 7 files changed, 1 insertion(+), 35 deletions(-)

diff --git a/package.json b/package.json
index b9be434..a696033 100644
--- a/package.json
+++ b/package.json
@@ -17,7 +17,7 @@
     "coverage-report": "nyc report --reporter=lcov",
     "coverage-html": "nyc report --reporter=html",
     "coverage": "nyc --check-coverage --branches 90 --functions 90 mocha",
-    "integration": "mocha test/integration/",
+    "integration": "mocha --timeout 50000 test/integration/",
     "standard": "standard",
     "test": "npm run standard && npm run coverage",
     "unit": "mocha"
diff --git a/test/integration/addresses.js b/test/integration/addresses.js
index 9575201..412e792 100644
--- a/test/integration/addresses.js
+++ b/test/integration/addresses.js
@@ -102,8 +102,6 @@ describe('bitcoinjs-lib (addresses)', function () {
   })
 
   it('can support the retrieval of transactions for an address (via 3PBP)', function (done) {
-    this.timeout(30000)
-
     const keyPair = bitcoin.ECPair.makeRandom()
     const { address } = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey })
 
diff --git a/test/integration/cltv.js b/test/integration/cltv.js
index 626c7e9..0161588 100644
--- a/test/integration/cltv.js
+++ b/test/integration/cltv.js
@@ -12,7 +12,6 @@ const bob = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZs
 describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
   // force update MTP
   before(function (done) {
-    this.timeout(30000)
     regtestUtils.mine(11, done)
   })
 
@@ -41,8 +40,6 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
 
   // expiry past, {Alice's signature} OP_TRUE
   it('can create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the past)', function (done) {
-    this.timeout(30000)
-
     // 3 hours ago
     const lockTime = bip65.encode({ utc: utcNow() - (3600 * 3) })
     const redeemScript = cltvCheckSigOutput(alice, bob, lockTime)
@@ -86,8 +83,6 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
 
   // expiry will pass, {Alice's signature} OP_TRUE
   it('can create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the future)', function (done) {
-    this.timeout(30000)
-
     regtestUtils.height(function (err, height) {
       if (err) return done(err)
 
@@ -142,8 +137,6 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
 
   // expiry ignored, {Bob's signature} {Alice's signature} OP_FALSE
   it('can create (and broadcast via 3PBP) a Transaction where Alice and Bob can redeem the output at any time', function (done) {
-    this.timeout(30000)
-
     // two hours ago
     const lockTime = bip65.encode({ utc: utcNow() - (3600 * 2) })
     const redeemScript = cltvCheckSigOutput(alice, bob, lockTime)
@@ -188,8 +181,6 @@ describe('bitcoinjs-lib (transactions w/ CLTV)', function () {
 
   // expiry in the future, {Alice's signature} OP_TRUE
   it('can create (but fail to broadcast via 3PBP) a Transaction where Alice attempts to redeem before the expiry', function (done) {
-    this.timeout(30000)
-
     // two hours from now
     const lockTime = bip65.encode({ utc: utcNow() + (3600 * 2) })
     const redeemScript = cltvCheckSigOutput(alice, bob, lockTime)
diff --git a/test/integration/crypto.js b/test/integration/crypto.js
index 864f4e7..c0eb2e2 100644
--- a/test/integration/crypto.js
+++ b/test/integration/crypto.js
@@ -9,8 +9,6 @@ const tinysecp = require('tiny-secp256k1')
 
 describe('bitcoinjs-lib (crypto)', function () {
   it('can recover a private key from duplicate R values', function () {
-    this.timeout(30000)
-
     // https://blockchain.info/tx/f4c16475f2a6e9c602e4a287f9db3040e319eb9ece74761a4b84bc820fbeef50
     const tx = bitcoin.Transaction.fromHex('01000000020b668015b32a6178d8524cfef6dc6fc0a4751915c2e9b2ed2d2eab02424341c8000000006a47304402205e00298dc5265b7a914974c9d0298aa0e69a0ca932cb52a360436d6a622e5cd7022024bf5f506968f5f23f1835574d5afe0e9021b4a5b65cf9742332d5e4acb68f41012103fd089f73735129f3d798a657aaaa4aa62a00fa15c76b61fc7f1b27ed1d0f35b8ffffffffa95fa69f11dc1cbb77ef64f25a95d4b12ebda57d19d843333819d95c9172ff89000000006b48304502205e00298dc5265b7a914974c9d0298aa0e69a0ca932cb52a360436d6a622e5cd7022100832176b59e8f50c56631acbc824bcba936c9476c559c42a4468be98975d07562012103fd089f73735129f3d798a657aaaa4aa62a00fa15c76b61fc7f1b27ed1d0f35b8ffffffff02b000eb04000000001976a91472956eed9a8ecb19ae7e3ebd7b06cae4668696a788ac303db000000000001976a9146c0bd55dd2592287cd9992ce3ba3fc1208fb76da88ac00000000')
 
diff --git a/test/integration/csv.js b/test/integration/csv.js
index e0ad02f..ac250f5 100644
--- a/test/integration/csv.js
+++ b/test/integration/csv.js
@@ -12,7 +12,6 @@ const bob = bitcoin.ECPair.fromWIF('cMkopUXKWsEzAjfa1zApksGRwjVpJRB3831qM9W4gKZs
 describe('bitcoinjs-lib (transactions w/ CSV)', function () {
   // force update MTP
   before(function (done) {
-    this.timeout(30000)
     regtestUtils.mine(11, done)
   })
 
@@ -38,8 +37,6 @@ describe('bitcoinjs-lib (transactions w/ CSV)', function () {
 
   // expiry will pass, {Alice's signature} OP_TRUE
   it('can create (and broadcast via 3PBP) a Transaction where Alice can redeem the output after the expiry (in the future)', function (done) {
-    this.timeout(30000)
-
     regtestUtils.height(function (err, height) {
       if (err) return done(err)
 
@@ -99,8 +96,6 @@ describe('bitcoinjs-lib (transactions w/ CSV)', function () {
 
   // expiry in the future, {Alice's signature} OP_TRUE
   it('can create (but fail to broadcast via 3PBP) a Transaction where Alice attempts to redeem before the expiry', function (done) {
-    this.timeout(30000)
-
     // two hours after confirmation
     const sequence = bip68.encode({ seconds: 7168 })
     const p2sh = bitcoin.payments.p2sh({
diff --git a/test/integration/payments.js b/test/integration/payments.js
index d319f60..263111e 100644
--- a/test/integration/payments.js
+++ b/test/integration/payments.js
@@ -43,8 +43,6 @@ function buildAndSign (depends, prevOutput, redeemScript, witnessScript, done) {
   if (!output) throw new TypeError('Missing output')
 
   describe('bitcoinjs-lib (payments - ' + k + ')', function () {
-    this.timeout(30000)
-
     it('can broadcast as an output, and be spent as an input', (done) => {
       buildAndSign(depends, output, null, null, done)
     })
diff --git a/test/integration/transactions.js b/test/integration/transactions.js
index ef95d53..35f8ff2 100644
--- a/test/integration/transactions.js
+++ b/test/integration/transactions.js
@@ -45,8 +45,6 @@ describe('bitcoinjs-lib (transactions)', function () {
   })
 
   it('can create (and broadcast via 3PBP) a typical Transaction', function (done) {
-    this.timeout(30000)
-
     const alice1 = bitcoin.ECPair.makeRandom({ network: regtest })
     const alice2 = bitcoin.ECPair.makeRandom({ network: regtest })
     const aliceChange = bitcoin.ECPair.makeRandom({ network: regtest, rng: rng })
@@ -81,8 +79,6 @@ describe('bitcoinjs-lib (transactions)', function () {
   })
 
   it('can create (and broadcast via 3PBP) a Transaction with an OP_RETURN output', function (done) {
-    this.timeout(30000)
-
     const keyPair = bitcoin.ECPair.makeRandom({ network: regtest })
     const p2pkh = bitcoin.payments.p2pkh({ pubkey: keyPair.publicKey, network: regtest })
 
@@ -103,8 +99,6 @@ describe('bitcoinjs-lib (transactions)', function () {
   })
 
   it('can create (and broadcast via 3PBP) a Transaction, w/ a P2SH(P2MS(2 of 4)) (multisig) input', function (done) {
-    this.timeout(30000)
-
     const keyPairs = [
       bitcoin.ECPair.makeRandom({ network: regtest }),
       bitcoin.ECPair.makeRandom({ network: regtest }),
@@ -141,8 +135,6 @@ describe('bitcoinjs-lib (transactions)', function () {
   })
 
   it('can create (and broadcast via 3PBP) a Transaction, w/ a P2SH(P2WPKH) input', function (done) {
-    this.timeout(30000)
-
     const keyPair = bitcoin.ECPair.makeRandom({ network: regtest })
     const p2wpkh = bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey, network: regtest })
     const p2sh = bitcoin.payments.p2sh({ redeem: p2wpkh, network: regtest })
@@ -172,8 +164,6 @@ describe('bitcoinjs-lib (transactions)', function () {
   })
 
   it('can create (and broadcast via 3PBP) a Transaction, w/ a P2WPKH input', function (done) {
-    this.timeout(30000)
-
     const keyPair = bitcoin.ECPair.makeRandom({ network: regtest })
     const p2wpkh = bitcoin.payments.p2wpkh({ pubkey: keyPair.publicKey, network: regtest })
 
@@ -202,8 +192,6 @@ describe('bitcoinjs-lib (transactions)', function () {
   })
 
   it('can create (and broadcast via 3PBP) a Transaction, w/ a P2WSH(P2PK) input', function (done) {
-    this.timeout(30000)
-
     const keyPair = bitcoin.ECPair.makeRandom({ network: regtest })
     const p2pk = bitcoin.payments.p2pk({ pubkey: keyPair.publicKey, network: regtest })
     const p2wsh = bitcoin.payments.p2wsh({ redeem: p2pk, network: regtest })
@@ -233,8 +221,6 @@ describe('bitcoinjs-lib (transactions)', function () {
   })
 
   it('can create (and broadcast via 3PBP) a Transaction, w/ a P2SH(P2WSH(P2MS(3 of 4))) (SegWit multisig) input', function (done) {
-    this.timeout(50000)
-
     const keyPairs = [
       bitcoin.ECPair.makeRandom({ network: regtest }),
       bitcoin.ECPair.makeRandom({ network: regtest }),