tests: use strictEqual always

This commit is contained in:
Daniel Cousens 2015-05-07 11:29:20 +10:00
parent ab66c983af
commit ec9cea0cf1
19 changed files with 186 additions and 186 deletions

View file

@ -15,8 +15,8 @@ describe('Address', function () {
var hash = new Buffer(f.hash, 'hex') var hash = new Buffer(f.hash, 'hex')
var addr = new Address(hash, f.version) var addr = new Address(hash, f.version)
assert.equal(addr.version, f.version) assert.strictEqual(addr.version, f.version)
assert.equal(addr.hash.toString('hex'), f.hash) assert.strictEqual(addr.hash.toString('hex'), f.hash)
}) })
}) })
}) })
@ -26,8 +26,8 @@ describe('Address', function () {
it('imports ' + f.script + ' (' + f.network + ') correctly', function () { it('imports ' + f.script + ' (' + f.network + ') correctly', function () {
var addr = Address.fromBase58Check(f.base58check) var addr = Address.fromBase58Check(f.base58check)
assert.equal(addr.version, f.version) assert.strictEqual(addr.version, f.version)
assert.equal(addr.hash.toString('hex'), f.hash) assert.strictEqual(addr.hash.toString('hex'), f.hash)
}) })
}) })
@ -46,8 +46,8 @@ describe('Address', function () {
var script = Script.fromASM(f.script) var script = Script.fromASM(f.script)
var addr = Address.fromOutputScript(script, networks[f.network]) var addr = Address.fromOutputScript(script, networks[f.network])
assert.equal(addr.version, f.version) assert.strictEqual(addr.version, f.version)
assert.equal(addr.hash.toString('hex'), f.hash) assert.strictEqual(addr.hash.toString('hex'), f.hash)
}) })
}) })
@ -68,7 +68,7 @@ describe('Address', function () {
var addr = Address.fromBase58Check(f.base58check) var addr = Address.fromBase58Check(f.base58check)
var result = addr.toBase58Check() var result = addr.toBase58Check()
assert.equal(result, f.base58check) assert.strictEqual(result, f.base58check)
}) })
}) })
}) })
@ -79,7 +79,7 @@ describe('Address', function () {
var addr = Address.fromBase58Check(f.base58check) var addr = Address.fromBase58Check(f.base58check)
var script = addr.toOutputScript() var script = addr.toOutputScript()
assert.equal(script.toASM(), f.script) assert.strictEqual(script.toASM(), f.script)
}) })
}) })

View file

@ -34,14 +34,14 @@ describe('Bitcoin-core', function () {
var buffer = base58.decode(fb58) var buffer = base58.decode(fb58)
var actual = new Buffer(buffer).toString('hex') var actual = new Buffer(buffer).toString('hex')
assert.equal(actual, fhex) assert.strictEqual(actual, fhex)
}) })
it('can encode ' + fhex, function () { it('can encode ' + fhex, function () {
var buffer = new Buffer(fhex, 'hex') var buffer = new Buffer(fhex, 'hex')
var actual = base58.encode(buffer) var actual = base58.encode(buffer)
assert.equal(actual, fb58) assert.strictEqual(actual, fb58)
}) })
}) })
}) })
@ -66,8 +66,8 @@ describe('Bitcoin-core', function () {
it('can import ' + string, function () { it('can import ' + string, function () {
var address = Address.fromBase58Check(string) var address = Address.fromBase58Check(string)
assert.equal(address.hash.toString('hex'), hex) assert.strictEqual(address.hash.toString('hex'), hex)
assert.equal(address.version, network[typeMap[params.addrType]]) assert.strictEqual(address.version, network[typeMap[params.addrType]])
}) })
}) })
}) })
@ -105,12 +105,12 @@ describe('Bitcoin-core', function () {
var keyPair = ECPair.fromWIF(string) var keyPair = ECPair.fromWIF(string)
it('imports ' + string, function () { it('imports ' + string, function () {
assert.equal(keyPair.d.toHex(), hex) assert.strictEqual(keyPair.d.toHex(), hex)
assert.equal(keyPair.compressed, params.isCompressed) assert.strictEqual(keyPair.compressed, params.isCompressed)
}) })
it('exports ' + hex + ' to ' + string, function () { it('exports ' + hex + ' to ' + string, function () {
assert.equal(keyPair.toWIF(), string) assert.strictEqual(keyPair.toWIF(), string)
}) })
}) })
}) })
@ -140,8 +140,8 @@ describe('Bitcoin-core', function () {
it('fromHex can parse ' + f.id, function () { it('fromHex can parse ' + f.id, function () {
var block = Block.fromHex(f.hex) var block = Block.fromHex(f.hex)
assert.equal(block.getId(), f.id) assert.strictEqual(block.getId(), f.id)
assert.equal(block.transactions.length, f.transactions) assert.strictEqual(block.transactions.length, f.transactions)
}) })
}) })
}) })
@ -170,7 +170,7 @@ describe('Bitcoin-core', function () {
assert.deepEqual(txIn.hash, prevOutHash) assert.deepEqual(txIn.hash, prevOutHash)
// we read UInt32, not Int32 // we read UInt32, not Int32
assert.equal(txIn.index & 0xffffffff, prevOutIndex) assert.strictEqual(txIn.index & 0xffffffff, prevOutIndex)
}) })
}) })
}) })
@ -200,10 +200,10 @@ describe('Bitcoin-core', function () {
it('should hash ' + txHex.slice(0, 40) + '... (' + hashTypeName + ')', function () { it('should hash ' + txHex.slice(0, 40) + '... (' + hashTypeName + ')', function () {
var transaction = Transaction.fromHex(txHex) var transaction = Transaction.fromHex(txHex)
assert.equal(transaction.toHex(), txHex) assert.strictEqual(transaction.toHex(), txHex)
var script = Script.fromHex(scriptHex) var script = Script.fromHex(scriptHex)
assert.equal(script.toHex(), scriptHex) assert.strictEqual(script.toHex(), scriptHex)
var hash = transaction.hashForSignature(inIndex, script, hashType) var hash = transaction.hashForSignature(inIndex, script, hashType)
assert.deepEqual(hash, expectedHash) assert.deepEqual(hash, expectedHash)
@ -218,7 +218,7 @@ describe('Bitcoin-core', function () {
it('can parse ' + hex, function () { it('can parse ' + hex, function () {
var parsed = ECSignature.parseScriptSignature(buffer) var parsed = ECSignature.parseScriptSignature(buffer)
var actual = parsed.signature.toScriptSignature(parsed.hashType) var actual = parsed.signature.toScriptSignature(parsed.hashType)
assert.equal(actual.toString('hex'), hex) assert.strictEqual(actual.toString('hex'), hex)
}) })
}) })

View file

@ -12,12 +12,12 @@ describe('Block', function () {
it('imports the block: ' + f.description + ' correctly', function () { it('imports the block: ' + f.description + ' correctly', function () {
var block = Block.fromHex(f.hex) var block = Block.fromHex(f.hex)
assert.equal(block.version, f.version) assert.strictEqual(block.version, f.version)
assert.equal(block.prevHash.toString('hex'), f.prevHash) assert.strictEqual(block.prevHash.toString('hex'), f.prevHash)
assert.equal(block.merkleRoot.toString('hex'), f.merkleRoot) assert.strictEqual(block.merkleRoot.toString('hex'), f.merkleRoot)
assert.equal(block.timestamp, f.timestamp) assert.strictEqual(block.timestamp, f.timestamp)
assert.equal(block.bits, f.bits) assert.strictEqual(block.bits, f.bits)
assert.equal(block.nonce, f.nonce) assert.strictEqual(block.nonce, f.nonce)
}) })
}) })
@ -39,7 +39,7 @@ describe('Block', function () {
}) })
it('exports the block: ' + f.description + ' correctly', function () { it('exports the block: ' + f.description + ' correctly', function () {
assert.equal(block.toHex(), f.hex) assert.strictEqual(block.toHex(), f.hex)
}) })
}) })
}) })
@ -53,7 +53,7 @@ describe('Block', function () {
}) })
it('calculates ' + f.hash + ' for the block: ' + f.description, function () { it('calculates ' + f.hash + ' for the block: ' + f.description, function () {
assert.equal(block.getHash().toString('hex'), f.hash) assert.strictEqual(block.getHash().toString('hex'), f.hash)
}) })
}) })
}) })
@ -67,7 +67,7 @@ describe('Block', function () {
}) })
it('calculates ' + f.id + ' for the block: ' + f.description, function () { it('calculates ' + f.id + ' for the block: ' + f.description, function () {
assert.equal(block.getId(), f.id) assert.strictEqual(block.getId(), f.id)
}) })
}) })
}) })
@ -83,7 +83,7 @@ describe('Block', function () {
it('returns UTC date of ' + f.id, function () { it('returns UTC date of ' + f.id, function () {
var utcDate = block.getUTCDate().getTime() var utcDate = block.getUTCDate().getTime()
assert.equal(utcDate, f.timestamp * 1e3) assert.strictEqual(utcDate, f.timestamp * 1e3)
}) })
}) })
}) })

