import {expect} from "chai"; import {toGraffitiBuffer} from "../../../src/util/graffiti.js"; describe("Graffiti helper", () => { describe("toGraffitiBuffer", () => { const cases: {input: string; result: string}[] = [ { // Pad short strings with zeros input: "chainsafe/lodestar", result: "636861696e736166652f6c6f6465737461720000000000000000000000000000", }, { // Empty strings should become a zero hash input: "", result: "0000000000000000000000000000000000000000000000000000000000000000", }, { // Really long string that should be cropped input: "a".repeat(96), result: "6161616161616161616161616161616161616161616161616161616161616161", }, ]; for (const {input, result} of cases) { it(`Convert graffiti UTF8 ${input} to Buffer`, () => { expect(toGraffitiBuffer(input).toString("hex")).to.equal(result); }); } }); });