Skip to content

test: add admin transfer, upgrade and credential display unit tests (#539, #540, #541) - #679

Merged
DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
devsimze:test/issues-539-540-541-credential-nft
Oct 21, 2026
Merged

DeFiVC merged 2 commits into
ChainLearnOfficial:mainfrom
devsimze:test/issues-539-540-541-credential-nft

Conversation

@devsimze

Copy link
Copy Markdown
Contributor

Closes #539
Closes #540
Closes #541

Summary

Closes the three remaining issues from the #538-#541 test batch and repairs the test suite that was left broken by the RBAC/typed-error work in #677 and the test merge in #678.

#539 — Admin transfer / handover

  • test_double_transfer_overwrites_previous_pending — a second transfer_admin replaces the pending candidate
  • test_transfer_admin_requires_the_current_admin_signature — only the current admin can nominate a successor
  • test_pending_admin_alone_can_accept_the_handover — the pending admin can accept without the old admin
  • test_default_admin_transfer_delay_blocks_acceptance_within_48_hours — the default 48h delay is enforced
  • test_admin_transfer_delay_is_never_below_the_minimum — the minimum delay cannot be lowered

#540 — Contract upgrade

  • test_upgrade_requires_admin_auth — only the admin can upgrade
  • test_upgrade_rejects_non_admin_role_holder — a role holder without the admin role is rejected
  • test_upgrade_sets_wasm_hash_and_increments_version — the hash is stored and the version increments
  • test_upgrade_emits_upgraded_event — the upgrade event is emitted with the new version
  • test_failed_upgrade_leaves_version_and_hash_untouched — a failed upgrade changes nothing

#541 — Credential display

  • test_get_credential_display_returns_none_for_unset / ..._for_unknown_credential
  • test_set_credential_display_all_fields / ..._partial_fields / ..._updates_overwrites_previous_values
  • test_set_credential_display_emits_event
  • test_set_credential_display_requires_admin_auth — no admin auth means no write
  • test_set_credential_display_rejects_unknown_credential — typed ContractError::NotFound
  • test_set_credential_display_is_scoped_to_a_single_credential
  • test_set_credential_display_survives_revocation

Test-suite repairs (pre-existing breakage)

  • mint_credential call sites updated to the post-RBAC signature
  • Stale should_panic expectations replaced with typed error assertions
  • Outdated pause/unpause/emergency_pause call sites corrected
  • Storage-size expectations updated for the new role-grant entry
  • Duplicate create_course calls removed from the cross-contract tests
  • test_get_certificate_uri_uses_the_cert_prefix_format now really asserts the cert_ + lowercase hex format

Testing

  • cargo test --workspace — 829 passed, 0 failed

… and display coverage

Restores the workspace test suite that broke on the RBAC/typed-error
changes and adds the missing coverage for issues ChainLearnOfficial#539, ChainLearnOfficial#540 and ChainLearnOfficial#541:

- ChainLearnOfficial#539 admin handover: pending candidate overwrite, admin signature
  enforcement, pending-admin acceptance, handover delay and minimum delay
- ChainLearnOfficial#540 contract upgrade: admin auth, role holder rejection, version and
  wasm hash updates, event emission and failed-upgrade invariants
- ChainLearnOfficial#541 credential display: field set/get, partial updates, overwrite,
  admin auth, unknown credential, per-credential scoping and revocation

Also fixes the pre-existing breakage in the test suite (stale panic
expectations replaced with typed error assertions, outdated pause and
mint_credential call sites, storage-size expectations and duplicated
course creation).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

3 participants