From d94a4f3c04bf380b545264b9cb4fcbdf0000f242 Mon Sep 17 00:00:00 2001 From: Guten Ye Date: Tue, 26 Mar 2019 13:20:05 +0800 Subject: [PATCH] Move tests from MyMOneroCoreCpp.node.js to monero_utils.spec.js --- tests/MyMoneroCoreCpp.node.js | 14 -------------- tests/monero_utils.spec.js | 36 ++++++++++++++++++++++++++++++++++- 2 files changed, 35 insertions(+), 15 deletions(-) diff --git a/tests/MyMoneroCoreCpp.node.js b/tests/MyMoneroCoreCpp.node.js index 6f480ff..6a4daa8 100644 --- a/tests/MyMoneroCoreCpp.node.js +++ b/tests/MyMoneroCoreCpp.node.js @@ -133,20 +133,6 @@ function tests(Module) console.timeEnd("estimated_tx_network_fee") console.log("estimated_tx_network_fee ret", ret_string) } - { - console.time("estimate_fee") - const args = {"use_per_byte_fee": "true", "use_rct": "true", "n_inputs": "2", "mixin": "10", "n_outputs": "2","extra_size": "0", "bulletproof": "true", "base_fee": "24658", "fee_quantization_mask": "10000", "priority": "2", "fork_version": "10"} - const ret_string = Module.estimate_fee(JSON.stringify(args)) - console.timeEnd("estimate_fee") - console.log("estimate_fee ret", ret_string) - } - { - console.time("estimate_tx_weight") - const args = {"use_rct": "true", "n_inputs": "2", "mixin": "10", "n_outputs": "2","extra_size": "0", "bulletproof": "true"} - const ret_string = Module.estimate_tx_weight(JSON.stringify(args)) - console.timeEnd("estimate_tx_weight") - console.log("estimate_tx_weight ret", ret_string) - } { console.time("estimate_rct_tx_size") const args_str = '{"n_inputs":1,"mixin":10,"n_outputs":2,"extra_size":0,"bulletproof":true}' diff --git a/tests/monero_utils.spec.js b/tests/monero_utils.spec.js index ad3580b..bc46fa9 100644 --- a/tests/monero_utils.spec.js +++ b/tests/monero_utils.spec.js @@ -181,5 +181,39 @@ describe("cryptonote_utils tests", function() { "4501", // TODO: is this correct? ); }); - + it("estimate_fee", async function() { + const monero_utils = await require("../monero_utils/MyMoneroCoreBridge")({}) + var fee = monero_utils.estimate_fee({ + use_per_byte_fee: true, + use_rct: true, + n_inputs: 2, + mixin: 10, + n_outputs: 2, + extra_size: 0, + bulletproof: true, + base_fee: 24658, + fee_quantization_mask: 10000, + priority: 2, + fork_version: 10 + }); + assert.equal( + fee, + 330050000 + ); + }); + it("estimate_tx_weight", async function() { + const monero_utils = await require("../monero_utils/MyMoneroCoreBridge")({}) + var weight = monero_utils.estimate_tx_weight({ + use_rct: true, + n_inputs: 2, + mixin: 10, + n_outputs: 2, + extra_size: 0, + bulletproof: true, + }); + assert.equal( + weight, + 2677 + ); + }); });