From 39ae1ccd9dd83c33a259e1cc0b0e2d805a1f8ba2 Mon Sep 17 00:00:00 2001 From: lts372005 <87189679+lts372005@users.noreply.github.com> Date: Sat, 30 Oct 2021 09:34:09 +0700 Subject: [PATCH] Unit Test Utils: iconHashToBigInt iconBigIntToHash --- tests/local.ts | 1 + tests/util/hash.ts | 30 ++++++++++++++++++++++++++++++ 2 files changed, 31 insertions(+) create mode 100644 tests/util/hash.ts diff --git a/tests/local.ts b/tests/local.ts index 738eda31b..5858743f4 100644 --- a/tests/local.ts +++ b/tests/local.ts @@ -1,3 +1,4 @@ import "./local/snowflake.ts"; import "./util/validateLength.ts"; import "./util/hasProperty.ts"; +import "./util/hash.ts"; diff --git a/tests/util/hash.ts b/tests/util/hash.ts new file mode 100644 index 000000000..0a2562bd2 --- /dev/null +++ b/tests/util/hash.ts @@ -0,0 +1,30 @@ +import { iconHashToBigInt, iconBigintToHash } from "../../src/util/hash.ts"; +import { assertEquals } from "../deps.ts"; +const iconHash = "4bbb271a13f7195031adcc06a2d867ce"; +const iconBigInt = 3843769888406823508519992434416504301518n; +const a_iconHash = "a_4bbb271a13f7195031adcc06a2d867ce"; +const a_iconBigInt = 3503487521485885045056617826984736090062n; +Deno.test({ + name: "[utils] icon hash to bigint", + fn() { + assertEquals(iconHashToBigInt(iconHash), iconBigInt); + }, +}); +Deno.test({ + name: "[utils] icon bigint to hash", + fn() { + assertEquals(iconBigintToHash(iconBigInt), iconHash); + }, +}); +Deno.test({ + name: "[utils] icon hash to bigint a_ (animated)", + fn() { + assertEquals(iconHashToBigInt(a_iconHash), a_iconBigInt); + }, +}); +Deno.test({ + name: "[utils] icon bigint to hash a_ (animated)", + fn() { + assertEquals(iconBigintToHash(a_iconBigInt), a_iconHash); + }, +});