From c013492c4d192deeb6f02857a305a097fd585abf Mon Sep 17 00:00:00 2001 From: Dudi Edri Date: Tue, 2 May 2023 19:53:43 +0300 Subject: [PATCH] Fix Tx Submission Tests with Error Handling --- src/test/MainnetService.test.ts | 19 ++++++++++--------- src/test/PreprodService.test.ts | 16 +++++++++------- src/test/PreviewService.test.ts | 16 +++++++++------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/src/test/MainnetService.test.ts b/src/test/MainnetService.test.ts index 10017ef..3b41865 100644 --- a/src/test/MainnetService.test.ts +++ b/src/test/MainnetService.test.ts @@ -137,13 +137,14 @@ describe("koiosTransactionsService", () => { console.log(result) expect(result).not.toBe(null) }); - test("submitTransaction", async () => { - const uint8 = new Uint8Array([0]) - let result - result = await koiosTransactionsService.submitTransaction(uint8) - expect(result).toBeInstanceOf(KoiosHttpError) - expect(result).not.toBe(null) - expect(result.statusCode).toBe(400) + test("submitTransactionBadRequest", async () => { + try { + await koiosTransactionsService.submitTransaction(new Uint8Array([0])) + } catch (e) { + expect(e).toBeInstanceOf(KoiosHttpError) + expect(e).not.toBe(null) + expect(e.statusCode).toBe(400) + } }); test("getTransactionStatus", async () => { const txHashes = [ @@ -243,7 +244,7 @@ describe("koiosAssetService", () => { console.log(result) expect(result).not.toBe(null) }); - test("getPolicyAssetAddressList", async () => { + test("mainnetGetPolicyAssetAddressList", async () => { const result = await koiosAssetService.getPolicyAssetAddressList("750900e4999ebe0d58f19b634768ba25e525aaf12403bfe8fe130501") console.log(result) expect(result).not.toBe(null) @@ -334,7 +335,7 @@ describe("koiosPoolService", () => { }); describe("koiosScriptService", () => { - test("getNativeScriptList", async () => { + test("mainnetGetNativeScriptList", async () => { const result = await koiosScriptService.getNativeScriptList() console.log(result) expect(result).not.toBe(null) diff --git a/src/test/PreprodService.test.ts b/src/test/PreprodService.test.ts index 6f7ea00..0a2a9ab 100644 --- a/src/test/PreprodService.test.ts +++ b/src/test/PreprodService.test.ts @@ -1,4 +1,4 @@ -import {BackendFactory} from "../index"; +import {BackendFactory, KoiosHttpError} from "../index"; import {describe, expect, test} from "vitest"; const koiosPreprodService = BackendFactory.getKoiosPreprodService() @@ -122,12 +122,14 @@ describe("koiosTransactionsService", () => { console.log(result) expect(result).not.toBe(null) }); - test("submitTransaction", async () => { - const uint8 = new Uint8Array([0]) - const result = await koiosTransactionsService.submitTransaction(uint8) - console.log(result) - expect(result).not.toBe(null) - expect(result.statusCode).toBe(400) + test("submitTransactionBadRequest", async () => { + try { + await koiosTransactionsService.submitTransaction(new Uint8Array([0])) + } catch (e) { + expect(e).toBeInstanceOf(KoiosHttpError) + expect(e).not.toBe(null) + expect(e.statusCode).toBe(400) + } }); test("getTransactionStatus", async () => { const txHashes = [ diff --git a/src/test/PreviewService.test.ts b/src/test/PreviewService.test.ts index 4078adb..2ce2445 100644 --- a/src/test/PreviewService.test.ts +++ b/src/test/PreviewService.test.ts @@ -9,7 +9,7 @@ import { LogicalOperatorFilter, LogicalOperatorFilterType, NotOperatorFilter, - SortType, + SortType, KoiosHttpError, } from "../index"; import {describe, expect, test} from "vitest"; @@ -142,12 +142,14 @@ describe("koiosTransactionsService", () => { console.log(result) expect(result).not.toBe(null) }); - test("submitTransaction", async () => { - const uint8 = new Uint8Array([0]) - const result = await koiosTransactionsService.submitTransaction(uint8) - console.log(result) - expect(result).not.toBe(null) - expect(result.statusCode).toBe(400) + test("submitTransactionBadRequest", async () => { + try { + await koiosTransactionsService.submitTransaction(new Uint8Array([0])) + } catch (e) { + expect(e).toBeInstanceOf(KoiosHttpError) + expect(e).not.toBe(null) + expect(e.statusCode).toBe(400) + } }); test("getTransactionStatus", async () => { const txHashes = [