Browse Source

add toAddress and getOutType tests to script

hk-custom-address
Wei Lu 11 years ago
parent
commit
423124966f
  1. 23
      test/script.js

23
test/script.js

@ -49,6 +49,29 @@ describe('Script', function() {
assert.equal(Address(sha256ripe160(hexToBytes(redeemScript)),network).toString(),
multiSigAddress)
})
})
describe('getOutType', function() {
it('works for p2sh', function() {
var script = Script.fromHex("a914e8c300c87986efa84c37c0519929019ef86eb5b487")
assert.equal(script.getOutType(), 'P2SH')
})
it('works for pubkey', function() {
var script = Script.fromHex("76a9145a3acbc7bbcc97c5ff16f5909c9d7d3fadb293a888ac")
assert.equal(script.getOutType(), 'Pubkey')
})
})
describe('toAddress', function() {
it('works for p2sh type output', function() {
var script = Script.fromHex("a914e8c300c87986efa84c37c0519929019ef86eb5b487")
assert.equal(script.toAddress(), '3NukJ6fYZJ5Kk8bPjycAnruZkE5Q7UW7i8')
})
it('works for pubkey type output', function() {
var script = Script.fromHex("76a9145a3acbc7bbcc97c5ff16f5909c9d7d3fadb293a888ac")
assert.equal(script.toAddress(), '19E6FV3m3kEPoJD5Jz6dGKdKwTVvjsWUvu')
})
})
})

Loading…
Cancel
Save