fix: rehydrate serialized BigNumber dishes

This commit is contained in:
cyphercodes 2026-06-26 06:32:49 +03:00
parent bd4c59cf34
commit 25fb514990
2 changed files with 11 additions and 1 deletions

View File

@ -292,7 +292,7 @@ class Dish {
and reinitialise it as a BigNumber object. and reinitialise it as a BigNumber object.
*/ */
if (Object.keys(this.value).sort().equals(["c", "e", "s"])) { if (Object.keys(this.value).sort().equals(["c", "e", "s"])) {
const temp = new BigNumber(); const temp = new BigNumber(0);
temp.c = this.value.c; temp.c = this.value.c;
temp.e = this.value.e; temp.e = this.value.e;
temp.s = this.value.s; temp.s = this.value.s;

View File

@ -9,4 +9,14 @@ TestRegister.addApiTests([
assert(dish.presentAs); assert(dish.presentAs);
}), }),
it("Dish - isValid: rehydrates serialized BigNumber values", () => {
const dish = new Dish({ c: [1], e: 0, s: 1 }, Dish.BIG_NUMBER);
assert.strictEqual(dish.value.toString(), "1");
}),
it("Dish - isValid: rehydrates serialized NaN BigNumber values", () => {
const dish = new Dish({ c: null, e: null, s: null }, Dish.BIG_NUMBER);
assert.strictEqual(dish.value.toString(), "NaN");
}),
]); ]);