Skip to content

Commit 2aaa9d0

Browse files
authored
ConsensusState/DumpConsensusState implementation (cosmos#273)
* feat: ConsensusState/DumpConsensusState implementation Resolves cosmos#242 Resolves cosmos#243
1 parent 67f51f7 commit 2aaa9d0

File tree

3 files changed

+23
-4
lines changed

3 files changed

+23
-4
lines changed

CHANGELOG-PENDING.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ Month, DD, YYYY
2222
- [rpc] [Implement BlockByHash #256](https://github.com/celestiaorg/optimint/pull/256) [@mauriceLC92](https://github.com/mauriceLC92)
2323
- [rpc] [Implement BlockResults #263](https://github.com/celestiaorg/optimint/pull/263) [@tzdybal](https://github.com/tzdybal/)
2424
- [store,indexer] [Replace tm-db dependency with store package #268](https://github.com/celestiaorg/optimint/pull/268) [@tzdybal](https://github.com/tzdybal/)
25+
- [rpc] [Implement ConsensusState/DumpConsensusState #273](https://github.com/celestiaorg/optimint/pull/273) [@tzdybal](https://github.com/tzdybal/)
2526

2627
### BUG FIXES
2728
- [store] [Use KeyCopy instead of Key in BadgerIterator #274](https://github.com/celestiaorg/optimint/pull/274) [@tzdybal](https://github.com/tzdybal/)

rpc/client/client.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,10 @@ const (
3131
subscribeTimeout = 5 * time.Second
3232
)
3333

34+
var (
35+
ErrConsensusStateNotAvailable = errors.New("consensus state not available in Optimint")
36+
)
37+
3438
var _ rpcclient.Client = &Client{}
3539

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

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

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

303305
func (c *Client) ConsensusParams(ctx context.Context, height *int64) (*ctypes.ResultConsensusParams, error) {

rpc/client/client_test.go

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,22 @@ func TestUnconfirmedTxsLimit(t *testing.T) {
333333
assert.NotContains(txRes.Txs, tx2)
334334
}
335335

336+
func TestConsensusState(t *testing.T) {
337+
assert := assert.New(t)
338+
require := require.New(t)
339+
340+
_, rpc := getRPC(t)
341+
require.NotNil(rpc)
342+
343+
resp1, err := rpc.ConsensusState(context.Background())
344+
assert.Nil(resp1)
345+
assert.ErrorIs(err, ErrConsensusStateNotAvailable)
346+
347+
resp2, err := rpc.DumpConsensusState(context.Background())
348+
assert.Nil(resp2)
349+
assert.ErrorIs(err, ErrConsensusStateNotAvailable)
350+
}
351+
336352
// copy-pasted from store/store_test.go
337353
func getRandomBlock(height uint64, nTxs int) *types.Block {
338354
block := &types.Block{

0 commit comments

Comments
 (0)