Skip to content

Commit

Permalink
fixed bytes length
Browse files Browse the repository at this point in the history
  • Loading branch information
alessandrokonrad committed Jan 16, 2025
1 parent c6ab5e7 commit abc8127
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
8 changes: 3 additions & 5 deletions src/plutus/data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,11 @@ export const Data = {
) => {
const bytes: Record<string, unknown> = { dataType: "bytes" };
if (typeof options === "number") {
bytes.minLength = options * 2;
bytes.maxLength = options * 2;
bytes.minLength = options;
bytes.maxLength = options;
} else if (options) {
Object.entries(options).forEach(([key, value]) => {
bytes[key] = (key === "minLength" || key === "maxLength")
? value as number * 2
: value;
bytes[key] = value;
});
}
return bytes as unknown as string;
Expand Down
4 changes: 2 additions & 2 deletions tests/data.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ Deno.test("Roundtrip data recursive $ref", () => {

Deno.test("Exact bytes length", () => {
const MyDatum = Data.Bytes(28);
const datum: typeof MyDatum = "00".repeat(56);
const datum: typeof MyDatum = "00".repeat(28);
assert(Data.to(datum, MyDatum));
const wrongDatum: typeof MyDatum = "00".repeat(28);
const wrongDatum: typeof MyDatum = "00".repeat(20);
let isError = false;
try {
Data.to(wrongDatum, MyDatum);
Expand Down

0 comments on commit abc8127

Please sign in to comment.