Skip to content

Commit

Permalink
Test netInfo in full_client_test.go (rollkit#1267)
Browse files Browse the repository at this point in the history
closes: rollkit#1260 

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

- **Tests**
- Implemented a new test `TestNetInfo` to verify the network information
functionality, ensuring the node correctly reports its listening status
and has no connected peers.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
  • Loading branch information
chandiniv1 authored Nov 15, 2023
1 parent cd29405 commit f96b077
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions node/full_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1172,3 +1172,27 @@ func TestHealth(t *testing.T) {
assert.Nil(err)
assert.Empty(resultHealth)
}

func TestNetInfo(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() {
err := rpc.node.Stop()
require.NoError(err)
}()

netInfo, err := rpc.NetInfo(context.Background())
require.NoError(err)
assert.NotNil(netInfo)
assert.True(netInfo.Listening)
assert.Equal(0, len(netInfo.Peers))
}

0 comments on commit f96b077

Please sign in to comment.