Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Test failed for Dictionary #45

Open
witterlee opened this issue Oct 2, 2024 · 0 comments
Open

Test failed for Dictionary #45

witterlee opened this issue Oct 2, 2024 · 0 comments

Comments

@witterlee
Copy link

witterlee commented Oct 2, 2024

● Dictionary › should correctly serialize Buffer keys and Cell values

Index 256 > 256 is out of bounds

  68 |         // Check bounds
  69 |         if (index >= this._length) {
> 70 |             throw new Error(`Index ${index} > ${this._length} is out of bounds`);
     |                   ^
  71 |         }
  72 |         if (index < 0) {
  73 |             throw new Error(`Index ${index} < 0 is out of bounds`);
it("should correctly serialize Buffer keys and Cell values", async () => {
    const keyLen = 256;
    const keys = Dictionary.Keys.Buffer(keyLen);
    const values = Dictionary.Values.Cell();
    let testKey = await sha256("name");
    let testVal = beginCell()
      .storeUint(0x00, 8)
      .storeBuffer(Buffer.from("Test", "utf8"))
      .endCell();
    let testDict = Dictionary.empty(keys, values);

    testDict.set(testKey, testVal);
    expect(testDict.get(testKey)!.equals(testVal)).toBe(true);
    let serialized = beginCell().storeDictDirect(testDict).endCell();
    let dictDs = Dictionary.loadDirect(keys, values, serialized);
    expect(dictDs.get(testKey)!.equals(testVal)).toBe(true);
  });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant