-
Notifications
You must be signed in to change notification settings - Fork 3.8k
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
test: add counter module #18272
test: add counter module #18272
Conversation
Warning Rate Limit Exceeded@tac0turtle has exceeded the limit for the number of files or commits that can be reviewed per hour. Please wait 15 minutes and 38 seconds before requesting another review. How to resolve this issue?After the wait time has elapsed, a review can be triggered using the @coderabbitai review command. Alternatively, push new commits to this PR. We recommend that you space out your commits to avoid hitting the rate limit. How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per repository. WalkthroughThe changes primarily involve a shift from using the Changes
Poem
TipsChat with CodeRabbit Bot (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 3
Configuration used: CodeRabbit UI
Files ignored due to filter (42)
- client/v2/go.mod
- client/v2/go.sum
- go.mod
- go.sum
- simapp/go.mod
- simapp/go.sum
- simapp/gomod2nix.toml
- tests/go.mod
- tests/go.sum
- tests/starship/tests/go.mod
- tests/starship/tests/go.sum
- x/authz/go.mod
- x/authz/go.sum
- x/bank/go.mod
- x/bank/go.sum
- x/circuit/go.mod
- x/circuit/go.sum
- x/counter/types/tx.pb.go
- x/distribution/go.mod
- x/distribution/go.sum
- x/evidence/go.mod
- x/evidence/go.sum
- x/feegrant/go.mod
- x/feegrant/go.sum
- x/gov/go.mod
- x/gov/go.sum
- x/group/go.mod
- x/group/go.sum
- x/mint/go.mod
- x/mint/go.sum
- x/nft/go.mod
- x/nft/go.sum
- x/params/go.mod
- x/params/go.sum
- x/protocolpool/go.mod
- x/protocolpool/go.sum
- x/slashing/go.mod
- x/slashing/go.sum
- x/staking/go.mod
- x/staking/go.sum
- x/upgrade/go.mod
- x/upgrade/go.sum
Files selected for processing (19)
- api/cosmos/counter/v1/tx.pulsar.go (2 hunks)
- client/fuzz_test.go (2 hunks)
- client/grpc_query_test.go (1 hunks)
- client/tx/aux_builder_test.go (2 hunks)
- client/tx/legacy_test.go (2 hunks)
- client/tx/tx_test.go (8 hunks)
- codec/bench_test.go (4 hunks)
- codec/proto_codec_test.go (3 hunks)
- collections/README.md (6 hunks)
- proto/cosmos/counter/v1/tx.proto (2 hunks)
- testutil/integration/doc.go (1 hunks)
- types/mempool/mempool_test.go (3 hunks)
- x/circuit/types/keys.go (1 hunks)
- x/counter/README.md (1 hunks)
- x/counter/keeper/keeper.go (1 hunks)
- x/counter/module.go (1 hunks)
- x/counter/testutil/expected_keepers_mocks.go (1 hunks)
- x/counter/types/codec.go (1 hunks)
- x/counter/types/keys.go (1 hunks)
Files skipped from review due to trivial changes (8)
- client/grpc_query_test.go
- client/tx/aux_builder_test.go
- collections/README.md
- testutil/integration/doc.go
- x/circuit/types/keys.go
- x/counter/README.md
- x/counter/types/codec.go
- x/counter/types/keys.go
Additional comments: 48
x/counter/testutil/expected_keepers_mocks.go (1)
- 1-228: This is a generated mock file for testing purposes. It seems to be correctly generated and follows the standard GoMock conventions. Ensure that the methods in the
MockAccountKeeper
struct match the methods in theAccountKeeper
interface. If the interface changes, this mock file should be regenerated to reflect those changes.proto/cosmos/counter/v1/tx.proto (2)
4-10: The import statement for "amino/amino.proto" has been added. Ensure that this import is necessary and that the package is included in the project dependencies.
20-24: The option "(amino.name) = "cosmos-sdk/increase_counter";" has been added to the message "MsgIncreaseCounter". This seems to be a temporary measure as indicated by the comment "TODO: remove amino". Ensure that this is tracked and removed as planned.
client/tx/legacy_test.go (2)
1-6: The import statements have been updated to include the new
counter
module and remove the oldbank
module. Ensure that thecounter
module is correctly implemented and that it provides all the necessary types and functions that were previously provided by thebank
module.17-17: The
msg1
variable has been updated to use theMsgIncreaseCounter
type from thecounter
module. Ensure that all uses ofmsg1
in the code are compatible with this new type.api/cosmos/counter/v1/tx.pulsar.go (2)
- 2-8: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [5-9]
The import statement for "cosmossdk.io/api/amino" has been added. Ensure that this package is being used in the code and is not an unnecessary import. If it's not used, it should be removed to keep the code clean and maintainable.
- 995-1027: The function "MsgIncreaseCounter" has been modified to include a new parameter "signer". Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, the function "MsgIncreaseCounterResponse" has been modified to include a new field "new_count". Make sure that the response handling code is updated to handle this new field.
codec/proto_codec_test.go (3)
16-23: The import statements have been updated to include the new
counter
module and its types. Ensure that thecounter
module is correctly implemented and that it provides the necessary functionality that was previously provided by thebank
module.114-117: This test case checks if a typed nil input to the
grpcServerEncode
function doesn't cause a panic. It's good to see that edge cases are being considered in the tests.187-195: The test case checks if the
GetMsgV1Signers
function correctly retrieves the signers from aMsgIncreaseCounter
message. It's good to see that the newcounter
module is being thoroughly tested.client/fuzz_test.go (3)
10-12: The import paths have been updated to reflect the new
counter
module. Ensure that the new import paths are correct and thecounter
module is available at the specified location.18-21: The function
FuzzQueryBalance
has been renamed toFuzzQuery
. Ensure that all references to this function in the codebase have been updated to reflect the new name.26-48: The type
types.QueryBalanceRequest
has been replaced withtypes.QueryGetCountRequest
and the functionBalance
has been replaced withGetCount
in the gRPC query call. Ensure that theGetCount
function is implemented in thecounter
module and that it behaves as expected.types/mempool/mempool_test.go (5)
10-15: The import statements look fine. No issues found.
18-22: The import of the new
counter
module is correctly placed. Ensure that thecounter
module is correctly implemented and available at the specified location.226-234: The test function
TestSampleTxs
is updated to use thecounter
module. Ensure that theunmarshalTx
function andmsgCounter
variable are correctly implemented to work with thecounter
module.236-239: The
unmarshalTx
function is updated to use thecounter
module. Ensure that thecounter.AppModuleBasic{}
is correctly implemented and can be used to create a test encoding config.241-241: The
msgCounter
variable is updated to represent a counter message. Ensure that the message is correctly formatted and can be used with thecounter
module.x/counter/keeper/keeper.go (4)
20-24: The
Keeper
struct has been updated to include two new fields:event
of typeevent.Service
andCountStore
of typecollections.Item[int64]
. Ensure that these new fields are properly initialized and used throughout the codebase.26-32: The
NewKeeper
function now accepts an additional parameterem
of typeevent.Service
and initializes the new fieldsevent
andCountStore
. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.38-50: The
GetCount
function now returns a*types.QueryGetCountResponse
and an error. This is a change from the previous return type. Ensure that all calls to this function throughout the codebase have been updated to handle the new return type.56-82: The
IncreaseCount
function now returns a*types.MsgIncreaseCountResponse
and an error. This is a change from the previous return type. Ensure that all calls to this function throughout the codebase have been updated to handle the new return type.codec/bench_test.go (6)
10-16: The import statements have been updated to include the new
counter
module and its types. Ensure that the paths are correct and the module is properly installed.19-26: The
msgCounterWrapper
struct and itsGetSigners
method have been updated to use theSigner
field from theMsgIncreaseCounter
message. This change is consistent with the switch from thebank
module to thecounter
module.28-35: In the
BenchmarkLegacyGetSigners
function, themsgCounterWrapper
is being used with theMsgIncreaseCounter
message. This is consistent with the switch from thebank
module to thecounter
module.43-51: In the
BenchmarkProtoreflectGetSigners
function, theMsgIncreaseCounter
message from thecounter
module is being used. This is consistent with the switch from thebank
module to thecounter
module.61-69: In the
BenchmarkProtoreflectGetSignersWithUnmarshal
function, theMsgIncreaseCounter
message from thecounter
module is being used. This is consistent with the switch from thebank
module to thecounter
module.82-90: In the
BenchmarkProtoreflectGetSignersDynamicpb
function, theMsgIncreaseCounter
message from thecounter
module is being used. This is consistent with the switch from thebank
module to thecounter
module.client/tx/tx_test.go (8)
9-14: The import statements look fine. No changes needed.
24-28: The import statement for the
counter
module has been added correctly.126-132: The
MsgIncreaseCounter
message is being created and used correctly. Ensure that theSigner
field is being set to a valid account address and that theCount
field is being set to an appropriate value.142-148: The
MsgIncreaseCounter
message is being created and used correctly. Ensure that theSigner
field is being set to a valid account address and that theCount
field is being set to an appropriate value.161-167: The
MsgIncreaseCounter
message is being created and used correctly. Ensure that theSigner
field is being set to a valid account address and that theCount
field is being set to an appropriate value.204-210: The
MsgIncreaseCounter
message is being created and used correctly. Ensure that theSigner
field is being set to a valid account address and that theCount
field is being set to an appropriate value.255-262: The
MsgIncreaseCounter
message is being created and used correctly. Ensure that theSigner
field is being set to a valid account address and that theCount
field is being set to an appropriate value.403-410: The
MsgIncreaseCounter
message is being created and used correctly. Ensure that theSigner
field is being set to a valid account address and that theCount
field is being set to an appropriate value.x/counter/module.go (12)
1-19: The import statements look fine. Ensure that all the imported packages are being used in the code. Also, make sure that the versions of these packages are compatible with each other.
24-29: The
AppModule
struct is correctly implementing themodule.AppModuleBasic
,appmodule.AppModule
, andappmodule.HasServices
interfaces. This is verified by the blank variable declarations.31-34: The
AppModuleBasic
struct is defined with acdc
field of typecodec.Codec
. Ensure that this field is used appropriately in the methods of this struct.36-48: The methods
Name
,RegisterLegacyAminoCodec
,RegisterGRPCGatewayRoutes
, andRegisterInterfaces
are defined for theAppModuleBasic
struct. Ensure that these methods are used correctly in the application.50-55: The
AppModule
struct is defined with an embeddedAppModuleBasic
and akeeper
field of typekeeper.Keeper
. Ensure that these fields are used appropriately in the methods of this struct.57-68: The methods
IsOnePerModuleType
,IsAppModule
, andRegisterServices
are defined for theAppModule
struct. Ensure that these methods are used correctly in the application.70-76: The
NewAppModule
function is defined to create a newAppModule
object. Ensure that this function is used correctly in the application.78-80: The
ConsensusVersion
method is defined for theAppModule
struct. Ensure that this method is used correctly in the application.81-86: The
init
function is defined to register themodulev1.Module
andProvideModule
function. Ensure that these are used correctly in the application.88-95: The
ModuleInputs
struct is defined with several fields. Ensure that these fields are used appropriately in the methods of this struct.97-102: The
ModuleOutputs
struct is defined with aKeeper
field of typekeeper.Keeper
and aModule
field of typeappmodule.AppModule
. Ensure that these fields are used appropriately in the methods of this struct.104-113: The
ProvideModule
function is defined to create a newModuleOutputs
object. Ensure that this function is used correctly in the application.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 5
Configuration used: CodeRabbit UI
Files ignored due to filter (42)
- client/v2/go.mod
- client/v2/go.sum
- go.mod
- go.sum
- simapp/go.mod
- simapp/go.sum
- simapp/gomod2nix.toml
- tests/go.mod
- tests/go.sum
- tests/starship/tests/go.mod
- tests/starship/tests/go.sum
- x/authz/go.mod
- x/authz/go.sum
- x/bank/go.mod
- x/bank/go.sum
- x/circuit/go.mod
- x/circuit/go.sum
- x/counter/types/tx.pb.go
- x/distribution/go.mod
- x/distribution/go.sum
- x/evidence/go.mod
- x/evidence/go.sum
- x/feegrant/go.mod
- x/feegrant/go.sum
- x/gov/go.mod
- x/gov/go.sum
- x/group/go.mod
- x/group/go.sum
- x/mint/go.mod
- x/mint/go.sum
- x/nft/go.mod
- x/nft/go.sum
- x/params/go.mod
- x/params/go.sum
- x/protocolpool/go.mod
- x/protocolpool/go.sum
- x/slashing/go.mod
- x/slashing/go.sum
- x/staking/go.mod
- x/staking/go.sum
- x/upgrade/go.mod
- x/upgrade/go.sum
Files selected for processing (19)
- api/cosmos/counter/v1/tx.pulsar.go (2 hunks)
- client/fuzz_test.go (2 hunks)
- client/grpc_query_test.go (1 hunks)
- client/tx/aux_builder_test.go (2 hunks)
- client/tx/legacy_test.go (2 hunks)
- client/tx/tx_test.go (8 hunks)
- codec/bench_test.go (4 hunks)
- codec/proto_codec_test.go (3 hunks)
- collections/README.md (6 hunks)
- proto/cosmos/counter/v1/tx.proto (2 hunks)
- testutil/integration/doc.go (1 hunks)
- types/mempool/mempool_test.go (3 hunks)
- x/circuit/types/keys.go (1 hunks)
- x/counter/README.md (1 hunks)
- x/counter/keeper/keeper.go (1 hunks)
- x/counter/module.go (1 hunks)
- x/counter/testutil/expected_keepers_mocks.go (1 hunks)
- x/counter/types/codec.go (1 hunks)
- x/counter/types/keys.go (1 hunks)
Files skipped from review due to trivial changes (8)
- client/grpc_query_test.go
- client/tx/aux_builder_test.go
- client/tx/legacy_test.go
- collections/README.md
- testutil/integration/doc.go
- x/circuit/types/keys.go
- x/counter/README.md
- x/counter/types/keys.go
Additional comments: 39
x/counter/types/codec.go (1)
- 1-16: The new package
types
and the functionRegisterInterfaces
seem to be correctly implemented. The function registers theMsgIncreaseCounter
message and the message service descriptor as expected. Ensure that theMsgIncreaseCounter
message and the_Msg_serviceDesc
are correctly defined and implemented elsewhere in the codebase. Also, make sure that theRegisterInterfaces
function is called during the initialization of the application to register the interfaces with the Cosmos SDK.proto/cosmos/counter/v1/tx.proto (2)
4-10: The import statement for "amino/amino.proto" has been added. Ensure that the Amino library is being used correctly and that it is compatible with the rest of the codebase. Also, ensure that the Amino library is maintained and secure to use.
21-24: The option "(amino.name) = "cosmos-sdk/increase_counter";" has been added to the message "MsgIncreaseCounter". This seems to be a temporary measure as indicated by the comment "TODO: remove amino". It would be good to clarify the timeline and plan for this removal.
codec/proto_codec_test.go (3)
13-24: The import statements have been updated to include the new
counter
module and remove the oldbank
module. Ensure that the new import paths are correct and that all dependencies for thecounter
module are properly installed.111-117: The variable
v
has been changed from*banktypes.QueryBalanceResponse
to*countertypes.QueryGetCountRequest
. Ensure that this change is consistent with the rest of the codebase and that all instances ofQueryBalanceResponse
have been replaced withQueryGetCountRequest
where necessary.187-195: The variables
msgSendV1
andmsgSendV2
have been changed from*banktypes.MsgSend
and*bankv1beta1.MsgSend
to*countertypes.MsgIncreaseCounter
and*counterv1.MsgIncreaseCounter
respectively. Ensure that this change is consistent with the rest of the codebase and that all instances ofMsgSend
have been replaced withMsgIncreaseCounter
where necessary.client/fuzz_test.go (5)
10-11: The import paths have been updated to reflect the new
counter
module. Ensure that the new import paths are correct and thecounter
module is properly installed.18-21: The function
FuzzQueryBalance
has been renamed toFuzzQuery
. Ensure that all calls to this function throughout the codebase have been updated to match the new name.29-30: The type
types.QueryBalanceRequest
has been replaced withtypes.QueryGetCountRequest
. Ensure that this change is consistent with the newcounter
module's API.33-48: The function
Balance
has been replaced withGetCount
in the gRPC query call. Ensure that this change is consistent with the newcounter
module's API.51-56: The function
FuzzQuery
has been updated to use the newfuzzSuite
struct. Ensure that this change is consistent with the newcounter
module's API.x/counter/keeper/keeper.go (4)
20-24: The
Keeper
struct has been updated to include two new fields:event
andCountStore
. Ensure that these fields are properly initialized and used throughout the codebase.26-32: The
NewKeeper
function has been updated to include a new parameterem
of typeevent.Service
. This function now initializes the new fields in theKeeper
struct. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.38-50: The
GetCount
function now returns a*types.QueryGetCountResponse
and anerror
. This is a change from the previous version of the function. Ensure that all calls to this function throughout the codebase have been updated to handle the new return types.56-82: The
IncreaseCount
function now returns a*types.MsgIncreaseCountResponse
and anerror
. This is a change from the previous version of the function. Ensure that all calls to this function throughout the codebase have been updated to handle the new return types.types/mempool/mempool_test.go (4)
10-15: The import statements look fine. Ensure that all the imported packages are used in the code.
18-22: The import statement for the
counter
module has been added. Ensure that thecounter
module is used in the code.226-234: The
unmarshalTx
function is used to unmarshal themsgCounter
byte array into asdk.Tx
type. Ensure that themsgCounter
byte array is correctly formatted and can be unmarshalled without errors.237-239: The
unmarshalTx
function uses thecounter.AppModuleBasic{}
to create a test encoding configuration. Ensure that thecounter.AppModuleBasic{}
is correctly implemented and can be used to create a test encoding configuration.241:
ThemsgCounter
byte array is used to test theunmarshalTx
function. Ensure that themsgCounter
byte array is correctly formatted and can be unmarshalled into asdk.Tx
type.client/tx/tx_test.go (7)
24-28: The import statement for the
counter
module has been added. Ensure that the module is correctly installed and available in the project's dependencies.128-132: The
MsgIncreaseCounter
message from thecounter
module is being used. Ensure that theSigner
andCount
fields are correctly set and that the message is correctly processed in thecounter
module.142-148: > Note: This review was outside of the patch, so it was mapped to the patch with the greatest overlap. Original lines [145-149]
The
MsgIncreaseCounter
message from thecounter
module is being used. Ensure that theSigner
andCount
fields are correctly set and that the message is correctly processed in thecounter
module.
163-167: The
MsgIncreaseCounter
message from thecounter
module is being used. Ensure that theSigner
andCount
fields are correctly set and that the message is correctly processed in thecounter
module.206-210: The
MsgIncreaseCounter
message from thecounter
module is being used. Ensure that theSigner
andCount
fields are correctly set and that the message is correctly processed in thecounter
module.255-262: The
MsgIncreaseCounter
message from thecounter
module is being used. Ensure that theSigner
andCount
fields are correctly set and that the message is correctly processed in thecounter
module.403-410: The
MsgIncreaseCounter
message from thecounter
module is being used. Ensure that theSigner
andCount
fields are correctly set and that the message is correctly processed in thecounter
module.codec/bench_test.go (6)
10-16: Ensure that the new import paths are correct and the
counter
module is properly installed in your environment.19-26: The
msgCounterWrapper
struct and itsGetSigners
method seem to be correctly implemented. However, ensure that theSigner
field inMsgIncreaseCounter
is always a valid Bech32 address, as theGetSigners
method assumes this without error checking.28-35: In the
BenchmarkLegacyGetSigners
function, themsgCounterWrapper
is correctly initialized and used.43-51: In the
BenchmarkProtoreflectGetSigners
function, theMsgIncreaseCounter
message is correctly initialized and used.61-69: In the
BenchmarkProtoreflectGetSignersWithUnmarshal
function, theMsgIncreaseCounter
message is correctly initialized and used.82-90: In the
BenchmarkProtoreflectGetSignersDynamicpb
function, theMsgIncreaseCounter
message is correctly initialized and used.x/counter/testutil/expected_keepers_mocks.go (1)
- 1-228: This is a generated mock file for testing purposes. It seems to be correctly generated and follows the standard GoMock conventions. The methods in the
MockAccountKeeper
struct match the methods in theAccountKeeper
interface, and theMockAccountKeeperMockRecorder
struct provides a way to set up expectations for those methods in tests. TheNewMockAccountKeeper
function correctly creates a new instance ofMockAccountKeeper
. TheEXPECT
method returns the recorder for setting up expectations. The mock methods correctly delegate to theCall
method of thegomock.Controller
, and the recorder methods correctly record calls with theRecordCallWithMethodType
method of thegomock.Controller
. TheValidatePermissions
method has been correctly added to theAccountKeeper
interface and the corresponding mock and recorder methods have been added to theMockAccountKeeper
andMockAccountKeeperMockRecorder
structs.x/counter/module.go (4)
1-19: Ensure that all the imported packages are used in the code. Unused imports can lead to compilation errors in Go.
64-68: The
RegisterServices
function registers theMsgServer
andQueryServer
with thekeeper
instance. Ensure that thekeeper
instance is properly initialized before this function is called.71-76: The
NewAppModule
function creates a newAppModule
instance. Ensure that thecdc
andkeeper
parameters are properly initialized before this function is called.104-113: The
ProvideModule
function creates a newKeeper
andAppModule
instance. Ensure that theStoreService
andEventManager
fields in theModuleInputs
struct are properly initialized before this function is called.api/cosmos/counter/v1/tx.pulsar.go (2)
5-8: The import statement for "cosmossdk.io/api/amino" has been added. Ensure that this package is used in the code and is not an unnecessary import. If it's not used, it should be removed to keep the code clean and maintainable.
998-1008: The function "MsgIncreaseCounter" has been modified to include a new parameter "signer". Ensure that all calls to this function throughout the codebase have been updated to match the new signature. Also, the function "MsgIncreaseCounterResponse" has been modified to include a new field "new_count". Make sure that this new field is handled properly in the function's usage.
client/fuzz_test.go
Outdated
fz.Require().NoError(err) | ||
f.Add(bz) | ||
|
||
// 2. Now fuzz it and ensure that we don't get any panics. | ||
ctx := context.Background() | ||
// ctx := context.Background() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The parameter ctx
in the function FuzzQuery
has been commented out. If this context is not needed, it should be removed. If it is needed, it should be uncommented and used appropriately.
- // ctx := context.Background()
+ ctx := context.Background()
Commitable suggestion (Beta)
// ctx := context.Background() | |
ctx := context.Background() |
@@ -17,6 +18,7 @@ service Msg { | |||
|
|||
// MsgIncreaseCounter defines a count Msg service counter. | |||
message MsgIncreaseCounter { | |||
option (amino.name) = "cosmos-sdk/increase_counter"; // TODO: remove amino |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
aux builder test fails without this but its not required anymore, ill look into the test to see if we can remove this here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review Status
Actionable comments generated: 1
Configuration used: CodeRabbit UI
Files selected for processing (3)
- client/fuzz_test.go (2 hunks)
- x/counter/keeper/keeper.go (1 hunks)
- x/counter/module.go (1 hunks)
Additional comments: 14
client/fuzz_test.go (4)
10-11: The import paths have been updated to include the new
counter
module and remove the oldbank
module. Ensure that the new import paths are correct and that thecounter
module is correctly implemented in the codebase.18-21: The function
FuzzQuery
has been updated to use the newcounter
module. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.26-48: The marshaling and unmarshaling of different request types have been changed from
types.QueryBalanceRequest
totypes.QueryGetCountRequest
. The gRPC query function has been changed fromfz.bankClient.Balance
tofz.counterClient.GetCount
. Ensure that these changes are correct and that the new request types and gRPC query function are correctly implemented in the codebase.51-56: The function
FuzzQuery
has been updated to use the newcounter
module. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.x/counter/module.go (5)
35-36: As per the previous discussion, the
RegisterLegacyAminoCodec
function is kept as boilerplate and will be addressed in a separate issue.38-39: As per the previous discussion, the
RegisterGRPCGatewayRoutes
function is kept as boilerplate and will be addressed in a separate issue.59-63: The
RegisterServices
function correctly registers theMsgServer
andQueryServer
with thekeeper
. This is a good practice as it allows the module to handle messages and queries.66-71: The
NewAppModule
function correctly initializes a newAppModule
with the providedkeeper
. This is a good practice as it allows the module to manage state and handle messages and queries.99-108: The
ProvideModule
function correctly initializes a newKeeper
andAppModule
and returns them in aModuleOutputs
struct. This is a good practice as it allows the module to manage state and handle messages and queries.x/counter/keeper/keeper.go (5)
1-16: The import statements look good and are well organized.
20-24: The
Keeper
struct has been updated to include new fieldsevent
andCountStore
. Ensure that these fields are used correctly throughout the codebase.26-32: The
NewKeeper
function has been updated to include a new parameterem
and initialize the newevent
field. Ensure that all calls to this function throughout the codebase have been updated to match the new signature.38-50: The
GetCount
function now returns a*types.QueryGetCountResponse
and anerror
. This is a breaking change and should be communicated to all users of this function.56-81: The
IncreaseCount
function now returns a*types.MsgIncreaseCountResponse
and anerror
. This is a breaking change and should be communicated to all users of this function.
if err := k.event.EventManager(ctx).EmitKV( | ||
ctx, | ||
"increase_counter", | ||
event.Attribute{Key: "signer", Value: msg.Signer}, | ||
event.Attribute{Key: "new count", Value: fmt.Sprint(num + msg.Count)}); err != nil { | ||
return nil, err | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The event emission logic seems to be correct. However, it's a good practice to define event names and attribute keys as constants to avoid typos and improve maintainability.
+ const EventIncreaseCounter = "increase_counter"
+ const AttributeSigner = "signer"
+ const AttributeNewCount = "new count"
- "increase_counter"
+ EventIncreaseCounter
- "signer"
+ AttributeSigner
- "new count"
+ AttributeNewCount
Commitable suggestion (Beta)
if err := k.event.EventManager(ctx).EmitKV( | |
ctx, | |
"increase_counter", | |
event.Attribute{Key: "signer", Value: msg.Signer}, | |
event.Attribute{Key: "new count", Value: fmt.Sprint(num + msg.Count)}); err != nil { | |
return nil, err | |
} | |
const ( | |
EventIncreaseCounter = "increase_counter" | |
AttributeSigner = "signer" | |
AttributeNewCount = "new count" | |
) | |
if err := k.event.EventManager(ctx).EmitKV( | |
ctx, | |
EventIncreaseCounter, | |
event.Attribute{Key: AttributeSigner, Value: msg.Signer}, | |
event.Attribute{Key: AttributeNewCount, Value: fmt.Sprint(num + msg.Count)}, | |
); err != nil { | |
return nil, err | |
} |
[Cosmos SDK - Distribution] Kudos, SonarCloud Quality Gate passed! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If the dep on distribution and protocolpool is removed, we can remove those replaces from all other go.mod
@@ -28,34 +26,31 @@ func (fz *fuzzSuite) FuzzQueryBalance(f *testing.F) { | |||
fz.Require().Equal("hello", testRes.Message) | |||
|
|||
// 1. Generate some seeds. | |||
bz, err := fz.cdc.Marshal(&types.QueryBalanceRequest{ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sadly this won't give the fuzzer good direction and it'll take a long while to figure out how a request will look like. Perhaps this is temporary?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can move the fuzzing into the bank module but cant keep it at the root level
Description
This pr adds a small counter module meant to be used for testing when all modules have been spun out into their own go.mods
ref #18290
Author Checklist
All items are required. Please add a note to the item if the item is not applicable and
please add links to any relevant follow up issues.
I have...
!
to the type prefix if API or client breaking changeCHANGELOG.md
make lint
andmake test
Reviewers Checklist
All items are required. Please add a note if the item is not applicable and please add
your handle next to the items reviewed if you only reviewed selected items.
I have...
!
in the type prefix if API or client breaking changeSummary by CodeRabbit
New Features:
Refactor:
Documentation:
Tests:
Chores: