Skip to content

test(identity): add missing tests for id progression, zero runtime key, and unknown tokenURI (fixes #1) - #2

Merged
Viscous106 merged 2 commits into
mergit-io:mainfrom
arifrhm:test/identity-missing-tests
Oct 29, 2026
Merged

Viscous106 merged 2 commits into
mergit-io:mainfrom
arifrhm:test/identity-missing-tests

Conversation

@arifrhm

@arifrhm arifrhm commented Oct 28, 2026

Copy link
Copy Markdown
Contributor

Resolves #1

Summary

Adds the three requested unit tests covering core behaviors of Identity.sol:

  1. test_agentIdsIncrease: Verifies registering sequential agents increments agentId (1 then 2).
  2. test_setRuntimeKeyRejectsZeroAddress: Verifies setting a runtime key to address(0) reverts with ZeroRuntimeKey.
  3. test_tokenURIOfUnknownAgentReverts: Verifies calling tokenURI(42) on an unminted agent reverts with UnknownAgent(42).

Verification & Quality Checks

  • forge test --match-contract IdentityTest passes (9/9 tests pass).
  • forge test passes across full suite (91/91 tests pass).
  • forge fmt --check is clean with zero formatting errors.
  • Only test/Identity.t.sol modified.

…y, and unknown tokenURI (fixes mergit-io#1)

Signed-off-by: Arif Rahman <arif.rahman.rhm@gmail.com>
@Viscous106
Viscous106 self-requested a review October 28, 2026 13:42
Comment thread test/Identity.t.sol Resolved
Comment thread test/Identity.t.sol Resolved
Comment thread test/Identity.t.sol Resolved

@Viscous106 Viscous106 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you need more help or talk regarding the changes feel free to ping me .. Great work otherwise just some changes are needed do that ... Thanks

@arifrhm

arifrhm commented Oct 28, 2026

Copy link
Copy Markdown
Contributor Author

All requested review changes have been addressed in commit 159bd38:

  1. Global ID Progression: test_agentIdsIncrease now registers the second agent with a distinct operator (operator2) and asserts both global sequential IDs and independent ownership via id.ownerOf(first) and id.ownerOf(second).
  2. Runtime Key Rotation Event: Added vm.expectEmit(true, false, false, true) for RuntimeKeyChanged in the rotation test.
  3. Unknown Agent Guard: Added sibling test test_setRuntimeKeyRejectsUnknownAgent verifying that rotating a key for an unminted agent ID reverts with IIdentity.UnknownAgent(42).
  4. Transfer Key Retention: test_runtimeKeyFollowsTokenTransferOwnership now explicitly asserts that id.runtimeKeyOf(agentId) persists as the seller's key across transferFrom until the new operator performs a rotation.

All 92/92 tests in the suite pass cleanly and forge fmt --check is satisfied!

@OfficialAbhinavSingh OfficialAbhinavSingh left a comment •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All three of Yash's review points are addressed: the second agentId test now uses a different operator and checks ownerOf on both, there's a sibling test for setRuntimeKey on an unknown agent plus the RuntimeKeyChanged emit assertion, and the transfer test now asserts runtimeKeyOf post-transfer (documenting current behavior: the key isn't cleared on sale). Checked the new assertions against Identity.sol directly error selectors and call order line up. Ready to merge.

@OfficialAbhinavSingh

OfficialAbhinavSingh commented Oct 28, 2026 •

Copy link
Copy Markdown
Member

Thanks for working through the feedback so carefully, Arif the updated tests are solid and the transfer-ownership one is a nice catch to have documented either way. Appreciate it.

@Viscous106
Viscous106 self-requested a review October 29, 2026 04:23

@Viscous106 Viscous106 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!! Thanks for this. If you're interested in writing the actual contract fix for the transfer case (#16), let me know there and I'll assign it to you.

@Viscous106
Viscous106 merged commit 2f804e4 into mergit-io:main Oct 29, 2026
1 check passed
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 this pull request may close these issues.

Identity: add three missing tests

3 participants