Skip to content

Commit

Permalink
added encode tests
Browse files Browse the repository at this point in the history
  • Loading branch information
maraoz committed Mar 5, 2014
1 parent a2bd68f commit 63973b2
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 0 deletions.
8 changes: 8 additions & 0 deletions test/test.misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,12 @@ var bitcore = require('../bitcore');

var should = chai.should();

var test_data = require('./testdata');

var bignum = bitcore.bignum;
var base58 = bitcore.base58;
var base58Check = base58.base58Check;
var util = bitcore.util;

describe('Miscelaneous stuff', function() {
it('should initialze the config object', function() {
Expand Down Expand Up @@ -55,6 +58,11 @@ describe('Miscelaneous stuff', function() {
var m = '1QCJj1gPZKx2EwzGo9Ri8mMBs39STvDYcv';
base58Check.encode(base58Check.decode(m)).should.equal(m);
});
test_data.dataEncodeDecode.forEach(function(datum) {
it('base58 encode/decode checks ' + datum, function() {
base58.encode(new Buffer(datum[0], 'hex')).should.equal(datum[1]);
});
});

});

Expand Down
2 changes: 2 additions & 0 deletions test/testdata.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ var fs = require('fs');

var dataValid = JSON.parse(fs.readFileSync('test/data/base58_keys_valid.json'));
var dataInvalid = JSON.parse(fs.readFileSync('test/data/base58_keys_invalid.json'));
var dataEncodeDecode = JSON.parse(fs.readFileSync('test/data/base58_encode_decode.json'));

module.exports.dataValid = dataValid;
module.exports.dataInvalid = dataInvalid;
module.exports.dataEncodeDecode = dataEncodeDecode;

0 comments on commit 63973b2

Please sign in to comment.