From ff4a6f549d8ccf9a350bdc7d9df74032dff90d23 Mon Sep 17 00:00:00 2001 From: Braydon Fuller Date: Mon, 5 Jan 2015 23:27:20 -0500 Subject: [PATCH] Fixed bugs in IE11 --- lib/address.js | 6 ++++-- lib/script/script.js | 5 ++--- test/hdkeycache.js | 2 ++ test/mocha.opts | 1 + test/paymentprotocol/index.js | 2 ++ test/transaction/transaction.js | 1 + test/util/preconditions.js | 3 ++- 7 files changed, 14 insertions(+), 6 deletions(-) diff --git a/lib/address.js b/lib/address.js index b773f9d..118d011 100644 --- a/lib/address.js +++ b/lib/address.js @@ -100,15 +100,17 @@ function Address(data, network, type) { * @returns {Object} An "info" object with "type", "network", and "hashBuffer" */ Address.prototype._classifyArguments = function(data, network, type) { + var PublicKey = require('./publickey'); + var Script = require('./script'); /* jshint maxcomplexity: 10 */ // transform and validate input data if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 20) { return Address._transformHash(data); } else if ((data instanceof Buffer || data instanceof Uint8Array) && data.length === 21) { return Address._transformBuffer(data, network, type); - } else if (data.constructor && (data.constructor.name && data.constructor.name === 'PublicKey')) { + } else if (data instanceof PublicKey) { return Address._transformPublicKey(data); - } else if (data.constructor && (data.constructor.name && data.constructor.name === 'Script')) { + } else if (data instanceof Script) { return Address._transformScript(data, network); } else if (typeof(data) === 'string') { return Address._transformString(data, network, type); diff --git a/lib/script/script.js b/lib/script/script.js index f7820cb..c06d636 100644 --- a/lib/script/script.js +++ b/lib/script/script.js @@ -177,7 +177,6 @@ Script.fromString = function(str) { Script.prototype.toString = function() { var str = ''; - for (var i = 0; i < this.chunks.length; i++) { var chunk = this.chunks[i]; var opcodenum = chunk.opcodenum; @@ -459,7 +458,7 @@ Script.prototype._addByType = function(obj, prepend) { this._addOpcode(obj, prepend); } else if (typeof obj === 'number') { this._addOpcode(obj, prepend); - } else if (obj.constructor && obj.constructor.name && obj.constructor.name === 'Opcode') { + } else if (obj instanceof Opcode) { this._addOpcode(obj, prepend); } else if (BufferUtil.isBuffer(obj)) { this._addBuffer(obj, prepend); @@ -484,7 +483,7 @@ Script.prototype._addOpcode = function(opcode, prepend) { var op; if (typeof opcode === 'number') { op = opcode; - } else if (opcode.constructor && opcode.constructor.name && opcode.constructor.name === 'Opcode') { + } else if (opcode instanceof Opcode) { op = opcode.toNumber(); } else { op = Opcode(opcode).toNumber(); diff --git a/test/hdkeycache.js b/test/hdkeycache.js index 57635d4..db1f4fc 100644 --- a/test/hdkeycache.js +++ b/test/hdkeycache.js @@ -8,6 +8,8 @@ var HDPrivateKey = bitcore.HDPrivateKey; var xprivkey = 'xprv9s21ZrQH143K3QTDL4LXw2F7HEK3wJUD2nW2nRk4stbPy6cq3jPPqjiChkVvvNKmPGJxWUtg6LnF5kejMRNNU3TGtRBeJgk33yuGBxrMPHi'; describe('HDKey cache', function() { + this.timeout(10000); + /* jshint unused: false */ var cache = bitcore._HDKeyCache; var master = new HDPrivateKey(xprivkey); diff --git a/test/mocha.opts b/test/mocha.opts index 4a52320..9409cf5 100644 --- a/test/mocha.opts +++ b/test/mocha.opts @@ -1 +1,2 @@ --recursive +--timeout 5000 diff --git a/test/paymentprotocol/index.js b/test/paymentprotocol/index.js index 17fd076..4ba58ca 100644 --- a/test/paymentprotocol/index.js +++ b/test/paymentprotocol/index.js @@ -279,6 +279,8 @@ var bitpayRequest = new Buffer('' describe('PaymentProtocol', function() { + this.timeout(15000); + it('should be able to create class', function() { should.exist(PaymentProtocol); }); diff --git a/test/transaction/transaction.js b/test/transaction/transaction.js index 742be1e..2aeeaa8 100644 --- a/test/transaction/transaction.js +++ b/test/transaction/transaction.js @@ -84,6 +84,7 @@ describe('Transaction', function() { }); describe('transaction creation test vector', function() { + this.timeout(5000); var index = 0; transactionVector.forEach(function(vector) { index++; diff --git a/test/util/preconditions.js b/test/util/preconditions.js index 5db9bb9..74a727f 100644 --- a/test/util/preconditions.js +++ b/test/util/preconditions.js @@ -52,7 +52,8 @@ describe('preconditions', function() { $.checkArgumentType(1, PrivateKey); } catch (e) { error = e; - e.message.should.equal('Invalid Argument for (unknown name), expected PrivateKey but got number'); + var fail = !(~e.message.indexOf('Invalid Argument for (unknown name)')); + fail.should.equal(false); } should.exist(error); });