Update tests

This commit is contained in:
Arnaud 2025-05-30 15:58:53 +02:00
parent 4fcf34a136
commit a05672ff7f
No known key found for this signature in database
GPG Key ID: B8FBC178F10CA7AE
2 changed files with 10 additions and 14 deletions

View File

@ -52,15 +52,15 @@ describe("marketplace", async () => {
const errors: Partial<CodexCreateAvailabilityInput>[] = [
{ 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"));
});
}
});

View File

@ -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),