Skip to content

Commit a05672f

Browse files
committed
Update tests
1 parent 4fcf34a commit a05672f

File tree

2 files changed

+10
-14
lines changed

2 files changed

+10
-14
lines changed

src/marketplace/marketplace.test.ts

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -52,15 +52,15 @@ describe("marketplace", async () => {
5252
const errors: Partial<CodexCreateAvailabilityInput>[] = [
5353
{ duration: 0 },
5454
{ totalSize: 0 },
55-
{ totalCollateral: BigInt(-1) },
56-
{ minPricePerBytePerSecond: BigInt(-1) },
55+
{ totalCollateral: -1 },
56+
{ minPricePerBytePerSecond: -1 },
5757
];
5858

5959
for (const err of errors) {
6060
const field = Object.keys(err)[0] as keyof typeof err;
6161
assert.ok(field);
6262

63-
it(`fails to create availability with wrong ${field}`, async () => {
63+
it(`fails to create availability with wrong ${field} = ${err[field]}`, async () => {
6464
const response = await spMarketplace.createAvailability({
6565
...body,
6666
[field]: err[field],
@@ -73,9 +73,7 @@ describe("marketplace", async () => {
7373
response.data.errors[0]?.received,
7474
err[field]?.toString()
7575
);
76-
assert.ok(
77-
response.data.errors[0]?.message.startsWith("Invalid value:")
78-
);
76+
assert.ok(response.data.errors[0]?.message.startsWith("Invalid"));
7977
});
8078
}
8179
});
@@ -137,9 +135,7 @@ describe("marketplace", async () => {
137135
response.data.errors[0]?.received,
138136
err[field]?.toString()
139137
);
140-
assert.ok(
141-
response.data.errors[0]?.message.startsWith("Invalid value:")
142-
);
138+
assert.ok(response.data.errors[0]?.message.startsWith("Invalid"));
143139
});
144140
}
145141
});

src/marketplace/types.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ export const CodexCreateAvailabilityInput = v.strictObject({
4242
totalSize: v.pipe(v.number(), v.minValue(1)),
4343
duration: v.pipe(v.number(), v.minValue(1)),
4444
minPricePerBytePerSecond: v.union([
45-
v.bigint(),
45+
v.pipe(v.bigint(), v.minValue(BigInt(0))),
4646
v.pipe(
4747
v.number(),
4848
v.minValue(0),
4949
v.transform((input) => BigInt(input))
5050
),
5151
]),
5252
totalCollateral: v.union([
53-
v.bigint(),
53+
v.pipe(v.bigint(), v.minValue(BigInt(0))),
5454
v.pipe(
5555
v.number(),
5656
v.minValue(0),
@@ -85,17 +85,17 @@ export const CodexAvailabilityPatchInput = v.strictObject({
8585
duration: v.optional(v.pipe(v.number(), v.minValue(1))),
8686
minPricePerBytePerSecond: v.optional(
8787
v.union([
88-
v.bigint(),
88+
v.pipe(v.bigint(), v.minValue(BigInt(0))),
8989
v.pipe(
9090
v.number(),
91-
v.minValue(1),
91+
v.minValue(0),
9292
v.transform((input) => BigInt(input))
9393
),
9494
])
9595
),
9696
totalCollateral: v.optional(
9797
v.union([
98-
v.bigint(),
98+
v.pipe(v.bigint(), v.minValue(BigInt(0))),
9999
v.pipe(
100100
v.number(),
101101
v.minValue(0),

0 commit comments

Comments
 (0)