mirror of
https://github.com/Xahau/xahau.js.git
synced 2025-11-20 12:15:51 +00:00
JS: Fix UInt160 comparison.
This commit is contained in:
committed by
Stefan Thomas
parent
c0eec780de
commit
45c54b6484
@@ -152,7 +152,7 @@ UInt160.prototype.copyTo = function(d) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
UInt160.prototype.equals = function(d) {
|
UInt160.prototype.equals = function(d) {
|
||||||
return this.value === d.value;
|
return isNaN(this.value) || isNaN(d.value) ? false : this.value.equals(d.value);
|
||||||
};
|
};
|
||||||
|
|
||||||
// value = NaN on error.
|
// value = NaN on error.
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ var nbi = jsbn.nbi;
|
|||||||
|
|
||||||
var amount = require("../js/amount.js");
|
var amount = require("../js/amount.js");
|
||||||
var Amount = require("../js/amount.js").Amount;
|
var Amount = require("../js/amount.js").Amount;
|
||||||
var UInt160 = require("../js/amount.js").UInt160;
|
var UInt160 = require("../js/amount.js").UInt160;
|
||||||
|
|
||||||
|
var config = require('./config.js');
|
||||||
|
|
||||||
buster.testCase("Amount", {
|
buster.testCase("Amount", {
|
||||||
"UInt160" : {
|
"UInt160" : {
|
||||||
@@ -25,8 +27,14 @@ buster.testCase("Amount", {
|
|||||||
"Parse rrrrrrrrrrrrrrrrrrrrBZbvji export" : function () {
|
"Parse rrrrrrrrrrrrrrrrrrrrBZbvji export" : function () {
|
||||||
buster.assert.equals(amount.consts.address_one, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrBZbvji").to_json());
|
buster.assert.equals(amount.consts.address_one, UInt160.from_json("rrrrrrrrrrrrrrrrrrrrBZbvji").to_json());
|
||||||
},
|
},
|
||||||
|
"Parse mtgox export" : function () {
|
||||||
|
buster.assert.equals(config.accounts["mtgox"].account, UInt160.from_json("mtgox").to_json());
|
||||||
|
},
|
||||||
},
|
},
|
||||||
"Amount parsing" : {
|
"Amount parsing" : {
|
||||||
|
"Parse 800/USD/mtgox" : function () {
|
||||||
|
buster.assert.equals("800/USD/"+config.accounts["mtgox"].account, Amount.from_json("800/USD/mtgox").to_text_full());
|
||||||
|
},
|
||||||
"Parse native 0" : function () {
|
"Parse native 0" : function () {
|
||||||
buster.assert.equals("0/XNS", Amount.from_json("0").to_text_full());
|
buster.assert.equals("0/XNS", Amount.from_json("0").to_text_full());
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user