diff --git a/test/address.js b/test/address.js index 50ff895..0e29f0d 100644 --- a/test/address.js +++ b/test/address.js @@ -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() diff --git a/test/fixtures/address.json b/test/fixtures/address.json index 28602bc..fff8d9a 100644 --- a/test/fixtures/address.json +++ b/test/fixtures/address.json @@ -1,36 +1,32 @@ { "valid": [ { - "description": "pubKeyHash", "network": "bitcoin", "version": 0, - "hex": "751e76e8199196d454941c45d1b3a323f1433bd6", + "hash": "751e76e8199196d454941c45d1b3a323f1433bd6", "base58check": "1BgGZ9tcN4rm9KBzDn7KprQz87SZ26SAMH", - "script": "76a914751e76e8199196d454941c45d1b3a323f1433bd688ac" + "script": "OP_DUP OP_HASH160 751e76e8199196d454941c45d1b3a323f1433bd6 OP_EQUALVERIFY OP_CHECKSIG" }, { - "description": "scriptHash", "network": "bitcoin", "version": 5, - "hex": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", + "hash": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", "base58check": "3LRW7jeCvQCRdPF8S3yUCfRAx4eqXFmdcr", - "script": "a914cd7b44d0b03f2d026d1e586d7ae18903b0d385f687" + "script": "OP_HASH160 cd7b44d0b03f2d026d1e586d7ae18903b0d385f6 OP_EQUAL" }, { - "description": "pubKeyHash", "network": "testnet", "version": 111, - "hex": "751e76e8199196d454941c45d1b3a323f1433bd6", + "hash": "751e76e8199196d454941c45d1b3a323f1433bd6", "base58check": "mrCDrCybB6J1vRfbwM5hemdJz73FwDBC8r", - "script": "76a914751e76e8199196d454941c45d1b3a323f1433bd688ac" + "script": "OP_DUP OP_HASH160 751e76e8199196d454941c45d1b3a323f1433bd6 OP_EQUALVERIFY OP_CHECKSIG" }, { - "description": "scriptHash", "network": "testnet", "version": 196, - "hex": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", + "hash": "cd7b44d0b03f2d026d1e586d7ae18903b0d385f6", "base58check": "2NByiBUaEXrhmqAsg7BbLpcQSAQs1EDwt5w", - "script": "a914cd7b44d0b03f2d026d1e586d7ae18903b0d385f687" + "script": "OP_HASH160 cd7b44d0b03f2d026d1e586d7ae18903b0d385f6 OP_EQUAL" } ], "invalid": { @@ -49,21 +45,21 @@ "fromOutputScript": [ { "description": "has no matching Address", - "hex": "21031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95ac" + "script": "031f1e68f82112b373f0fe980b3a89d212d2b5c01fb51eb25acb8b4c4b4299ce95 OP_CHECKSIG" }, { "description": "has no matching Address", - "hex": "5121032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca330162102308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a52ae" + "script": "OP_TRUE 032487c2a32f7c8d57d2a93906a6457afd00697925b0e6e145d89af6d3bca33016 02308673d16987eaa010e540901cc6fe3695e758c19f46ce604e174dac315e685a OP_2 OP_CHECKMULTISIG" }, { "description": "has no matching Address", - "hex": "6a2606deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474" + "script": "OP_RETURN 06deadbeef03f895a2ad89fb6d696497af486cb7c644a27aa568c7a18dd06113401115185474" } ], "toOutputScript": [ { "description": "24kPZCmVgzfkpGdXExy56234MRHrsqQxNWE has no matching Script", - "hex": "751e76e8199196d454941c45d1b3a323f1433bd6", + "hash": "751e76e8199196d454941c45d1b3a323f1433bd6", "version": 153 } ]