Browse Source

integration: fix script usage in integration tests

hk-custom-address
Daniel Cousens 10 years ago
parent
commit
1c92cfb373
  1. 2
      test/integration/advanced.js
  2. 8
      test/integration/crypto.js

2
test/integration/advanced.js

@ -55,7 +55,7 @@ describe('bitcoinjs-lib (advanced)', function () {
var actual = bitcoin.Transaction.fromHex(transaction.txHex)
var dataScript2 = actual.outs[0].script
var data2 = dataScript2.chunks[1]
var data2 = bitcoin.scripts.decompile(dataScript2)[1]
assert.deepEqual(dataScript, dataScript2)
assert.deepEqual(data, data2)

8
test/integration/crypto.js

@ -121,7 +121,9 @@ describe('bitcoinjs-lib (crypto)', function () {
inputs.forEach(function (input) {
var transaction = transactions[input.txId]
var script = transaction.ins[input.vout].script
assert(bitcoin.scripts.isPubKeyHashInput(script), 'Expected pubKeyHash script')
var scriptChunks = bitcoin.scripts.decompile(script)
assert(bitcoin.scripts.isPubKeyHashInput(scriptChunks), 'Expected pubKeyHash script')
var prevOutTxId = bitcoin.bufferutils.reverse(transaction.ins[input.vout].hash).toString('hex')
var prevVout = transaction.ins[input.vout].index
@ -133,8 +135,8 @@ describe('bitcoinjs-lib (crypto)', function () {
var prevOut = bitcoin.Transaction.fromHex(result.txHex)
var prevOutScript = prevOut.outs[prevVout].script
var scriptSignature = bitcoin.ECSignature.parseScriptSignature(script.chunks[0])
var publicKey = bitcoin.ECPair.fromPublicKeyBuffer(script.chunks[1])
var scriptSignature = bitcoin.ECSignature.parseScriptSignature(scriptChunks[0])
var publicKey = bitcoin.ECPair.fromPublicKeyBuffer(scriptChunks[1])
var m = transaction.hashForSignature(input.vout, prevOutScript, scriptSignature.hashType)
assert(publicKey.verify(m, scriptSignature.signature), 'Invalid m')

Loading…
Cancel
Save