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

wrapped-keys test fails due to getPkpAccessControlCondition returning an object instead of an array #760

Closed
1 task done
susumutomita opened this issue Jan 4, 2025 · 0 comments · Fixed by #761
Closed
1 task done

Comments

@susumutomita
Copy link
Contributor

Is there an existing issue for this?

  • I have searched the existing issues

SDK version

Using Lit JS SDK (master branch commit 412264b.)

Lit Network

This issue is for unit testing , so not

Description of the bug/issue

The test should correctly create the ACC in packages/wrapped-keys/src/lib/api/utils.spec.ts expects an array with a single ACC object, but the actual getPkpAccessControlCondition function returns a plain object (not an array). This causes:

 FAIL   types  packages/wrapped-keys/src/lib/api/utils.spec.ts
  ● getPkpAccessControlCondition › should correctly create the ACC

    expect(received).toEqual(expected) // deep equality

    Expected: [{"chain": "ethereum", "contractAddress": "", "method": "", "parameters": [":userAddress"], "returnValueTest": {"comparator": "=", "value": "0xd1Af1AAC50aC837C873200D17b78664aFCde597C"}, "standardContractType": ""}]
    Received: {"chain": "ethereum", "contractAddress": "", "method": "", "parameters": [":userAddress"], "returnValueTest": {"comparator": "=", "value": "0xd1Af1AAC50aC837C873200D17b78664aFCde597C"}, "standardContractType": ""}

      88 |     const pkpAddress = '0xd1Af1AAC50aC837C873200D17b78664aFCde597C';
      89 |     const acc = getPkpAccessControlCondition(pkpAddress);
    > 90 |     expect(acc).toEqual([
         |                 ^
      91 |       {
      92 |         contractAddress: '',
      93 |         standardContractType: '',

      at Object.<anonymous> (src/lib/api/utils.spec.ts:90:17)

Test Suites: 1 failed, 1 passed, 2 total
Tests:       1 failed, 12 passed, 13 total
Snapshots:   0 total
Time:        2.563 s
Ran all test suites.

Severity of the bug

This breaks the test suite out-of-the-box, causing CI to fail unless the code or test is adjusted.

Steps To Reproduce

  1. npx nx run wrapped-keys:test
  2. The test fails with the mismatch: expected array vs actual object.

Link to code

Anything else?

Proposed fix:

  • Either update the implementation of getPkpAccessControlCondition to return an array (like [ {...} ]), or modify the test to expect an object.
  • Considering that other ACC usage patterns might rely on an array, it’s probably safer to return an array from the implementation for consistency.
Ansonhkg added a commit that referenced this issue Jan 15, 2025
fix #760 wrapped-keys test to expect a single ACC object instead of an array
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

Successfully merging a pull request may close this issue.

1 participant