mirror of
https://github.com/logos-storage/logos-storage-js.git
synced 2026-01-04 06:23:06 +00:00
Update tests
This commit is contained in:
parent
4fcf34a136
commit
a05672ff7f
@ -52,15 +52,15 @@ describe("marketplace", async () => {
|
|||||||
const errors: Partial<CodexCreateAvailabilityInput>[] = [
|
const errors: Partial<CodexCreateAvailabilityInput>[] = [
|
||||||
{ duration: 0 },
|
{ duration: 0 },
|
||||||
{ totalSize: 0 },
|
{ totalSize: 0 },
|
||||||
{ totalCollateral: BigInt(-1) },
|
{ totalCollateral: -1 },
|
||||||
{ minPricePerBytePerSecond: BigInt(-1) },
|
{ minPricePerBytePerSecond: -1 },
|
||||||
];
|
];
|
||||||
|
|
||||||
for (const err of errors) {
|
for (const err of errors) {
|
||||||
const field = Object.keys(err)[0] as keyof typeof err;
|
const field = Object.keys(err)[0] as keyof typeof err;
|
||||||
assert.ok(field);
|
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({
|
const response = await spMarketplace.createAvailability({
|
||||||
...body,
|
...body,
|
||||||
[field]: err[field],
|
[field]: err[field],
|
||||||
@ -73,9 +73,7 @@ describe("marketplace", async () => {
|
|||||||
response.data.errors[0]?.received,
|
response.data.errors[0]?.received,
|
||||||
err[field]?.toString()
|
err[field]?.toString()
|
||||||
);
|
);
|
||||||
assert.ok(
|
assert.ok(response.data.errors[0]?.message.startsWith("Invalid"));
|
||||||
response.data.errors[0]?.message.startsWith("Invalid value:")
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -137,9 +135,7 @@ describe("marketplace", async () => {
|
|||||||
response.data.errors[0]?.received,
|
response.data.errors[0]?.received,
|
||||||
err[field]?.toString()
|
err[field]?.toString()
|
||||||
);
|
);
|
||||||
assert.ok(
|
assert.ok(response.data.errors[0]?.message.startsWith("Invalid"));
|
||||||
response.data.errors[0]?.message.startsWith("Invalid value:")
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@ -42,7 +42,7 @@ export const CodexCreateAvailabilityInput = v.strictObject({
|
|||||||
totalSize: v.pipe(v.number(), v.minValue(1)),
|
totalSize: v.pipe(v.number(), v.minValue(1)),
|
||||||
duration: v.pipe(v.number(), v.minValue(1)),
|
duration: v.pipe(v.number(), v.minValue(1)),
|
||||||
minPricePerBytePerSecond: v.union([
|
minPricePerBytePerSecond: v.union([
|
||||||
v.bigint(),
|
v.pipe(v.bigint(), v.minValue(BigInt(0))),
|
||||||
v.pipe(
|
v.pipe(
|
||||||
v.number(),
|
v.number(),
|
||||||
v.minValue(0),
|
v.minValue(0),
|
||||||
@ -50,7 +50,7 @@ export const CodexCreateAvailabilityInput = v.strictObject({
|
|||||||
),
|
),
|
||||||
]),
|
]),
|
||||||
totalCollateral: v.union([
|
totalCollateral: v.union([
|
||||||
v.bigint(),
|
v.pipe(v.bigint(), v.minValue(BigInt(0))),
|
||||||
v.pipe(
|
v.pipe(
|
||||||
v.number(),
|
v.number(),
|
||||||
v.minValue(0),
|
v.minValue(0),
|
||||||
@ -85,17 +85,17 @@ export const CodexAvailabilityPatchInput = v.strictObject({
|
|||||||
duration: v.optional(v.pipe(v.number(), v.minValue(1))),
|
duration: v.optional(v.pipe(v.number(), v.minValue(1))),
|
||||||
minPricePerBytePerSecond: v.optional(
|
minPricePerBytePerSecond: v.optional(
|
||||||
v.union([
|
v.union([
|
||||||
v.bigint(),
|
v.pipe(v.bigint(), v.minValue(BigInt(0))),
|
||||||
v.pipe(
|
v.pipe(
|
||||||
v.number(),
|
v.number(),
|
||||||
v.minValue(1),
|
v.minValue(0),
|
||||||
v.transform((input) => BigInt(input))
|
v.transform((input) => BigInt(input))
|
||||||
),
|
),
|
||||||
])
|
])
|
||||||
),
|
),
|
||||||
totalCollateral: v.optional(
|
totalCollateral: v.optional(
|
||||||
v.union([
|
v.union([
|
||||||
v.bigint(),
|
v.pipe(v.bigint(), v.minValue(BigInt(0))),
|
||||||
v.pipe(
|
v.pipe(
|
||||||
v.number(),
|
v.number(),
|
||||||
v.minValue(0),
|
v.minValue(0),
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user