Skip to content

fix: auth fetch hanging process and certificates exchange between peers #220

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

Merged
merged 6 commits into from
Aug 5, 2025

Conversation

dorzepowski
Copy link
Collaborator

THIS PR IS BASED ON #217

@Copilot Copilot AI review requested due to automatic review settings August 5, 2025 13:58
Copilot

This comment was marked as outdated.

@dorzepowski dorzepowski force-pushed the fix-auth-fetch-hanging-process branch from 1cea585 to cdf7ca1 Compare August 5, 2025 14:06
@bsv-blockchain bsv-blockchain deleted a comment from Copilot AI Aug 5, 2025
@bsv-blockchain bsv-blockchain deleted a comment from Copilot AI Aug 5, 2025
@dorzepowski dorzepowski requested a review from Copilot August 5, 2025 14:07
@bsv-blockchain bsv-blockchain deleted a comment from Copilot AI Aug 5, 2025
Copy link

@Copilot Copilot AI left a comment

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 introduces comprehensive testing infrastructure improvements with better wallet mocking capabilities and enhanced certificate validation. The changes focus on replacing the old MockWallet implementation with a more flexible TestWallet system that provides better test isolation and cleaner APIs.

Key Changes:

  • Replaced MockWallet with TestWallet: New TestWallet provides fluent API for test setup with OnXyz().ReturnSuccess/ReturnError patterns
  • Enhanced certificate validation: Improved ValidateCertificates function with better error handling and concurrent processing
  • Added comprehensive test utilities: New test certificate utilities and better logging infrastructure for tests

Reviewed Changes

Copilot reviewed 31 out of 32 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
wallet/mock.go Removed legacy MockWallet implementation
wallet/test_wallet.go Added new TestWallet with fluent mocking API
wallet/wallet_keys.go Added key conversion utilities with generic type support
auth/utils/validate_certificates.go Enhanced certificate validation with concurrent processing
Multiple test files Updated to use new TestWallet instead of MockWallet
Comments suppressed due to low confidence (2)

primitives/ec/symmetric.go:22

  • [nitpick] The error message "failed to encrypt string" is redundant since the wrapped error from Encrypt already contains encryption failure context. Consider using a more specific message like "string encryption failed" or just return the wrapped error directly.
		return "", fmt.Errorf("failed to encrypt string: %w", err)

auth/transports/simplified_http_transport.go:109

  • [nitpick] The error message format uses pipe separator '|' between identity key and URL which could be confusing. Consider using a clearer format like 'key=%s url=%s' or separate the information more clearly.
		return fmt.Errorf("%s message to (%s | %s) failed: %w", message.MessageType, message.IdentityKey.ToDERHex(), requestURL, err)

@dorzepowski dorzepowski force-pushed the fix-auth-fetch-hanging-process branch from cdf7ca1 to 4ffd5db Compare August 5, 2025 14:09
@bsv-blockchain bsv-blockchain deleted a comment from Copilot AI Aug 5, 2025
@rohenaz rohenaz requested a review from Copilot August 5, 2025 19:07
Copilot

This comment was marked as outdated.

@rohenaz rohenaz requested a review from Copilot August 5, 2025 19:18
Copy link

@Copilot Copilot AI left a comment

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 refactors the wallet testing infrastructure by replacing the old MockWallet with a new TestWallet implementation. It introduces enhanced certificate handling with a dedicated test certificate manager and key derivation utilities, improving testing consistency and maintainability across the codebase.

Key Changes:

  • Replaces MockWallet with TestWallet that provides a fluent API for method mocking
  • Introduces testcertificates.Manager for certificate testing operations
  • Adds generic key derivation utilities with support for multiple input types (hex, WIF, PrivateKey)

Reviewed Changes

Copilot reviewed 32 out of 33 changed files in this pull request and generated no comments.

Show a summary per file
File Description
wallet/mock.go Removed old MockWallet implementation
wallet/test_wallet.go Added new TestWallet with fluent mocking API
wallet/wallet_keys.go Added generic key conversion utilities
wallet/testcertificates/test_certificates_manager.go Added certificate testing framework
util/test_cert_util/test_certificate_utils.go Added certificate creation utilities
Multiple test files Updated to use new TestWallet API
Comments suppressed due to low confidence (4)

auth/peer.go:165

  • This FIXME comment indicates incomplete implementation. Consider creating a GitHub issue to track this technical debt or implementing the context passing in this PR to avoid leaving incomplete work.
}

auth/peer.go:363

  • This TODO indicates a design improvement opportunity. Since the code already implements context with timeout on lines 344-345, this TODO comment appears to be outdated and should be removed.
		return nil, ErrTimeout

auth/peer.go:844

  • This TODO comment suggests incomplete validation logic. Consider implementing default certificate validation or creating a GitHub issue to track this enhancement request.
	if !valid {

Copy link
Collaborator

@rohenaz rohenaz left a comment

Choose a reason for hiding this comment

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

lgtm

@rohenaz rohenaz merged commit a079ce4 into master Aug 5, 2025
5 of 7 checks passed
rohenaz added a commit to b-open-io/go-sdk that referenced this pull request Aug 5, 2025
- Added reveal methods implementation (bsv-blockchain#219)
- Added auth/certificate improvements (bsv-blockchain#217, bsv-blockchain#220)
- Added testing infrastructure improvements
- Updated dependencies
@rohenaz rohenaz mentioned this pull request Aug 5, 2025
@dorzepowski dorzepowski deleted the fix-auth-fetch-hanging-process branch August 18, 2025 06:49
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