From 22366e04c4276a7f3fbbc467438fa856bbb070b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Fri, 11 Jun 2021 11:13:15 +0200 Subject: [PATCH 1/2] fixexs for JS --- c/src/verifier/btc/rpc.yml | 12 +++--------- wasm/src/in3_util.js | 5 ++--- 2 files changed, 5 insertions(+), 12 deletions(-) diff --git a/c/src/verifier/btc/rpc.yml b/c/src/verifier/btc/rpc.yml index f97f894de..74dd4cb02 100644 --- a/c/src/verifier/btc/rpc.yml +++ b/c/src/verifier/btc/rpc.yml @@ -562,8 +562,8 @@ btc: cmdParams: -x -c btc -f 8 request: - 'f3c06e17b04ef748ce6604ad68e5b9f68ca96914b57c2118a1bb9a09a194ddaf' - - true - - '000000000000000000103b2395f6cd94221b10d02eb9be5850303c0534307220' + # - true + # - '000000000000000000103b2395f6cd94221b10d02eb9be5850303c0534307220' response: in_active_chain: true txid: f3c06e17b04ef748ce6604ad68e5b9f68ca96914b57c2118a1bb9a09a194ddaf @@ -671,10 +671,6 @@ btc: getdifficulty: descr: Returns the proof-of-work difficulty as a multiple of the minimum difficulty. - params: - blocknumber: - type: uint64 - descr: 'Can be the number of a certain block to get its difficulty. To get the difficulty of the latest block use `latest`, `earliest`, `pending` or leave `params` empty (Hint: Latest block always means `actual latest block` minus `in3.finality`)' in3Params: finality: descr: defines the amount of finality headers @@ -687,7 +683,7 @@ btc: type: bool result: - type: uint256 + type: double descr: | - `blocknumber` is a certain number: the difficulty of this block - `blocknumber` is `latest`, `earliest`, `pending` or empty: the difficulty of the latest block (`actual latest block` minus `in3.finality`) @@ -733,8 +729,6 @@ btc: in3Params: finality: 8 cmdParams: -x -c btc -f 8 - request: - - 631910 response: 15138043247082.88 in3: proof: diff --git a/wasm/src/in3_util.js b/wasm/src/in3_util.js index 729574fa7..7c963c4e7 100644 --- a/wasm/src/in3_util.js +++ b/wasm/src/in3_util.js @@ -347,10 +347,9 @@ function toNumber(val) { case 'string': return parseInt(val) case 'undefined': - case 'null': - return 0 + return undefined default: - if (!val) return 0 + if (!val) return val if (val.readBigInt64BE) //nodejs Buffer return val.length == 0 ? 0 : parseInt(toMinHex(val)) else if (val.redIMul) From f2a1a901beee0845a290499e92a091ed8ba5395a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20K=C3=BCchler?= Date: Fri, 11 Jun 2021 12:39:27 +0200 Subject: [PATCH 2/2] updated toNumber test --- wasm/test/testUtil.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wasm/test/testUtil.js b/wasm/test/testUtil.js index 47254579d..41a317b10 100644 --- a/wasm/test/testUtil.js +++ b/wasm/test/testUtil.js @@ -163,8 +163,8 @@ describe('Util-Tests', () => { assert.equal(0, IN3.util.toNumber(false)) assert.equal(65535, IN3.util.toNumber(65535n)) assert.equal(65535, IN3.util.toNumber("65535")) - assert.equal(0, IN3.util.toNumber(undefined)) - assert.equal(0, IN3.util.toNumber(null)) + assert.equal(undefined, IN3.util.toNumber(undefined)) + assert.equal(null, IN3.util.toNumber(null)) assert.equal(97, IN3.util.toNumber(Buffer.from('a', 'utf8'))) assert.equal(255, IN3.util.toNumber("0xff")) assert.Throw(() => IN3.util.toNumber({}))