Skip to content

Commit

Permalink
[Code Health] Ensure service module msg responses are non-empty (#973)
Browse files Browse the repository at this point in the history
# Summary

Ensure all supplier module msg responses are non-empty. This adds a
`Service` field to the following protobuf type(s), and updates the unit
tests to assert for presence and correctness.

- `MsgAddServiceResopnse`

## Issue

- #663

## Type of change

Select one or more from the following:

- [ ] New feature, functionality or library
- [ ] Consensus breaking; add the `consensus-breaking` label if so. See
#791 for details
- [ ] Bug fix
- [x] Code health or cleanup
- [ ] Documentation
- [ ] Other (specify)

## Testing

- [ ] **Documentation**: `make docusaurus_start`; only needed if you
make doc changes
- [ ] **Unit Tests**: `make go_develop_and_test`
- [ ] **LocalNet E2E Tests**: `make test_e2e`
- [ ] **DevNet E2E Tests**: Add the `devnet-test-e2e` label to the PR.

## Sanity Checklist

- [ ] I have tested my changes using the available tooling
- [ ] I have commented my code
- [ ] I have performed a self-review of my own code; both comments &
source code
- [ ] I create and reference any new tickets, if applicable
- [ ] I have left TODOs throughout the codebase, if applicable
  • Loading branch information
bryanchriswhite authored Dec 9, 2024
1 parent a6e99b1 commit 3faea85
Show file tree
Hide file tree
Showing 5 changed files with 242 additions and 84 deletions.
176 changes: 134 additions & 42 deletions api/poktroll/service/tx.pulsar.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion proto/poktroll/service/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,7 @@ message MsgAddService {
poktroll.shared.Service service = 2 [(gogoproto.nullable) = false]; // The Service being added to the network
}

message MsgAddServiceResponse {}
message MsgAddServiceResponse {
poktroll.shared.Service service = 1;
}

4 changes: 3 additions & 1 deletion x/service/keeper/msg_server_add_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -111,5 +111,7 @@ func (k msgServer) AddService(
k.SetService(ctx, msg.Service)

isSuccessful = true
return &types.MsgAddServiceResponse{}, nil
return &types.MsgAddServiceResponse{
Service: &msg.Service,
}, nil
}
3 changes: 2 additions & 1 deletion x/service/keeper/msg_server_add_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,12 @@ func TestMsgServer_AddService(t *testing.T) {
keepertest.AddAccToAccMapCoins(t, oldServiceOwnerAddr, volatile.DenomuPOKT, oneUPOKTGreaterThanFee)

// Add the service to the store
_, err := srv.AddService(ctx, &types.MsgAddService{
addSvcRes, err := srv.AddService(ctx, &types.MsgAddService{
OwnerAddress: oldServiceOwnerAddr,
Service: oldService,
})
require.NoError(t, err)
require.Equal(t, &oldService, addSvcRes.GetService())

// Validate the service was added
serviceFound, found := k.GetService(ctx, oldService.Id)
Expand Down
Loading

0 comments on commit 3faea85

Please sign in to comment.