jwk unit tests and jwk genesis params fix #363
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This pull request adds comprehensive unit and integration tests for the JWK module, improves defensive programming in JWT validation, and enhances migration and module registration logic. The changes focus on increasing test coverage, improving robustness, and ensuring correct module behavior.
Testing improvements:
Added extensive unit tests for the JWK module, including keeper logic, audience operations, genesis import/export/validation, and migration flows in the following files:
x/jwk/keeper/keeper_test.go
,x/jwk/keeper/audience_test.go
,x/jwk/keeper/migrations_test.go
,x/jwk/genesis_test.go
, andx/jwk/migrations/v1/migration_test.go
. This ensures that all major module functions are covered and validated. [1] [2] [3] [4] [5]Added a shell script
scripts/test-coverage.sh
to run Go tests with coverage, filter out generated protobuf files, and display summary statistics for overall and per-module coverage, highlighting areas with 0% or low coverage.Defensive programming and robustness:
Improved the
ValidateJWT
query handler to add a panic recovery guard around JWT parsing, check for empty JWT input, and ensure per-call JWT options for thread safety, preventing unexpected panics and improving error handling.Fixed a bug in audience pagination by checking for a nil pagination request before accessing its fields, preventing potential panics on invalid requests.
Migration and module registration enhancements:
Added interface marker methods to
AppModule
to clarify module instantiation and interface compliance, improving maintainability and clarity.Enhanced
AppModule.RegisterServices
to explicitly register message/query servers and migrations, ensuring correct initialization and upgrade paths for the module.x/jwk/types/params.go change