View file

@ -13,7 +13,7 @@ describe('bufferutils', function () {
var size = bufferutils.pushDataSize(f.dec) var size = bufferutils.pushDataSize(f.dec)
assert.equal(size, f.hexPD.length / 2) assert.strictEqual(size, f.hexPD.length / 2)
}) })
}) })
}) })
@ -27,9 +27,9 @@ describe('bufferutils', function () {
var d = bufferutils.readPushDataInt(buffer, 0) var d = bufferutils.readPushDataInt(buffer, 0)
var fopcode = parseInt(f.hexPD.substr(0, 2), 16) var fopcode = parseInt(f.hexPD.substr(0, 2), 16)
assert.equal(d.opcode, fopcode) assert.strictEqual(d.opcode, fopcode)
assert.equal(d.number, f.dec) assert.strictEqual(d.number, f.dec)
assert.equal(d.size, buffer.length) assert.strictEqual(d.size, buffer.length)
}) })
}) })
@ -40,7 +40,7 @@ describe('bufferutils', function () {
var buffer = new Buffer(f.hexPD, 'hex') var buffer = new Buffer(f.hexPD, 'hex')
var n = bufferutils.readPushDataInt(buffer, 0) var n = bufferutils.readPushDataInt(buffer, 0)
assert.equal(n, null) assert.strictEqual(n, null)
}) })
}) })
}) })
@ -51,7 +51,7 @@ describe('bufferutils', function () {
var buffer = new Buffer(f.hex64, 'hex') var buffer = new Buffer(f.hex64, 'hex')
var number = bufferutils.readUInt64LE(buffer, 0) var number = bufferutils.readUInt64LE(buffer, 0)
assert.equal(number, f.dec) assert.strictEqual(number, f.dec)
}) })
}) })
@ -72,8 +72,8 @@ describe('bufferutils', function () {
var buffer = new Buffer(f.hexVI, 'hex') var buffer = new Buffer(f.hexVI, 'hex')
var d = bufferutils.readVarInt(buffer, 0) var d = bufferutils.readVarInt(buffer, 0)
assert.equal(d.number, f.dec) assert.strictEqual(d.number, f.dec)
assert.equal(d.size, buffer.length) assert.strictEqual(d.size, buffer.length)
}) })
}) })
@ -106,7 +106,7 @@ describe('bufferutils', function () {
it('encodes ' + f.dec + ' correctly', function () { it('encodes ' + f.dec + ' correctly', function () {
var buffer = bufferutils.varIntBuffer(f.dec) var buffer = bufferutils.varIntBuffer(f.dec)
assert.equal(buffer.toString('hex'), f.hexVI) assert.strictEqual(buffer.toString('hex'), f.hexVI)
}) })
}) })
}) })
@ -116,7 +116,7 @@ describe('bufferutils', function () {
it('determines the varIntSize of ' + f.dec + ' correctly', function () { it('determines the varIntSize of ' + f.dec + ' correctly', function () {
var size = bufferutils.varIntSize(f.dec) var size = bufferutils.varIntSize(f.dec)
assert.equal(size, f.hexVI.length / 2) assert.strictEqual(size, f.hexVI.length / 2)
}) })
}) })
}) })
@ -130,7 +130,7 @@ describe('bufferutils', function () {
buffer.fill(0) buffer.fill(0)
var n = bufferutils.writePushDataInt(buffer, f.dec, 0) var n = bufferutils.writePushDataInt(buffer, f.dec, 0)
assert.equal(buffer.slice(0, n).toString('hex'), f.hexPD) assert.strictEqual(buffer.slice(0, n).toString('hex'), f.hexPD)
}) })
}) })
}) })
@ -142,7 +142,7 @@ describe('bufferutils', function () {
buffer.fill(0) buffer.fill(0)
bufferutils.writeUInt64LE(buffer, f.dec, 0) bufferutils.writeUInt64LE(buffer, f.dec, 0)
assert.equal(buffer.toString('hex'), f.hex64) assert.strictEqual(buffer.toString('hex'), f.hex64)
}) })
}) })
@ -165,7 +165,7 @@ describe('bufferutils', function () {
buffer.fill(0) buffer.fill(0)
var n = bufferutils.writeVarInt(buffer, f.dec, 0) var n = bufferutils.writeVarInt(buffer, f.dec, 0)
assert.equal(buffer.slice(0, n).toString('hex'), f.hexVI) assert.strictEqual(buffer.slice(0, n).toString('hex'), f.hexVI)
}) })
}) })

View file

@ -16,7 +16,7 @@ describe('Crypto', function () {
var data = new Buffer(f.hex, 'hex') var data = new Buffer(f.hex, 'hex')
var actual = fn(data).toString('hex') var actual = fn(data).toString('hex')
assert.equal(actual, expected) assert.strictEqual(actual, expected)
}) })
}) })
}) })

View file

