Skip to content

Commit

Permalink
Test node health in full_client_test.go (cosmos#1290)
Browse files Browse the repository at this point in the history
closes: cosmos#1258 

<!-- This is an auto-generated comment: release notes by coderabbit.ai
-->
## Summary by CodeRabbit

Tests:
- Introduced a new test, `TestHealth`, to ensure the proper functioning
of the `Health` function in our node application. This test sets up a
mock application, starts the RPC server, and calls the `Health`
function. It asserts that the returned error is nil and the result is
empty. This addition enhances the overall quality and reliability of our
system.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
chandiniv1 authored Oct 30, 2023
1 parent a65652d commit 2694e6f
Showing 1 changed file with 21 additions and 0 deletions.
21 changes: 21 additions & 0 deletions node/full_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1191,3 +1191,24 @@ func TestFutureGenesisTime(t *testing.T) {

assert.True(beginBlockTime.After(genesisTime))
}

func TestHealth(t *testing.T) {
assert := assert.New(t)
require := require.New(t)

mockApp, rpc := getRPC(t)
mockApp.On("BeginBlock", mock.Anything).Return(abci.ResponseBeginBlock{})
mockApp.On("CheckTx", mock.Anything).Return(abci.ResponseCheckTx{})
mockApp.On("EndBlock", mock.Anything).Return(abci.ResponseEndBlock{})
mockApp.On("Commit", mock.Anything).Return(abci.ResponseCommit{})

err := rpc.node.Start()
require.NoError(err)
defer func() {
require.NoError(rpc.node.Stop())
}()

resultHealth, err := rpc.Health(context.Background())
assert.Nil(err)
assert.Empty(resultHealth)
}

0 comments on commit 2694e6f

Please sign in to comment.