JS: Add support for parsing and encoding base58.

This commit is contained in:
Arthur Britto
2012-10-22 16:15:58 -07:00
parent 485f1aab13
commit c5dce0e270
3 changed files with 161 additions and 34 deletions

View File

@@ -1,5 +1,9 @@
var buster = require("buster");
var jsbn = require('../js/jsbn.js');
var BigInteger = jsbn.BigInteger;
var nbi = jsbn.nbi;
var amount = require("../js/amount.js");
var Amount = require("../js/amount.js").Amount;
var UInt160 = require("../js/amount.js").UInt160;
@@ -7,10 +11,19 @@ var UInt160 = require("../js/amount.js").UInt160;
buster.testCase("Amount", {
"UInt160" : {
"Parse 0" : function () {
buster.assert.equals(0, UInt160.from_json("0").value);
buster.assert.equals(nbi(), UInt160.from_json("0").value);
},
"Parse 0 export" : function () {
buster.assert.equals(amount.consts.hex_xns, UInt160.from_json("0").to_json());
buster.assert.equals(amount.consts.address_xns, UInt160.from_json("0").to_json());
},
"Parse 1" : function () {
buster.assert.equals(new BigInteger([1]), UInt160.from_json("1").value);
},
"Parse rrrrrrrrrrrrrrrrrrrrrhoLvTp export" : function () {
buster.assert.equals(amount.consts.address_xns, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrrhoLvTp").to_json());
},
"Parse rrrrrrrrrrrrrrrrrrrrBZbvji export" : function () {
buster.assert.equals(amount.consts.address_one, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrBZbvji").to_json());
},
},
"Amount parsing" : {