From f440f37cbfd91ebac2b5e811faf61cfc1119bd64 Mon Sep 17 00:00:00 2001 From: yse Date: Mon, 16 Feb 2026 10:34:59 +0100 Subject: [PATCH] tests: wallet: add encoding test for list_transactions request This adds a test to verify that the `getTransactionList` behaves as expected when passing a nil and not-nil type as argument. Signed-off-by: Hydra Yse --- damusTests/WalletConnectTests.swift | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/damusTests/WalletConnectTests.swift b/damusTests/WalletConnectTests.swift index f8651484..d4600985 100644 --- a/damusTests/WalletConnectTests.swift +++ b/damusTests/WalletConnectTests.swift @@ -206,4 +206,31 @@ final class WalletConnectTests: XCTestCase { XCTFail("Decoded to the wrong case") } } + + func testEncodingListTransactionsType() throws { + func encoded_request_with_type(type: String?) throws -> String { + let request = WalletConnect.Request.getTransactionList( + from: nil, + until: nil, + limit: nil, + offset: nil, + unpaid: nil, + type: type, + ) + let encodedData = try JSONEncoder().encode(request) + return String(data: encodedData, encoding: .utf8)! + } + + var encodedRequest = try encoded_request_with_type(type: nil) + XCTAssertFalse(encodedRequest.contains("\"type\"")) + + encodedRequest = try encoded_request_with_type(type: "") + XCTAssertTrue(encodedRequest.contains("\"type\":\"\"")) + + encodedRequest = try encoded_request_with_type(type: "incoming") + XCTAssertTrue(encodedRequest.contains("\"type\":\"incoming\"")) + + encodedRequest = try encoded_request_with_type(type: "outgoing") + XCTAssertTrue(encodedRequest.contains("\"type\":\"outgoing\"")) + } }