@ -27,7 +27,7 @@ describe('ecdsa', function () {
var h1 = crypto.sha256(f.message) var h1 = crypto.sha256(f.message)
var k = ecdsa.deterministicGenerateK(curve, h1, d, checkSig) var k = ecdsa.deterministicGenerateK(curve, h1, d, checkSig)
assert.equal(k.toHex(), f.k) assert.strictEqual(k.toHex(), f.k)
}) })
}) })
@ -42,7 +42,7 @@ describe('ecdsa', function () {
var h1 = new Buffer(32) var h1 = new Buffer(32)
var k = ecdsa.deterministicGenerateK(curve, h1, d, checkSig) var k = ecdsa.deterministicGenerateK(curve, h1, d, checkSig)
assert.equal(k.toString(), '42') assert.strictEqual(k.toString(), '42')
})) }))
it('loops until a suitable signature is found', sinon.test(function () { it('loops until a suitable signature is found', sinon.test(function () {
@ -62,7 +62,7 @@ describe('ecdsa', function () {
var h1 = new Buffer(32) var h1 = new Buffer(32)
var k = ecdsa.deterministicGenerateK(curve, h1, d, checkSig) var k = ecdsa.deterministicGenerateK(curve, h1, d, checkSig)
assert.equal(k.toString(), '53') assert.strictEqual(k.toString(), '53')
})) }))
fixtures.valid.rfc6979.forEach(function (f) { fixtures.valid.rfc6979.forEach(function (f) {
@ -77,9 +77,9 @@ describe('ecdsa', function () {
return results.length === 16 return results.length === 16
}) })
assert.equal(results[0].toHex(), f.k0) assert.strictEqual(results[0].toHex(), f.k0)
assert.equal(results[1].toHex(), f.k1) assert.strictEqual(results[1].toHex(), f.k1)
assert.equal(results[15].toHex(), f.k15) assert.strictEqual(results[15].toHex(), f.k15)
}) })
}) })
}) })
@ -119,7 +119,7 @@ describe('ecdsa', function () {
var Qprime = ecdsa.recoverPubKey(curve, e, signature, i) var Qprime = ecdsa.recoverPubKey(curve, e, signature, i)
var QprimeHex = Qprime.getEncoded().toString('hex') var QprimeHex = Qprime.getEncoded().toString('hex')
assert.equal(QprimeHex, expectedHex) assert.strictEqual(QprimeHex, expectedHex)
}) })
}) })
}) })
@ -143,8 +143,8 @@ describe('ecdsa', function () {
var hash = crypto.sha256(f.message) var hash = crypto.sha256(f.message)
var signature = ecdsa.sign(curve, hash, d) var signature = ecdsa.sign(curve, hash, d)
assert.equal(signature.r.toString(), f.signature.r) assert.strictEqual(signature.r.toString(), f.signature.r)
assert.equal(signature.s.toString(), f.signature.s) assert.strictEqual(signature.s.toString(), f.signature.s)
}) })
}) })
@ -177,7 +177,7 @@ describe('ecdsa', function () {
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s)) var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
var Q = curve.G.multiply(d) var Q = curve.G.multiply(d)
assert.equal(ecdsa.verify(curve, H, signature, Q), false) assert.strictEqual(ecdsa.verify(curve, H, signature, Q), false)
}) })
}) })
}) })

View file

@ -18,7 +18,7 @@ describe('ECPair', function () {
it('defaults to compressed', function () { it('defaults to compressed', function () {
var keyPair = new ECPair(BigInteger.ONE) var keyPair = new ECPair(BigInteger.ONE)
assert.equal(keyPair.compressed, true) assert.strictEqual(keyPair.compressed, true)
}) })
it('supports the uncompressed option', function () { it('supports the uncompressed option', function () {
@ -26,7 +26,7 @@ describe('ECPair', function () {
compressed: false compressed: false
}) })
assert.equal(keyPair.compressed, false) assert.strictEqual(keyPair.compressed, false)
}) })
it('supports the network option', function () { it('supports the network option', function () {
@ -35,7 +35,7 @@ describe('ECPair', function () {
network: networks.testnet network: networks.testnet
}) })
assert.equal(keyPair.network, networks.testnet) assert.strictEqual(keyPair.network, networks.testnet)
}) })
it('throws if compressed option is not a bool', function () { it('throws if compressed option is not a bool', function () {
@ -70,7 +70,7 @@ describe('ECPair', function () {
compressed: f.compressed compressed: f.compressed
}) })
assert.equal(keyPair.getPublicKeyBuffer().toString('hex'), f.Q) assert.strictEqual(keyPair.getPublicKeyBuffer().toString('hex'), f.Q)
}) })
}) })
@ -105,9 +105,9 @@ describe('ECPair', function () {
it('imports ' + f.WIF + ' correctly', function () { it('imports ' + f.WIF + ' correctly', function () {
var keyPair = ECPair.fromWIF(f.WIF) var keyPair = ECPair.fromWIF(f.WIF)
assert.equal(keyPair.d.toString(), f.d) assert.strictEqual(keyPair.d.toString(), f.d)
assert.equal(keyPair.compressed, f.compressed) assert.strictEqual(keyPair.compressed, f.compressed)
assert.equal(keyPair.network, networks[f.network]) assert.strictEqual(keyPair.network, networks[f.network])
}) })
}) })
@ -126,7 +126,7 @@ describe('ECPair', function () {
var keyPair = ECPair.fromWIF(f.WIF) var keyPair = ECPair.fromWIF(f.WIF)
var result = keyPair.toWIF() var result = keyPair.toWIF()
assert.equal(result, f.WIF) assert.strictEqual(result, f.WIF)
}) })
}) })
}) })
@ -141,7 +141,7 @@ describe('ECPair', function () {
var ProxiedECPair = proxyquire('../src/ecpair', stub) var ProxiedECPair = proxyquire('../src/ecpair', stub)
var keyPair = ProxiedECPair.makeRandom() var keyPair = ProxiedECPair.makeRandom()
assert.equal(keyPair.toWIF(), exWIF) assert.strictEqual(keyPair.toWIF(), exWIF)
}) })
it('passes the options param', sinon.test(function () { it('passes the options param', sinon.test(function () {
@ -162,7 +162,7 @@ describe('ECPair', function () {
rng: function (size) { return d.slice(0, size) } rng: function (size) { return d.slice(0, size) }
}) })
assert.equal(keyPair.toWIF(), exWIF) assert.strictEqual(keyPair.toWIF(), exWIF)
}) })
}) })
@ -171,7 +171,7 @@ describe('ECPair', function () {
it('returns ' + f.address + ' for ' + f.WIF, function () { it('returns ' + f.address + ' for ' + f.WIF, function () {
var keyPair = ECPair.fromWIF(f.WIF) var keyPair = ECPair.fromWIF(f.WIF)
assert.equal(keyPair.getAddress().toString(), f.address) assert.strictEqual(keyPair.getAddress().toString(), f.address)
}) })
}) })
}) })

View file

@ -14,7 +14,7 @@ describe('ECSignature', function () {
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s)) var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
var buffer = signature.toCompact(f.compact.i, f.compact.compressed) var buffer = signature.toCompact(f.compact.i, f.compact.compressed)
assert.equal(buffer.toString('hex'), f.compact.hex) assert.strictEqual(buffer.toString('hex'), f.compact.hex)
}) })
}) })
}) })
@ -25,10 +25,10 @@ describe('ECSignature', function () {
var buffer = new Buffer(f.compact.hex, 'hex') var buffer = new Buffer(f.compact.hex, 'hex')
var parsed = ECSignature.parseCompact(buffer) var parsed = ECSignature.parseCompact(buffer)
assert.equal(parsed.compressed, f.compact.compressed) assert.strictEqual(parsed.compressed, f.compact.compressed)
assert.equal(parsed.i, f.compact.i) assert.strictEqual(parsed.i, f.compact.i)
assert.equal(parsed.signature.r.toString(), f.signature.r) assert.strictEqual(parsed.signature.r.toString(), f.signature.r)
assert.equal(parsed.signature.s.toString(), f.signature.s) assert.strictEqual(parsed.signature.s.toString(), f.signature.s)
}) })
}) })
@ -49,7 +49,7 @@ describe('ECSignature', function () {
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s)) var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
var DER = signature.toDER() var DER = signature.toDER()
assert.equal(DER.toString('hex'), f.DER) assert.strictEqual(DER.toString('hex'), f.DER)
}) })
}) })
}) })
@ -60,8 +60,8 @@ describe('ECSignature', function () {
var buffer = new Buffer(f.DER, 'hex') var buffer = new Buffer(f.DER, 'hex')
var signature = ECSignature.fromDER(buffer) var signature = ECSignature.fromDER(buffer)
assert.equal(signature.r.toString(), f.signature.r) assert.strictEqual(signature.r.toString(), f.signature.r)
assert.equal(signature.s.toString(), f.signature.s) assert.strictEqual(signature.s.toString(), f.signature.s)
}) })
}) })
@ -82,7 +82,7 @@ describe('ECSignature', function () {
var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s)) var signature = new ECSignature(new BigInteger(f.signature.r), new BigInteger(f.signature.s))
var scriptSignature = signature.toScriptSignature(f.scriptSignature.hashType) var scriptSignature = signature.toScriptSignature(f.scriptSignature.hashType)
assert.equal(scriptSignature.toString('hex'), f.scriptSignature.hex) assert.strictEqual(scriptSignature.toString('hex'), f.scriptSignature.hex)
}) })
}) })
@ -103,9 +103,9 @@ describe('ECSignature', function () {
var buffer = new Buffer(f.scriptSignature.hex, 'hex') var buffer = new Buffer(f.scriptSignature.hex, 'hex')
var parsed = ECSignature.parseScriptSignature(buffer) var parsed = ECSignature.parseScriptSignature(buffer)
assert.equal(parsed.signature.r.toString(), f.signature.r) assert.strictEqual(parsed.signature.r.toString(), f.signature.r)
assert.equal(parsed.signature.s.toString(), f.signature.s) assert.strictEqual(parsed.signature.s.toString(), f.signature.s)
assert.equal(parsed.hashType, f.scriptSignature.hashType) assert.strictEqual(parsed.hashType, f.scriptSignature.hashType)
}) })
}) })

