Skip to content

Commit

Permalink
ConsensusState/DumpConsensusState implementation (cosmos#273)
Browse files Browse the repository at this point in the history
* feat: ConsensusState/DumpConsensusState implementation

Resolves cosmos#242
Resolves cosmos#243
  • Loading branch information
tzdybal authored Feb 4, 2022
1 parent 67f51f7 commit 2aaa9d0
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG-PENDING.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Month, DD, YYYY
- [rpc] [Implement BlockByHash #256](https://github.com/celestiaorg/optimint/pull/256) [@mauriceLC92](https://github.com/mauriceLC92)
- [rpc] [Implement BlockResults #263](https://github.com/celestiaorg/optimint/pull/263) [@tzdybal](https://github.com/tzdybal/)
- [store,indexer] [Replace tm-db dependency with store package #268](https://github.com/celestiaorg/optimint/pull/268) [@tzdybal](https://github.com/tzdybal/)
- [rpc] [Implement ConsensusState/DumpConsensusState #273](https://github.com/celestiaorg/optimint/pull/273) [@tzdybal](https://github.com/tzdybal/)

### BUG FIXES
- [store] [Use KeyCopy instead of Key in BadgerIterator #274](https://github.com/celestiaorg/optimint/pull/274) [@tzdybal](https://github.com/tzdybal/)
Expand Down
10 changes: 6 additions & 4 deletions rpc/client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ const (
subscribeTimeout = 5 * time.Second
)

var (
ErrConsensusStateNotAvailable = errors.New("consensus state not available in Optimint")
)

var _ rpcclient.Client = &Client{}

type Client struct {
Expand Down Expand Up @@ -291,13 +295,11 @@ func (c *Client) NetInfo(ctx context.Context) (*ctypes.ResultNetInfo, error) {
}

func (c *Client) DumpConsensusState(ctx context.Context) (*ctypes.ResultDumpConsensusState, error) {
// need consensus state
panic("DumpConsensusState - not implemented!")
return nil, ErrConsensusStateNotAvailable
}

func (c *Client) ConsensusState(ctx context.Context) (*ctypes.ResultConsensusState, error) {
// need consensus state
panic("ConsensusState - not implemented!")
return nil, ErrConsensusStateNotAvailable
}

func (c *Client) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error) {
Expand Down
16 changes: 16 additions & 0 deletions rpc/client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,22 @@ func TestUnconfirmedTxsLimit(t *testing.T) {
assert.NotContains(txRes.Txs, tx2)
}

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

_, rpc := getRPC(t)
require.NotNil(rpc)

resp1, err := rpc.ConsensusState(context.Background())
assert.Nil(resp1)
assert.ErrorIs(err, ErrConsensusStateNotAvailable)

resp2, err := rpc.DumpConsensusState(context.Background())
assert.Nil(resp2)
assert.ErrorIs(err, ErrConsensusStateNotAvailable)
}

// copy-pasted from store/store_test.go
func getRandomBlock(height uint64, nTxs int) *types.Block {
block := &types.Block{
Expand Down

0 comments on commit 2aaa9d0

Please sign in to comment.