From 71f8b4fc2c0a3a5095611b71a67eb1b29584d495 Mon Sep 17 00:00:00 2001 From: Bo Yao Date: Fri, 30 Sep 2022 21:34:01 +0800 Subject: [PATCH] Fix #247 (#249) * reproduce issue 247 in tests * fix issue 247 * format --- cli/post-install.js | 2 +- tests/__tests__/test_context_api.ava.js | 13 ++++++++++++- tests/src/context_api.js | 2 +- 3 files changed, 14 insertions(+), 3 deletions(-) diff --git a/cli/post-install.js b/cli/post-install.js index bbc1db80..d87998b7 100644 --- a/cli/post-install.js +++ b/cli/post-install.js @@ -37,7 +37,7 @@ await executeCommand(`rm ${BINARYEN_TAR_NAME}`); console.log("Installing QuickJS..."); -const QUICK_JS_VERSION = `0.1.1`; +const QUICK_JS_VERSION = `0.1.2`; const QUICK_JS_VERSION_TAG = `v${QUICK_JS_VERSION}`; const QUICK_JS_SYSTEM_NAME = OS === "Linux" ? "Linux" : OS === "Darwin" ? "macOS" : "other"; diff --git a/tests/__tests__/test_context_api.ava.js b/tests/__tests__/test_context_api.ava.js index 7479c3cd..ee49173f 100644 --- a/tests/__tests__/test_context_api.ava.js +++ b/tests/__tests__/test_context_api.ava.js @@ -103,7 +103,18 @@ test("get attached deposit", async (t) => { let r = await carl.call(contextApiContract, "get_attached_deposit", "", { attachedDeposit: 3, }); - t.is(r, 3); + t.is(r, "3"); + + for (let i = 1; i <= 10; i++) { + // 1 NEAR, 2 NEAR, ..., 10 NEAR + let r = await carl.call( + contextApiContract, + "get_attached_deposit", + {}, + { attachedDeposit: i.toString() + "000000000000000000000000" } + ); + t.is(r, i.toString() + "000000000000000000000000"); + } }); test("get prepaid gas", async (t) => { diff --git a/tests/src/context_api.js b/tests/src/context_api.js index e34084ae..9560fcdd 100644 --- a/tests/src/context_api.js +++ b/tests/src/context_api.js @@ -37,7 +37,7 @@ export function get_epoch_height() { } export function get_attached_deposit() { - near.valueReturn(near.attachedDeposit()); + near.valueReturn(JSON.stringify(near.attachedDeposit().toString())); } export function get_prepaid_gas() {