View file

@ -66,8 +66,8 @@ describe('HDNode', function () {
var network = networks[f.network] var network = networks[f.network]
var hd = HDNode.fromSeedHex(f.master.seed, network) var hd = HDNode.fromSeedHex(f.master.seed, network)
assert.equal(hd.keyPair.toWIF(), f.master.wif) assert.strictEqual(hd.keyPair.toWIF(), f.master.wif)
assert.equal(hd.chainCode.toString('hex'), f.master.chainCode) assert.strictEqual(hd.chainCode.toString('hex'), f.master.chainCode)
}) })
}) })
@ -90,7 +90,7 @@ describe('HDNode', function () {
var network = networks[f.network] var network = networks[f.network]
var hd = HDNode.fromSeedHex(f.master.seed, network).neutered() var hd = HDNode.fromSeedHex(f.master.seed, network).neutered()
assert.equal(hd.toBase58(), f.master.base58) assert.strictEqual(hd.toBase58(), f.master.base58)
}) })
}) })
@ -99,7 +99,7 @@ describe('HDNode', function () {
var network = networks[f.network] var network = networks[f.network]
var hd = HDNode.fromSeedHex(f.master.seed, network) var hd = HDNode.fromSeedHex(f.master.seed, network)
assert.equal(hd.toBase58(), f.master.base58Priv) assert.strictEqual(hd.toBase58(), f.master.base58Priv)
}) })
}) })
}) })
@ -110,8 +110,8 @@ describe('HDNode', function () {
var network = networks[f.network] var network = networks[f.network]
var hd = HDNode.fromBase58(f.master.base58) var hd = HDNode.fromBase58(f.master.base58)
assert.equal(hd.toBase58(), f.master.base58) assert.strictEqual(hd.toBase58(), f.master.base58)
assert.equal(hd.keyPair.network, network) assert.strictEqual(hd.keyPair.network, network)
}) })
}) })
@ -120,8 +120,8 @@ describe('HDNode', function () {
var network = networks[f.network] var network = networks[f.network]
var hd = HDNode.fromBase58(f.master.base58Priv, network) var hd = HDNode.fromBase58(f.master.base58Priv, network)
assert.equal(hd.toBase58(), f.master.base58Priv) assert.strictEqual(hd.toBase58(), f.master.base58Priv)
assert.equal(hd.keyPair.network, network) assert.strictEqual(hd.keyPair.network, network)
}) })
}) })
@ -142,7 +142,7 @@ describe('HDNode', function () {
it('returns the identifier for ' + f.master.fingerprint, function () { it('returns the identifier for ' + f.master.fingerprint, function () {
var hd = HDNode.fromBase58(f.master.base58) var hd = HDNode.fromBase58(f.master.base58)
assert.equal(hd.getIdentifier().toString('hex'), f.master.identifier) assert.strictEqual(hd.getIdentifier().toString('hex'), f.master.identifier)
}) })
}) })
@ -152,7 +152,7 @@ describe('HDNode', function () {
it('returns the fingerprint for ' + f.master.fingerprint, function () { it('returns the fingerprint for ' + f.master.fingerprint, function () {
var hd = HDNode.fromBase58(f.master.base58) var hd = HDNode.fromBase58(f.master.base58)
assert.equal(hd.getFingerprint().toString('hex'), f.master.fingerprint) assert.strictEqual(hd.getFingerprint().toString('hex'), f.master.fingerprint)
}) })
}) })
@ -169,7 +169,7 @@ describe('HDNode', function () {
this.mock(hd.keyPair).expects('getAddress') this.mock(hd.keyPair).expects('getAddress')
.once().returns('foobar') .once().returns('foobar')
assert.equal(hd.getAddress(), 'foobar') assert.strictEqual(hd.getAddress(), 'foobar')
})) }))
}) })
@ -180,25 +180,25 @@ describe('HDNode', function () {
var hd = HDNode.fromBase58(f.master.base58) var hd = HDNode.fromBase58(f.master.base58)
var hdn = hd.neutered() var hdn = hd.neutered()
assert.equal(hdn.keyPair.d, null) assert.strictEqual(hdn.keyPair.d, undefined)
assert.equal(hdn.keyPair.Q, hd.keyPair.Q) assert.strictEqual(hdn.keyPair.Q, hd.keyPair.Q)
assert.equal(hdn.chainCode, hd.chainCode) assert.strictEqual(hdn.chainCode, hd.chainCode)
assert.equal(hdn.depth, hd.depth) assert.strictEqual(hdn.depth, hd.depth)
assert.equal(hdn.index, hd.index) assert.strictEqual(hdn.index, hd.index)
}) })
}) })
describe('derive', function () { describe('derive', function () {
function verifyVector (hd, v, depth) { function verifyVector (hd, v, depth) {
assert.equal(hd.keyPair.toWIF(), v.wif) assert.strictEqual(hd.keyPair.toWIF(), v.wif)
assert.equal(hd.keyPair.getPublicKeyBuffer().toString('hex'), v.pubKey) assert.strictEqual(hd.keyPair.getPublicKeyBuffer().toString('hex'), v.pubKey)
assert.equal(hd.chainCode.toString('hex'), v.chainCode) assert.strictEqual(hd.chainCode.toString('hex'), v.chainCode)
assert.equal(hd.depth, depth || 0) assert.strictEqual(hd.depth, depth || 0)
if (v.hardened) { if (v.hardened) {
assert.equal(hd.index, v.m + HDNode.HIGHEST_BIT) assert.strictEqual(hd.index, v.m + HDNode.HIGHEST_BIT)
} else { } else {
assert.equal(hd.index, v.m) assert.strictEqual(hd.index, v.m)
} }
} }
@ -227,7 +227,7 @@ describe('HDNode', function () {
var master = HDNode.fromBase58(f.master.base58Priv) var master = HDNode.fromBase58(f.master.base58Priv)
var child = master.derive(c.m).neutered() var child = master.derive(c.m).neutered()
assert.equal(child.toBase58(), c.base58) assert.strictEqual(child.toBase58(), c.base58)
}) })
it('works for Private -> public (neutered, hardened)', function () { it('works for Private -> public (neutered, hardened)', function () {
@ -237,7 +237,7 @@ describe('HDNode', function () {
var master = HDNode.fromBase58(f.master.base58Priv) var master = HDNode.fromBase58(f.master.base58Priv)
var child = master.deriveHardened(c.m).neutered() var child = master.deriveHardened(c.m).neutered()
assert.equal(child.toBase58(), c.base58) assert.strictEqual(child.toBase58(), c.base58)
}) })
it('works for Public -> public', function () { it('works for Public -> public', function () {
@ -247,7 +247,7 @@ describe('HDNode', function () {
var master = HDNode.fromBase58(f.master.base58) var master = HDNode.fromBase58(f.master.base58)
var child = master.derive(c.m) var child = master.derive(c.m)
assert.equal(child.toBase58(), c.base58) assert.strictEqual(child.toBase58(), c.base58)
}) })
it('throws on Public -> public (hardened)', function () { it('throws on Public -> public (hardened)', function () {

View file

@ -10,7 +10,7 @@ describe('bitcoinjs-lib (advanced)', function () {
var message = 'This is an example of a signed message.' var message = 'This is an example of a signed message.'
var signature = bitcoin.message.sign(keyPair, message) var signature = bitcoin.message.sign(keyPair, message)
assert.equal(signature.toString('base64'), 'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=') assert.strictEqual(signature.toString('base64'), 'G9L5yLFjti0QTHhPyFrZCT1V/MMnBtXKmoiKDZ78NDBjERki6ZTQZdSMCtkgoNmp17By9ItJr8o7ChX0XxY91nk=')
}) })
it('can verify a Bitcoin message', function () { it('can verify a Bitcoin message', function () {

View file

@ -13,7 +13,7 @@ describe('bitcoinjs-lib (basic)', function () {
var keyPair = bitcoin.ECPair.makeRandom({ rng: rng }) var keyPair = bitcoin.ECPair.makeRandom({ rng: rng })
var address = keyPair.getAddress().toString() var address = keyPair.getAddress().toString()
assert.equal(address, '1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64') assert.strictEqual(address, '1F5VhMHukdnUES9kfXqzPzMeF1GPHKiF64')
}) })
it('can generate an address from a SHA256 hash', function () { it('can generate an address from a SHA256 hash', function () {
@ -23,7 +23,7 @@ describe('bitcoinjs-lib (basic)', function () {
var keyPair = new bitcoin.ECPair(d) var keyPair = new bitcoin.ECPair(d)
var address = keyPair.getAddress().toString() var address = keyPair.getAddress().toString()
assert.equal(address, '1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8') assert.strictEqual(address, '1C7zdTfnkzmr13HfA2vNm5SJYRK6nEKyq8')
}) })
it('can generate a random keypair for alternative networks', function () { it('can generate a random keypair for alternative networks', function () {
@ -36,15 +36,15 @@ describe('bitcoinjs-lib (basic)', function () {
var wif = keyPair.toWIF() var wif = keyPair.toWIF()
var address = keyPair.getAddress().toString() var address = keyPair.getAddress().toString()
assert.equal(address, 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn') assert.strictEqual(address, 'LZJSxZbjqJ2XVEquqfqHg1RQTDdfST5PTn')
assert.equal(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS') assert.strictEqual(wif, 'T7A4PUSgTDHecBxW1ZiYFrDNRih2o7M8Gf9xpoCgudPF9gDiNvuS')
}) })
it('can import an address via WIF', function () { it('can import an address via WIF', function () {
var keyPair = bitcoin.ECPair.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct') var keyPair = bitcoin.ECPair.fromWIF('Kxr9tQED9H44gCmp6HAdmemAzU3n84H3dGkuWTKvE23JgHMW8gct')
var address = keyPair.getAddress().toString() var address = keyPair.getAddress().toString()
assert.equal(address, '19AAjaTUbRjQCMuVczepkoPswiZRhjtg31') assert.strictEqual(address, '19AAjaTUbRjQCMuVczepkoPswiZRhjtg31')
}) })
it('can create a Transaction', function () { it('can create a Transaction', function () {
@ -55,6 +55,6 @@ describe('bitcoinjs-lib (basic)', function () {
tx.addOutput('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000) tx.addOutput('1Gokm82v6DmtwKEB8AiVhm82hyFSsEvBDK', 15000)
tx.sign(0, keyPair) tx.sign(0, keyPair)
assert.equal(tx.build().toHex(), '0100000001313eb630b128102b60241ca895f1d0ffca2170d5a0990e094f2182c102ab94aa000000006b483045022100aefbcf847900b01dd3e3debe054d3b6d03d715d50aea8525f5ea3396f168a1fb022013d181d05b15b90111808b22ef4f9ebe701caf2ab48db269691fdf4e9048f4f60121029f50f51d63b345039a290c94bffd3180c99ed659ff6ea6b1242bca47eb93b59fffffffff01983a0000000000001976a914ad618cf4333b3b248f9744e8e81db2964d0ae39788ac00000000') assert.strictEqual(tx.build().toHex(), '0100000001313eb630b128102b60241ca895f1d0ffca2170d5a0990e094f2182c102ab94aa000000006b483045022100aefbcf847900b01dd3e3debe054d3b6d03d715d50aea8525f5ea3396f168a1fb022013d181d05b15b90111808b22ef4f9ebe701caf2ab48db269691fdf4e9048f4f60121029f50f51d63b345039a290c94bffd3180c99ed659ff6ea6b1242bca47eb93b59fffffffff01983a0000000000001976a914ad618cf4333b3b248f9744e8e81db2964d0ae39788ac00000000')
}) })
}) })

View file

@ -37,7 +37,7 @@ describe('bitcoinjs-lib (crypto)', function () {
// derived shared-secret address // derived shared-secret address
var address = new bitcoin.ECPair(null, QprimeS).getAddress().toString() var address = new bitcoin.ECPair(null, QprimeS).getAddress().toString()
assert.equal(address, '1EwCNJNZM5q58YPPTnjR1H5BvYRNeyZi47') assert.strictEqual(address, '1EwCNJNZM5q58YPPTnjR1H5BvYRNeyZi47')
}) })
// TODO // TODO
@ -87,7 +87,7 @@ describe('bitcoinjs-lib (crypto)', function () {
// now for the recovery // now for the recovery
var neuteredMaster = master.neutered() var neuteredMaster = master.neutered()
var recovered = recoverParent(neuteredMaster, child) var recovered = recoverParent(neuteredMaster, child)
assert.equal(recovered.toBase58(), master.toBase58()) assert.strictEqual(recovered.toBase58(), master.toBase58())
}) })
it('can recover a private key from duplicate R values', function () { it('can recover a private key from duplicate R values', function () {
@ -161,7 +161,7 @@ describe('bitcoinjs-lib (crypto)', function () {
var inputB = inputs[j] var inputB = inputs[j]
// enforce matching r values // enforce matching r values
assert.equal(inputA.signature.r.toString(), inputB.signature.r.toString()) assert.strictEqual(inputA.signature.r.toString(), inputB.signature.r.toString())
var r = inputA.signature.r var r = inputA.signature.r
var rInv = r.modInverse(n) var rInv = r.modInverse(n)
@ -181,7 +181,7 @@ describe('bitcoinjs-lib (crypto)', function () {
var d2 = ((s2.multiply(k).mod(n)).subtract(z2).mod(n)).multiply(rInv).mod(n) var d2 = ((s2.multiply(k).mod(n)).subtract(z2).mod(n)).multiply(rInv).mod(n)
// enforce matching private keys // enforce matching private keys
assert.equal(d1.toString(), d2.toString()) assert.strictEqual(d1.toString(), d2.toString())
} }
} }
}) })

View file

@ -16,9 +16,9 @@ describe('bitcoinjs-lib (multisig)', function () {
var redeemScript = bitcoin.scripts.multisigOutput(2, pubKeys) // 2 of 3 var redeemScript = bitcoin.scripts.multisigOutput(2, pubKeys) // 2 of 3
var scriptPubKey = bitcoin.scripts.scriptHashOutput(redeemScript.getHash()) var scriptPubKey = bitcoin.scripts.scriptHashOutput(redeemScript.getHash())
var address = bitcoin.Address.fromOutputScript(scriptPubKey) var address = bitcoin.Address.fromOutputScript(scriptPubKey).toString()
assert.equal(address, '36NUkt6FWUi3LAWBqWRdDmdTWbt91Yvfu7') assert.strictEqual(address, '36NUkt6FWUi3LAWBqWRdDmdTWbt91Yvfu7')
}) })
it('can spend from a 2-of-4 multsig P2SH address', function (done) { it('can spend from a 2-of-4 multsig P2SH address', function (done) {
@ -73,7 +73,7 @@ describe('bitcoinjs-lib (multisig)', function () {
blockchain.addresses.summary(targetAddress, function (err, result) { blockchain.addresses.summary(targetAddress, function (err, result) {
if (err) return done(err) if (err) return done(err)
assert.equal(result.balance, 1e4) assert.strictEqual(result.balance, 1e4)
done() done()
}) })
}) })

View file

@ -17,7 +17,7 @@ describe('message', function () {
var network = networks[f.network] var network = networks[f.network]
var actual = message.magicHash(f.message, network) var actual = message.magicHash(f.message, network)
assert.equal(actual.toString('hex'), f.magicHash) assert.strictEqual(actual.toString('hex'), f.magicHash)
}) })
}) })
}) })
@ -59,13 +59,13 @@ describe('message', function () {
compressed: false compressed: false
}) })
var signature = message.sign(keyPair, f.message, network) var signature = message.sign(keyPair, f.message, network)
assert.equal(signature.toString('base64'), f.signature) assert.strictEqual(signature.toString('base64'), f.signature)
if (f.compressed) { if (f.compressed) {
var compressedPrivKey = new ECPair(new BigInteger(f.d)) var compressedPrivKey = new ECPair(new BigInteger(f.d))
var compressedSignature = message.sign(compressedPrivKey, f.message) var compressedSignature = message.sign(compressedPrivKey, f.message)
assert.equal(compressedSignature.toString('base64'), f.compressed.signature) assert.strictEqual(compressedSignature.toString('base64'), f.compressed.signature)
} }
}) })
}) })

