From ecf168ad254f3a0822b442c03a2aeb705019f800 Mon Sep 17 00:00:00 2001 From: Joe Polny Date: Wed, 18 Dec 2024 15:08:59 -0500 Subject: [PATCH] skipEvalTrace on tests that are expected to throw an error --- tests/common.ts | 6 ++++++ tests/general.test.ts | 4 ++-- tests/math.test.ts | 2 +- tests/templates.test.ts | 3 ++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/tests/common.ts b/tests/common.ts index c18b8eec2..f4849f7c2 100644 --- a/tests/common.ts +++ b/tests/common.ts @@ -156,6 +156,7 @@ export async function runMethod({ callType = 'call', fundAmount = 0, fee = 1000, + skipEvalTrace = false, }: { appClient: ApplicationClient; method: string; @@ -163,6 +164,7 @@ export async function runMethod({ callType?: 'call' | 'optIn'; fundAmount?: number; fee?: number; + skipEvalTrace?: boolean; }) { const params = { method, @@ -179,6 +181,10 @@ export async function runMethod({ } return (await appClient[callType](params)).return?.returnValue; } catch (e) { + if (skipEvalTrace) { + console.warn(e); + throw e; + } // eslint-disable-next-line no-console const abiMethod = appClient.getABIMethod(params.method)!; const { appId } = await appClient.getAppReference(); diff --git a/tests/general.test.ts b/tests/general.test.ts index 71b6a56ee..4aa641746 100644 --- a/tests/general.test.ts +++ b/tests/general.test.ts @@ -99,7 +99,7 @@ describe('General', function () { const { appClient, compiler } = await compileAndCreate(await sender, PATH, ARTIFACTS_DIR, NAME); let msg = 'No error'; try { - await runMethod({ appClient, method: 'assertComment' }); + await runMethod({ appClient, method: 'assertComment', skipEvalTrace: true }); } catch (e) { msg = getErrorMessage(e.message, compiler.sourceInfo); } @@ -111,7 +111,7 @@ describe('General', function () { const { appClient, compiler } = await compileAndCreate(await sender, PATH, ARTIFACTS_DIR, NAME); let msg = 'No error'; try { - await runMethod({ appClient, method: 'throwErrorMessage' }); + await runMethod({ appClient, method: 'throwErrorMessage', skipEvalTrace: true }); } catch (e) { msg = getErrorMessage(e.message, compiler.sourceInfo); } diff --git a/tests/math.test.ts b/tests/math.test.ts index 454051707..2eb0100f0 100644 --- a/tests/math.test.ts +++ b/tests/math.test.ts @@ -85,7 +85,7 @@ describe('Math', function () { let msg: string; try { - await runMethod({ appClient, method: 'uint8plus', methodArgs: [2 ** 8 - 1, 1] }); + await runMethod({ appClient, method: 'uint8plus', methodArgs: [2 ** 8 - 1, 1], skipEvalTrace: true }); msg = 'No error'; // eslint-disable-next-line @typescript-eslint/no-explicit-any } catch (e: any) { diff --git a/tests/templates.test.ts b/tests/templates.test.ts index f63f90aa6..0d6504708 100644 --- a/tests/templates.test.ts +++ b/tests/templates.test.ts @@ -73,7 +73,7 @@ describe('Template Variables', function () { }); let pc = 0; try { - await runMethod({ appClient, method: 'throwError' }); + await runMethod({ appClient, method: 'throwError', skipEvalTrace: true }); } catch (error) { pc = Number(String(error).match(/pc=(\d+)/)?.[1]); } @@ -86,6 +86,7 @@ describe('Template Variables', function () { const offsetPc = pc - cblocksOffset; const sourceInfo = arc56.sourceInfo.approval.sourceInfo.find((s) => s.pc?.includes(offsetPc)); + console.debug(arc56.sourceInfo.approval.sourceInfo, offsetPc, pc); expect(sourceInfo?.errorMessage).toBe('this is an error'); }); });