From a05672ff7ff88d9354ff292bce5a34a2df3d5b24 Mon Sep 17 00:00:00 2001 From: Arnaud Date: Fri, 30 May 2025 15:58:53 +0200 Subject: [PATCH] Update tests --- src/marketplace/marketplace.test.ts | 14 +++++--------- src/marketplace/types.ts | 10 +++++----- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/src/marketplace/marketplace.test.ts b/src/marketplace/marketplace.test.ts index f38eed9..83b5273 100644 --- a/src/marketplace/marketplace.test.ts +++ b/src/marketplace/marketplace.test.ts @@ -52,15 +52,15 @@ describe("marketplace", async () => { const errors: Partial[] = [ { duration: 0 }, { totalSize: 0 }, - { totalCollateral: BigInt(-1) }, - { minPricePerBytePerSecond: BigInt(-1) }, + { totalCollateral: -1 }, + { minPricePerBytePerSecond: -1 }, ]; for (const err of errors) { const field = Object.keys(err)[0] as keyof typeof err; assert.ok(field); - it(`fails to create availability with wrong ${field}`, async () => { + it(`fails to create availability with wrong ${field} = ${err[field]}`, async () => { const response = await spMarketplace.createAvailability({ ...body, [field]: err[field], @@ -73,9 +73,7 @@ describe("marketplace", async () => { response.data.errors[0]?.received, err[field]?.toString() ); - assert.ok( - response.data.errors[0]?.message.startsWith("Invalid value:") - ); + assert.ok(response.data.errors[0]?.message.startsWith("Invalid")); }); } }); @@ -137,9 +135,7 @@ describe("marketplace", async () => { response.data.errors[0]?.received, err[field]?.toString() ); - assert.ok( - response.data.errors[0]?.message.startsWith("Invalid value:") - ); + assert.ok(response.data.errors[0]?.message.startsWith("Invalid")); }); } }); diff --git a/src/marketplace/types.ts b/src/marketplace/types.ts index d5128c3..f2280fb 100644 --- a/src/marketplace/types.ts +++ b/src/marketplace/types.ts @@ -42,7 +42,7 @@ export const CodexCreateAvailabilityInput = v.strictObject({ totalSize: v.pipe(v.number(), v.minValue(1)), duration: v.pipe(v.number(), v.minValue(1)), minPricePerBytePerSecond: v.union([ - v.bigint(), + v.pipe(v.bigint(), v.minValue(BigInt(0))), v.pipe( v.number(), v.minValue(0), @@ -50,7 +50,7 @@ export const CodexCreateAvailabilityInput = v.strictObject({ ), ]), totalCollateral: v.union([ - v.bigint(), + v.pipe(v.bigint(), v.minValue(BigInt(0))), v.pipe( v.number(), v.minValue(0), @@ -85,17 +85,17 @@ export const CodexAvailabilityPatchInput = v.strictObject({ duration: v.optional(v.pipe(v.number(), v.minValue(1))), minPricePerBytePerSecond: v.optional( v.union([ - v.bigint(), + v.pipe(v.bigint(), v.minValue(BigInt(0))), v.pipe( v.number(), - v.minValue(1), + v.minValue(0), v.transform((input) => BigInt(input)) ), ]) ), totalCollateral: v.optional( v.union([ - v.bigint(), + v.pipe(v.bigint(), v.minValue(BigInt(0))), v.pipe( v.number(), v.minValue(0),