View file

@ -15,7 +15,7 @@ describe('networks', function () {
var extb58 = f.bip32[name] var extb58 = f.bip32[name]
it(extb58 + ' auto-detects ' + f.network, function () { it(extb58 + ' auto-detects ' + f.network, function () {
assert.equal(HDNode.fromBase58(extb58).keyPair.network, network) assert.strictEqual(HDNode.fromBase58(extb58).keyPair.network, network)
}) })
}) })
}) })

View file

@ -15,8 +15,8 @@ describe('Script', function () {
var chunks = [1] var chunks = [1]
var script = new Script(buffer, chunks) var script = new Script(buffer, chunks)
assert.equal(script.buffer, buffer) assert.strictEqual(script.buffer, buffer)
assert.equal(script.chunks, chunks) assert.strictEqual(script.chunks, chunks)
}) })
it('throws an error when input is not an array', function () { it('throws an error when input is not an array', function () {
@ -33,8 +33,8 @@ describe('Script', function () {
it('decodes/encodes ' + f.description, function () { it('decodes/encodes ' + f.description, function () {
var script = Script.fromASM(f.asm) var script = Script.fromASM(f.asm)
assert.equal(script.toASM(), f.asm) assert.strictEqual(script.toASM(), f.asm)
assert.equal(script.toHex(), f.hex) assert.strictEqual(script.toHex(), f.hex)
}) })
}) })
}) })
@ -44,8 +44,8 @@ describe('Script', function () {
it('decodes/encodes ' + f.description, function () { it('decodes/encodes ' + f.description, function () {
var script = Script.fromHex(f.hex) var script = Script.fromHex(f.hex)
assert.equal(script.toASM(), f.asm) assert.strictEqual(script.toASM(), f.asm)
assert.equal(script.toHex(), f.hex) assert.strictEqual(script.toHex(), f.hex)
}) })
}) })
}) })
@ -55,7 +55,7 @@ describe('Script', function () {
it('produces a HASH160 of ' + f.description, function () { it('produces a HASH160 of ' + f.description, function () {
var script = Script.fromHex(f.hex) var script = Script.fromHex(f.hex)
assert.equal(script.getHash().toString('hex'), f.hash) assert.strictEqual(script.getHash().toString('hex'), f.hash)
}) })
}) })
}) })
@ -71,7 +71,7 @@ describe('Script', function () {
opcodes.OP_EQUAL opcodes.OP_EQUAL
]) ])
assert.equal(script.toHex(), 'a920000000000000000000000000000000000000000000000000000000000000000087') assert.strictEqual(script.toHex(), 'a920000000000000000000000000000000000000000000000000000000000000000087')
}) })
}) })
@ -82,14 +82,14 @@ describe('Script', function () {
it('should return a script without the given value', function () { it('should return a script without the given value', function () {
var subScript = script.without(opcodes.OP_HASH160) var subScript = script.without(opcodes.OP_HASH160)
assert.equal(subScript.toHex(), '14e8c300c87986efa94c37c0519929019ef86eb5b487') assert.strictEqual(subScript.toHex(), '14e8c300c87986efa94c37c0519929019ef86eb5b487')
}) })
it('shouldnt mutate the original script', function () { it('shouldnt mutate the original script', function () {
var subScript = script.without(opcodes.OP_EQUAL) var subScript = script.without(opcodes.OP_EQUAL)
assert.notEqual(subScript.toHex(), hex) assert.notEqual(subScript.toHex(), hex)
assert.equal(script.toHex(), hex) assert.strictEqual(script.toHex(), hex)
}) })
}) })
}) })

