|
|
@ -10,22 +10,22 @@ describe('Address', function() { |
|
|
|
describe('Constructor', function() { |
|
|
|
it('does not mutate the input', function() { |
|
|
|
fixtures.valid.forEach(function(f) { |
|
|
|
var hash = new Buffer(f.hex, 'hex') |
|
|
|
var hash = new Buffer(f.hash, 'hex') |
|
|
|
var addr = new Address(hash, f.version) |
|
|
|
|
|
|
|
assert.equal(addr.version, f.version) |
|
|
|
assert.equal(addr.hash.toString('hex'), f.hex) |
|
|
|
assert.equal(addr.hash.toString('hex'), f.hash) |
|
|
|
}) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
describe('fromBase58Check', function() { |
|
|
|
fixtures.valid.forEach(function(f) { |
|
|
|
it('imports ' + f.description + '(' + f.network + ') correctly', function() { |
|
|
|
it('imports ' + f.script + ' (' + f.network + ') correctly', function() { |
|
|
|
var addr = Address.fromBase58Check(f.base58check) |
|
|
|
|
|
|
|
assert.equal(addr.version, f.version) |
|
|
|
assert.equal(addr.hash.toString('hex'), f.hex) |
|
|
|
assert.equal(addr.hash.toString('hex'), f.hash) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
@ -40,18 +40,18 @@ describe('Address', function() { |
|
|
|
|
|
|
|
describe('fromOutputScript', function() { |
|
|
|
fixtures.valid.forEach(function(f) { |
|
|
|
it('imports ' + f.description + '(' + f.network + ') correctly', function() { |
|
|
|
var script = Script.fromHex(f.script) |
|
|
|
it('imports ' + f.script + ' (' + f.network + ') correctly', function() { |
|
|
|
var script = Script.fromASM(f.script) |
|
|
|
var addr = Address.fromOutputScript(script, networks[f.network]) |
|
|
|
|
|
|
|
assert.equal(addr.version, f.version) |
|
|
|
assert.equal(addr.hash.toString('hex'), f.hex) |
|
|
|
assert.equal(addr.hash.toString('hex'), f.hash) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
fixtures.invalid.fromOutputScript.forEach(function(f) { |
|
|
|
it('throws when ' + f.description, function() { |
|
|
|
var script = Script.fromHex(f.hex) |
|
|
|
var script = Script.fromASM(f.script) |
|
|
|
|
|
|
|
assert.throws(function() { |
|
|
|
Address.fromOutputScript(script) |
|
|
@ -62,7 +62,7 @@ describe('Address', function() { |
|
|
|
|
|
|
|
describe('toBase58Check', function() { |
|
|
|
fixtures.valid.forEach(function(f) { |
|
|
|
it('exports ' + f.description + '(' + f.network + ') correctly', function() { |
|
|
|
it('exports ' + f.script + ' (' + f.network + ') correctly', function() { |
|
|
|
var addr = Address.fromBase58Check(f.base58check) |
|
|
|
var result = addr.toBase58Check() |
|
|
|
|
|
|
@ -73,17 +73,17 @@ describe('Address', function() { |
|
|
|
|
|
|
|
describe('toOutputScript', function() { |
|
|
|
fixtures.valid.forEach(function(f) { |
|
|
|
it('imports ' + f.description + '(' + f.network + ') correctly', function() { |
|
|
|
it('imports ' + f.script + ' (' + f.network + ') correctly', function() { |
|
|
|
var addr = Address.fromBase58Check(f.base58check) |
|
|
|
var script = addr.toOutputScript() |
|
|
|
|
|
|
|
assert.equal(script.toHex(), f.script) |
|
|
|
assert.equal(script.toASM(), f.script) |
|
|
|
}) |
|
|
|
}) |
|
|
|
|
|
|
|
fixtures.invalid.toOutputScript.forEach(function(f) { |
|
|
|
it('throws when ' + f.description, function() { |
|
|
|
var addr = new Address(new Buffer(f.hex, 'hex'), f.version) |
|
|
|
var addr = new Address(new Buffer(f.hash, 'hex'), f.version) |
|
|
|
|
|
|
|
assert.throws(function() { |
|
|
|
addr.toOutputScript() |
|
|
|