add tests for checkEncode and checkDecode

This commit is contained in:
Wei Lu 2014-03-06 17:19:35 +08:00
parent 78c257ff9b
commit bf1be94fe3

View file

@ -19,4 +19,31 @@ describe('base58', function() {
assert.equal(base58.encode(conv.hexToBytes(hex)), enc); assert.equal(base58.encode(conv.hexToBytes(hex)), enc);
}) })
}) })
describe('checkEncode', function() {
it('handles known examples', function() {
var input = [
171, 210, 178, 125, 2, 16, 86, 184, 248, 88, 235,
163, 244, 160, 83, 156, 184, 186, 45, 167, 169, 164,
67, 125, 163, 89, 106, 243, 207, 193, 149, 206
]
var vbyte = 239
assert.equal(base58.checkEncode(input, vbyte),
'92tb9mjz6q9eKZjYvLsgk87kPrMoh7BGRumSzPeUGhmigtsfrbP');
})
})
describe('checkDecode', function() {
it('handles known examples', function() {
var input = '1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa'
var expected = [
98, 233, 7, 177, 92, 191, 39, 213, 66, 83,
153, 235, 246, 240, 251, 80, 235, 184, 143, 24
];
expected.version = 0
assert.deepEqual(base58.checkDecode(input), expected);
})
})
}) })