View file

@ -22,7 +22,7 @@ describe('Scripts', function () {
var script = Script.fromASM(f.scriptSig) var script = Script.fromASM(f.scriptSig)
var type = scripts.classifyInput(script) var type = scripts.classifyInput(script)
assert.equal(type, f.type) assert.strictEqual(type, f.type)
}) })
}) })
@ -34,7 +34,7 @@ describe('Scripts', function () {
var script = Script.fromASM(f.scriptSig) var script = Script.fromASM(f.scriptSig)
var type = scripts.classifyInput(script, true) var type = scripts.classifyInput(script, true)
assert.equal(type, f.typeIncomplete) assert.strictEqual(type, f.typeIncomplete)
}) })
}) })
}) })
@ -47,7 +47,7 @@ describe('Scripts', function () {
var script = Script.fromASM(f.scriptPubKey) var script = Script.fromASM(f.scriptPubKey)
var type = scripts.classifyOutput(script) var type = scripts.classifyOutput(script)
assert.equal(type, f.type) assert.strictEqual(type, f.type)
}) })
}) })
}) })
@ -73,14 +73,14 @@ describe('Scripts', function () {
} }
it('returns ' + expected + ' for ' + f.scriptSig, function () { it('returns ' + expected + ' for ' + f.scriptSig, function () {
assert.equal(inputFn(script), expected) assert.strictEqual(inputFn(script), expected)
}) })
if (f.typeIncomplete) { if (f.typeIncomplete) {
var expectedIncomplete = type.toLowerCase() === f.typeIncomplete var expectedIncomplete = type.toLowerCase() === f.typeIncomplete
it('returns ' + expected + ' for ' + f.scriptSig, function () { it('returns ' + expected + ' for ' + f.scriptSig, function () {
assert.equal(inputFn(script, true), expectedIncomplete) assert.strictEqual(inputFn(script, true), expectedIncomplete)
}) })
} }
} }
@ -99,7 +99,7 @@ describe('Scripts', function () {
script = Script.fromHex(f.scriptSigHex) script = Script.fromHex(f.scriptSigHex)
} }
assert.equal(inputFn(script), false) assert.strictEqual(inputFn(script), false)
}) })
} }
}) })
@ -113,7 +113,7 @@ describe('Scripts', function () {
it('returns ' + expected + ' for ' + f.scriptPubKey, function () { it('returns ' + expected + ' for ' + f.scriptPubKey, function () {
var script = Script.fromASM(f.scriptPubKey) var script = Script.fromASM(f.scriptPubKey)
assert.equal(outputFn(script), expected) assert.strictEqual(outputFn(script), expected)
}) })
} }
}) })
@ -125,7 +125,7 @@ describe('Scripts', function () {
it('returns false for ' + f.description + ' (' + f.scriptPubKey + ')', function () { it('returns false for ' + f.description + ' (' + f.scriptPubKey + ')', function () {
var script = Script.fromASM(f.scriptPubKey) var script = Script.fromASM(f.scriptPubKey)
assert.equal(outputFn(script), false) assert.strictEqual(outputFn(script), false)
}) })
} }
}) })
@ -140,7 +140,7 @@ describe('Scripts', function () {
var signature = new Buffer(f.signature, 'hex') var signature = new Buffer(f.signature, 'hex')
var scriptSig = scripts.pubKeyInput(signature) var scriptSig = scripts.pubKeyInput(signature)
assert.equal(scriptSig.toASM(), f.scriptSig) assert.strictEqual(scriptSig.toASM(), f.scriptSig)
}) })
}) })
}) })
@ -152,7 +152,7 @@ describe('Scripts', function () {
it('returns ' + f.scriptPubKey, function () { it('returns ' + f.scriptPubKey, function () {
var pubKey = new Buffer(f.pubKey, 'hex') var pubKey = new Buffer(f.pubKey, 'hex')
var scriptPubKey = scripts.pubKeyOutput(pubKey) var scriptPubKey = scripts.pubKeyOutput(pubKey)
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
}) })
}) })
}) })
@ -167,7 +167,7 @@ describe('Scripts', function () {
var signature = new Buffer(f.signature, 'hex') var signature = new Buffer(f.signature, 'hex')
var scriptSig = scripts.pubKeyHashInput(signature, pubKey) var scriptSig = scripts.pubKeyHashInput(signature, pubKey)
assert.equal(scriptSig.toASM(), f.scriptSig) assert.strictEqual(scriptSig.toASM(), f.scriptSig)
}) })
}) })
}) })
@ -181,7 +181,7 @@ describe('Scripts', function () {
it('returns ' + f.scriptPubKey, function () { it('returns ' + f.scriptPubKey, function () {
var scriptPubKey = scripts.pubKeyHashOutput(address.hash) var scriptPubKey = scripts.pubKeyHashOutput(address.hash)
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
}) })
}) })
}) })
@ -196,7 +196,7 @@ describe('Scripts', function () {
}) })
var scriptSig = scripts.multisigInput(signatures) var scriptSig = scripts.multisigInput(signatures)
assert.equal(scriptSig.toASM(), f.scriptSig) assert.strictEqual(scriptSig.toASM(), f.scriptSig)
}) })
}) })
@ -223,7 +223,7 @@ describe('Scripts', function () {
var scriptPubKey = scripts.multisigOutput(pubKeys.length, pubKeys) var scriptPubKey = scripts.multisigOutput(pubKeys.length, pubKeys)
it('returns ' + f.scriptPubKey, function () { it('returns ' + f.scriptPubKey, function () {
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
}) })
}) })
@ -251,9 +251,9 @@ describe('Scripts', function () {
var scriptSig = scripts.scriptHashInput(redeemScriptSig, redeemScript) var scriptSig = scripts.scriptHashInput(redeemScriptSig, redeemScript)
if (f.scriptSig) { if (f.scriptSig) {
assert.equal(scriptSig.toASM(), f.scriptSig) assert.strictEqual(scriptSig.toASM(), f.scriptSig)
} else { } else {
assert.equal(scriptSig.toHex(), f.scriptSigHex) assert.strictEqual(scriptSig.toHex(), f.scriptSigHex)
} }
}) })
}) })
@ -268,7 +268,7 @@ describe('Scripts', function () {
var redeemScript = Script.fromASM(f.redeemScript) var redeemScript = Script.fromASM(f.redeemScript)
var scriptPubKey = scripts.scriptHashOutput(redeemScript.getHash()) var scriptPubKey = scripts.scriptHashOutput(redeemScript.getHash())
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
}) })
}) })
}) })
@ -281,7 +281,7 @@ describe('Scripts', function () {
var scriptPubKey = scripts.nullDataOutput(data) var scriptPubKey = scripts.nullDataOutput(data)
it('returns ' + f.scriptPubKey, function () { it('returns ' + f.scriptPubKey, function () {
assert.equal(scriptPubKey.toASM(), f.scriptPubKey) assert.strictEqual(scriptPubKey.toASM(), f.scriptPubKey)
}) })
}) })
}) })

