Skip to content

Commit

Permalink
small cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
jprichardson committed Jun 6, 2014
1 parent 2f77304 commit af2288d
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
18 changes: 9 additions & 9 deletions test/coinstring.test.js
Expand Up @@ -8,7 +8,7 @@ describe('coinstring', function() {
fixtures.valid.forEach(function(f) {
it('should encode ' + f.description, function() {
var inp = new Buffer(f.hex, 'hex')
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')
assert.equal(cs.encode(inp, version), f.base58)
assert.equal(cs.encode([].slice.call(inp), version), f.base58)
assert.equal(cs.encode(new Uint8Array([].slice.call(inp)), version), f.base58)
Expand All @@ -19,7 +19,7 @@ describe('coinstring', function() {
describe('+ decode()', function() {
fixtures.valid.forEach(function(f) {
it('should decode ' + f.description, function() {
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')
assert.equal(cs.decode(f.base58, version).payload.toString('hex'), f.hex)
assert.equal(cs.decode(f.base58).payload.toString('hex'), f.hex)
})
Expand All @@ -29,7 +29,7 @@ describe('coinstring', function() {
fixtures.invalid.forEach(function(f) {
it(f.description + ' should throw an error', function() {
assert.throws(function() {
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')
assert(cs.decode(version, f.base58))
})
})
Expand All @@ -40,15 +40,15 @@ describe('coinstring', function() {
describe('+ isValid()', function() {
fixtures.valid.forEach(function(f) {
it('should validate ' + f.description, function() {
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')
assert(cs.isValid(f.base58, version))
})
})

describe('> when invalid input', function() {
fixtures.invalid.forEach(function(f) {
it(f.description + ' should return false', function() {
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')
assert(!cs.isValid(f.base58, version))
})
})
Expand All @@ -59,7 +59,7 @@ describe('coinstring', function() {
fixtures.valid.forEach(function(f) {
it('should create an encoder ' + f.description, function() {
var inp = new Buffer(f.hex, 'hex')
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')

var encode = cs.createEncoder(version)
assert.equal(encode(inp), f.base58)
Expand All @@ -71,7 +71,7 @@ describe('coinstring', function() {
fixtures.valid.forEach(function(f) {
it('should create a decoder ' + f.description, function() {
var inp = new Buffer(f.hex, 'hex')
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')

var decode = cs.createDecoder(version)
assert.equal(decode(f.base58).payload.toString('hex'), f.hex)
Expand All @@ -82,7 +82,7 @@ describe('coinstring', function() {
describe('+ createValidator()', function() {
fixtures.valid.forEach(function(f) {
it('should create a validator ' + f.description, function() {
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')
var isValid = cs.createValidator(version)
assert(isValid(f.base58))
})
Expand All @@ -91,7 +91,7 @@ describe('coinstring', function() {
describe('> when invalid input', function() {
fixtures.invalid.forEach(function(f) {
it(f.description + ' should return false', function() {
var version = parseInt(f.versionHex, '16')
var version = parseInt(f.version, '16')
var isValid = cs.createValidator(version)
assert(!isValid(f.base58))
})
Expand Down
24 changes: 12 additions & 12 deletions test/fixtures/coinstring.json
Expand Up @@ -3,71 +3,71 @@
{
"hex": "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd",
"base58": "5Hx15HFGyep2CfPxsJKe2fXJsCVn5DEiyoeGGF6JZjGbTRnqfiD",
"versionHex": "80",
"version": "0x80",
"description": "bitcoin private non-compressed key / wallet import format"
},
{
"hex": "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd01",
"base58": "KwomKti1X3tYJUUMb1TGSM2mrZk1wb1aHisUNHCQXTZq5auC2qc3",
"versionHex": "80",
"version": "0x80",
"description": "bitcoin private compressed key / wallet import format"
},
{
"hex": "3c176e659bea0f29a3e9bf7880c112b1b31b4dc8",
"base58": "16UjcYNBG9GTK4uq2f7yYEbuifqCzoLMGS",
"versionHex": "00",
"version": "0x00",
"description": "bitcoin hash160 / address"
},
{
"hex": "a1c2f92a9dacbd2991c3897724a93f338e44bdc1",
"base58": "1FkKMsKNJqWSDvTvETqcCeHcUQQ64kSC6s",
"versionHex": "00",
"version": "0x00",
"description": "bitcoin hash160 / address"
},
{
"hex": "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd",
"base58": "6JGLNEiEYR6pFGq84gwceHWYLcyKaLWzaymVajjCPPUEGAR2MTT",
"versionHex": "9E",
"version": "0x9E",
"description": "dogecoin private non-compressed key / wallet import format"
},
{
"hex": "1184cd2cdd640ca42cfc3a091c51d549b2f016d454b2774019c2b2d2e08529fd01",
"base58": "QPCgUjWzmfNfXzsQBHJ4KZsPKbmaz99PAyZP9ubFFpBBXWuSQh6n",
"versionHex": "9E",
"version": "0x9E",
"description": "dogecoin private compressed key / wallet import format"
},
{
"hex": "3c176e659bea0f29a3e9bf7880c112b1b31b4dc8",
"base58": "DAcq9oJpZZAjr56RmF7Y5zmWboZWQ4HAsW",
"versionHex": "1E",
"version": "0x1E",
"description": "dogecoin hash160 / address"
},
{
"hex": "a1c2f92a9dacbd2991c3897724a93f338e44bdc1",
"base58": "DKtQu8G1cFQikveWy3qAkQTDMY8PKVU18Z",
"versionHex": "1E",
"version": "0x1E",
"description": "dogecoin hash160 / address"
}
],
"invalid": [
{
"base58": "16ujcynbg9gtk4uq2f7yyebuifqczolmgs",
"versionHex": "00",
"version": "0x00",
"description": "lowercase"
},
{
"base58": "5hx15hfgyep2cfpxsjke2fxjscvn5deiyoeggf6jzjgbtrnqfid",
"versionHex": "80",
"version": "0x80",
"description": "lowercase"
},
{
"base58": "16ujcynbg9gtk4uq2f7yyebuifqczolmgs",
"versionHex": "01",
"version": "0x01",
"description": "invalid version"
},
{
"base58": "5hx15hfgyep2cfpxsjke2fxjscvn5deiyoeggf6jzjgbtrnqfid",
"versionHex": "02",
"version": "0x02",
"description": "invalid version"
}
]
Expand Down

0 comments on commit af2288d

Please sign in to comment.