From fba64bf3a433c9a5f55b4e43d6cba4f8ae79b9d7 Mon Sep 17 00:00:00 2001 From: 10gic <2391796+10gic@users.noreply.github.com> Date: Fri, 8 Nov 2024 17:47:07 +0800 Subject: [PATCH] Fix failed test cases --- .../trustwallet/core/app/utils/TestBech32.kt | 2 +- swift/Tests/Bech32Tests.swift | 4 ++-- wasm/tests/Bech32.test.ts | 18 ++---------------- 3 files changed, 5 insertions(+), 19 deletions(-) diff --git a/android/app/src/androidTest/java/com/trustwallet/core/app/utils/TestBech32.kt b/android/app/src/androidTest/java/com/trustwallet/core/app/utils/TestBech32.kt index 598823665db..64b32728c5c 100644 --- a/android/app/src/androidTest/java/com/trustwallet/core/app/utils/TestBech32.kt +++ b/android/app/src/androidTest/java/com/trustwallet/core/app/utils/TestBech32.kt @@ -1,6 +1,6 @@ package com.trustwallet.core.app.utils -import org.junit.Assert.assertEquals +import org.junit.Assert.* import org.junit.Test import wallet.core.jni.Bech32 diff --git a/swift/Tests/Bech32Tests.swift b/swift/Tests/Bech32Tests.swift index 42f67aa1547..e7f924113e9 100644 --- a/swift/Tests/Bech32Tests.swift +++ b/swift/Tests/Bech32Tests.swift @@ -13,7 +13,7 @@ class Bech32Tests: XCTestCase { } func testDecode() { - let decoded = Bech32.decode(string: "abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw") + let decoded = Bech32.decode(string: "abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw")! XCTAssertEqual(decoded.hexString, "00443214c74254b635cf84653a56d7c675be77df") } @@ -30,7 +30,7 @@ class Bech32Tests: XCTestCase { } func testDecodeM() { - let decoded = Bech32.decodeM(string: "abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx") + let decoded = Bech32.decodeM(string: "abcdef1l7aum6echk45nj3s0wdvt2fg8x9yrzpqzd3ryx")! XCTAssertEqual(decoded.hexString, "ffbbcdeb38bdab49ca307b9ac5a928398a418820") } diff --git a/wasm/tests/Bech32.test.ts b/wasm/tests/Bech32.test.ts index a98194b4021..f9ac76a0c9f 100644 --- a/wasm/tests/Bech32.test.ts +++ b/wasm/tests/Bech32.test.ts @@ -22,17 +22,10 @@ describe("Bech32", () => { assert.equal( HexCoding.encode(decoded), - "00443214c74254b635cf84653a56d7c675be77df" + "0x00443214c74254b635cf84653a56d7c675be77df" ); }); - it("test decode wrongChecksumVariant", () => { - const { Bech32 } = globalThis.core; - // This is a Bech32m variant, not Bech32 variant. So it should fail using Bech32 decoder. - const decoded = Bech32.decode("abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw"); - assert.isNull(decoded); - }); - it("test encodeM", () => { const { Bech32 } = globalThis.core; @@ -48,14 +41,7 @@ describe("Bech32", () => { assert.equal( HexCoding.encode(decoded), - "ffbbcdeb38bdab49ca307b9ac5a928398a418820" + "0xffbbcdeb38bdab49ca307b9ac5a928398a418820" ); }); - - it("test decode wrongChecksumVariant", () => { - const { Bech32 } = globalThis.core; - // This is a Bech32 variant, not Bech32m variant. So it should fail using Bech32M decoder. - const decoded = Bech32.decodeM("abcdef1qpzry9x8gf2tvdw0s3jn54khce6mua7lmqqqxw"); - assert.isNull(decoded); - }); });