View file

@ -48,7 +48,7 @@ describe('Transaction', function () {
it('imports ' + f.description + ' (' + f.id + ')', function () { it('imports ' + f.description + ' (' + f.id + ')', function () {
var actual = Transaction.fromHex(f.hex) var actual = Transaction.fromHex(f.hex)
assert.equal(actual.toHex(), f.hex, actual.toHex()) assert.strictEqual(actual.toHex(), f.hex, actual.toHex())
}) })
}) })
@ -66,7 +66,7 @@ describe('Transaction', function () {
it('exports ' + f.description + ' (' + f.id + ')', function () { it('exports ' + f.description + ' (' + f.id + ')', function () {
var actual = fromRaw(f.raw) var actual = fromRaw(f.raw)
assert.equal(actual.toHex(), f.hex, actual.toHex()) assert.strictEqual(actual.toHex(), f.hex, actual.toHex())
}) })
}) })
}) })
@ -87,22 +87,22 @@ describe('Transaction', function () {
it('returns an index', function () { it('returns an index', function () {
var tx = new Transaction() var tx = new Transaction()
assert.equal(tx.addInput(prevTxHash, 0), 0) assert.strictEqual(tx.addInput(prevTxHash, 0), 0)
assert.equal(tx.addInput(prevTxHash, 0), 1) assert.strictEqual(tx.addInput(prevTxHash, 0), 1)
}) })
it('defaults to DEFAULT_SEQUENCE', function () { it('defaults to DEFAULT_SEQUENCE', function () {
var tx = new Transaction() var tx = new Transaction()
tx.addInput(prevTxHash, 0) tx.addInput(prevTxHash, 0)
assert.equal(tx.ins[0].sequence, Transaction.DEFAULT_SEQUENCE) assert.strictEqual(tx.ins[0].sequence, Transaction.DEFAULT_SEQUENCE)
}) })
it('defaults to empty script', function () { it('defaults to empty script', function () {
var tx = new Transaction() var tx = new Transaction()
tx.addInput(prevTxHash, 0) tx.addInput(prevTxHash, 0)
assert.equal(tx.ins[0].script, Script.EMPTY) assert.strictEqual(tx.ins[0].script, Script.EMPTY)
}) })
fixtures.invalid.addInput.forEach(function (f) { fixtures.invalid.addInput.forEach(function (f) {
@ -120,8 +120,8 @@ describe('Transaction', function () {
describe('addOutput', function () { describe('addOutput', function () {
it('returns an index', function () { it('returns an index', function () {
var tx = new Transaction() var tx = new Transaction()
assert.equal(tx.addOutput(Script.EMPTY, 0), 0) assert.strictEqual(tx.addOutput(Script.EMPTY, 0), 0)
assert.equal(tx.addOutput(Script.EMPTY, 0), 1) assert.strictEqual(tx.addOutput(Script.EMPTY, 0), 1)
}) })
}) })
@ -149,7 +149,7 @@ describe('Transaction', function () {
it('should return the id for ' + f.id, function () { it('should return the id for ' + f.id, function () {
var tx = Transaction.fromHex(f.hex) var tx = Transaction.fromHex(f.hex)
assert.equal(tx.getId(), f.id) assert.strictEqual(tx.getId(), f.id)
}) })
}) })
}) })
@ -159,7 +159,7 @@ describe('Transaction', function () {
it('should return the hash for ' + f.id, function () { it('should return the hash for ' + f.id, function () {
var tx = Transaction.fromHex(f.hex) var tx = Transaction.fromHex(f.hex)
assert.equal(tx.getHash().toString('hex'), f.hash) assert.strictEqual(tx.getHash().toString('hex'), f.hash)
}) })
}) })
}) })

