Skip to content

Add more did validator test#3754

Merged
jolestar merged 2 commits into
mainfrom
more_did_validator_test
Nov 18, 2025
Merged

Add more did validator test#3754
jolestar merged 2 commits into
mainfrom
more_did_validator_test

Conversation

@jolestar

Copy link
Copy Markdown
Contributor

Summary

Summary about this PR

  • Closes #issue

@vercel

vercel Bot commented Nov 18, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
rooch-portal-v2.1 Ready Ready Preview Comment Nov 18, 2025 3:54am
test-portal Ready Ready Preview Comment Nov 18, 2025 3:54am
1 Skipped Deployment
Project Deployment Preview Comments Updated (UTC)
rooch Ignored Ignored Preview Nov 18, 2025 3:54am

@jolestar jolestar requested review from Copilot and removed request for baichuan3 and wow-sven November 18, 2025 03:27
@github-actions

github-actions Bot commented Nov 18, 2025

Copy link
Copy Markdown

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds comprehensive test coverage for the DID validator module, focusing on testing various failure scenarios across different envelope types (RawTxHash, BitcoinMessageV0, and WebAuthnV0).

Key Changes:

  • Added 15 new test cases covering various error conditions in DID authentication
  • Introduced helper functions for creating test payloads and signatures
  • Added test-only helper functions to the did_validator module for payload creation

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 4 comments.

File Description
frameworks/rooch-framework/sources/tests/did_validator_test.move Added comprehensive test coverage for DID validator error scenarios including missing DIDs, unauthorized verification methods, invalid signatures, and envelope-specific validation failures
frameworks/rooch-framework/sources/auth_validator/did_validator.move Added two test-only helper functions (create_test_did_auth_payload and create_test_webauthn_envelope) to support test payload construction

Comment on lines +541 to +545
let i = 0;
while (i < 64) {
vector::push_back(&mut signature, 0x00);
i = i + 1;
};

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

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

Variable i is declared and reused in the same scope on lines 541-545. The first loop (lines 526-530) already declared and used i, but then it's re-declared on line 541. While this may work in Move, it's better practice to reuse the existing variable or use different variable names to avoid confusion. Consider using i = 0; instead of let i = 0; on line 541.

Copilot uses AI. Check for mistakes.
#[test]
#[expected_failure(abort_code = DID_ERROR_VERIFICATION_METHOD_NOT_AUTHORIZED, location = rooch_framework::did_validator)]
fun test_raw_tx_hash_verification_method_not_found() {
// Test that validation fails when vm_fragment does not exist in DID document

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

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

The comment on line 218 says "Test that validation fails when vm_fragment does not exist in DID document", but this is actually testing when a verification method exists but is not in the authentication relationship. The scenario where a verification method doesn't exist at all is the same as the scenario where it's not authorized (both fail at the same check). Consider updating the comment to: "Test that validation fails when vm_fragment is not in the authentication relationship (non-existent keys also fail here)".

Suggested change
// Test that validation fails when vm_fragment does not exist in DID document
// Test that validation fails when vm_fragment is not in the authentication relationship (non-existent keys also fail here)

Copilot uses AI. Check for mistakes.
Comment on lines +94 to +98
let i = 0;
while (i < 64) {
vector::push_back(&mut signature, 0x00);
i = i + 1;
};

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

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

[nitpick] This code block for creating a 64-byte signature is duplicated many times throughout the test file (lines 94-98, 151-156, 198-203, 231-236, 278-283, 315-320, 348-353, 390-395, 427-432, 454-459, 493-498, 540-545, 594-599, 653-658, 703-708). Consider extracting this into a helper function like create_empty_signature(size: u64): vector<u8> to improve maintainability and reduce code duplication.

Copilot uses AI. Check for mistakes.
Comment on lines +391 to +395
let i = 0;
while (i < 64) {
vector::push_back(&mut signature, 0x00);
i = i + 1;
};

Copilot AI Nov 18, 2025

Copy link

Choose a reason for hiding this comment

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

Variable i is declared and reused in the same scope on lines 391-395. The first loop (lines 382-386) already declared and used i, but then it's re-declared on line 391. While this may work in Move, it's better practice to reuse the existing variable or use different variable names to avoid confusion. Consider using i = 0; instead of let i = 0; on line 391.

Copilot uses AI. Check for mistakes.
@jolestar jolestar merged commit fd14ff3 into main Nov 18, 2025
16 of 21 checks passed
@jolestar jolestar deleted the more_did_validator_test branch November 18, 2025 07:42
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.

2 participants