View file

@ -77,40 +77,40 @@ describe('TransactionBuilder', function () {
describe('addInput', function () { describe('addInput', function () {
it('accepts a txHash, index [and sequence number]', function () { it('accepts a txHash, index [and sequence number]', function () {
var vin = txb.addInput(prevTxHash, 1, 54) var vin = txb.addInput(prevTxHash, 1, 54)
assert.equal(vin, 0) assert.strictEqual(vin, 0)
var txIn = txb.tx.ins[0] var txIn = txb.tx.ins[0]
assert.equal(txIn.hash, prevTxHash) assert.strictEqual(txIn.hash, prevTxHash)
assert.equal(txIn.index, 1) assert.strictEqual(txIn.index, 1)
assert.equal(txIn.sequence, 54) assert.strictEqual(txIn.sequence, 54)
assert.equal(txb.inputs[0].prevOutScript, undefined) assert.strictEqual(txb.inputs[0].prevOutScript, undefined)
}) })
it('accepts a txHash, index [, sequence number and scriptPubKey]', function () { it('accepts a txHash, index [, sequence number and scriptPubKey]', function () {
var vin = txb.addInput(prevTxHash, 1, 54, prevTx.outs[1].script) var vin = txb.addInput(prevTxHash, 1, 54, prevTx.outs[1].script)
assert.equal(vin, 0) assert.strictEqual(vin, 0)
var txIn = txb.tx.ins[0] var txIn = txb.tx.ins[0]
assert.equal(txIn.hash, prevTxHash) assert.strictEqual(txIn.hash, prevTxHash)
assert.equal(txIn.index, 1) assert.strictEqual(txIn.index, 1)
assert.equal(txIn.sequence, 54) assert.strictEqual(txIn.sequence, 54)
assert.equal(txb.inputs[0].prevOutScript, prevTx.outs[1].script) assert.strictEqual(txb.inputs[0].prevOutScript, prevTx.outs[1].script)
}) })
it('accepts a prevTx, index [and sequence number]', function () { it('accepts a prevTx, index [and sequence number]', function () {
var vin = txb.addInput(prevTx, 1, 54) var vin = txb.addInput(prevTx, 1, 54)
assert.equal(vin, 0) assert.strictEqual(vin, 0)
var txIn = txb.tx.ins[0] var txIn = txb.tx.ins[0]
assert.deepEqual(txIn.hash, prevTxHash) assert.deepEqual(txIn.hash, prevTxHash)
assert.equal(txIn.index, 1) assert.strictEqual(txIn.index, 1)
assert.equal(txIn.sequence, 54) assert.strictEqual(txIn.sequence, 54)
assert.equal(txb.inputs[0].prevOutScript, prevTx.outs[1].script) assert.strictEqual(txb.inputs[0].prevOutScript, prevTx.outs[1].script)
}) })
it('returns the input index', function () { it('returns the input index', function () {
assert.equal(txb.addInput(prevTxHash, 0), 0) assert.strictEqual(txb.addInput(prevTxHash, 0), 0)
assert.equal(txb.addInput(prevTxHash, 1), 1) assert.strictEqual(txb.addInput(prevTxHash, 1), 1)
}) })
it('throws if SIGHASH_ALL has been used to sign any existing scriptSigs', function () { it('throws if SIGHASH_ALL has been used to sign any existing scriptSigs', function () {
@ -126,29 +126,29 @@ describe('TransactionBuilder', function () {
describe('addOutput', function () { describe('addOutput', function () {
it('accepts an address string and value', function () { it('accepts an address string and value', function () {
var vout = txb.addOutput(privAddress.toBase58Check(), 1000) var vout = txb.addOutput(privAddress.toBase58Check(), 1000)
assert.equal(vout, 0) assert.strictEqual(vout, 0)
var txout = txb.tx.outs[0] var txout = txb.tx.outs[0]
assert.deepEqual(txout.script, privScript) assert.deepEqual(txout.script, privScript)
assert.equal(txout.value, 1000) assert.strictEqual(txout.value, 1000)
}) })
it('accepts an Address object and value', function () { it('accepts an Address object and value', function () {
var vout = txb.addOutput(privAddress, 1000) var vout = txb.addOutput(privAddress, 1000)
assert.equal(vout, 0) assert.strictEqual(vout, 0)
var txout = txb.tx.outs[0] var txout = txb.tx.outs[0]
assert.deepEqual(txout.script, privScript) assert.deepEqual(txout.script, privScript)
assert.equal(txout.value, 1000) assert.strictEqual(txout.value, 1000)
}) })
it('accepts a ScriptPubKey and value', function () { it('accepts a ScriptPubKey and value', function () {
var vout = txb.addOutput(privScript, 1000) var vout = txb.addOutput(privScript, 1000)
assert.equal(vout, 0) assert.strictEqual(vout, 0)
var txout = txb.tx.outs[0] var txout = txb.tx.outs[0]
assert.deepEqual(txout.script, privScript) assert.deepEqual(txout.script, privScript)
assert.equal(txout.value, 1000) assert.strictEqual(txout.value, 1000)
}) })
it('throws if SIGHASH_ALL has been used to sign any existing scriptSigs', function () { it('throws if SIGHASH_ALL has been used to sign any existing scriptSigs', function () {
@ -196,7 +196,7 @@ describe('TransactionBuilder', function () {
construct(txb, f) construct(txb, f)
var tx = txb.build() var tx = txb.build()
assert.equal(tx.toHex(), f.txHex) assert.strictEqual(tx.toHex(), f.txHex)
}) })
}) })
@ -247,7 +247,7 @@ describe('TransactionBuilder', function () {
// rebuild/replace the scriptSig without them // rebuild/replace the scriptSig without them
var replacement = scripts.scriptHashInput(scripts.multisigInput(signatures), redeemScript) var replacement = scripts.scriptHashInput(scripts.multisigInput(signatures), redeemScript)
assert.equal(replacement.toASM(), sign.scriptSigFiltered) assert.strictEqual(replacement.toASM(), sign.scriptSigFiltered)
sign.scriptSigFiltered = replacement.toASM() sign.scriptSigFiltered = replacement.toASM()
tx.ins[i].script = replacement tx.ins[i].script = replacement
@ -264,12 +264,12 @@ describe('TransactionBuilder', function () {
tx = txb.buildIncomplete() tx = txb.buildIncomplete()
// now verify the serialized scriptSig is as expected // now verify the serialized scriptSig is as expected
assert.equal(tx.ins[i].script.toASM(), sign.scriptSig) assert.strictEqual(tx.ins[i].script.toASM(), sign.scriptSig)
}) })
}) })
tx = txb.build() tx = txb.build()
assert.equal(tx.toHex(), f.txHex) assert.strictEqual(tx.toHex(), f.txHex)
}) })
}) })
}) })
@ -280,7 +280,7 @@ describe('TransactionBuilder', function () {
var tx = Transaction.fromHex(f.txHex) var tx = Transaction.fromHex(f.txHex)
var txb = TransactionBuilder.fromTransaction(tx) var txb = TransactionBuilder.fromTransaction(tx)
assert.equal(txb.build().toHex(), f.txHex) assert.strictEqual(txb.build().toHex(), f.txHex)
}) })
}) })