-
Notifications
You must be signed in to change notification settings - Fork 31
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
(cherry picked from commit 97219d5) * Add CHANGELOG * Resolve ostracon conflicts --------- Co-authored-by: Jaeseung Lee <[email protected]>
- Loading branch information
1 parent
7d2a15f
commit 48480c1
Showing
20 changed files
with
2,159 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
package client | ||
|
||
import ( | ||
"context" | ||
|
||
rpcclient "github.com/Finschia/ostracon/rpc/client" | ||
coretypes "github.com/Finschia/ostracon/rpc/core/types" | ||
) | ||
|
||
// TendermintRPC defines the interface of a Tendermint RPC client needed for | ||
// queries and transaction handling. | ||
type TendermintRPC interface { | ||
rpcclient.ABCIClient | ||
|
||
Validators(ctx context.Context, height *int64, page, perPage *int) (*coretypes.ResultValidators, error) | ||
Status(context.Context) (*coretypes.ResultStatus, error) | ||
Block(ctx context.Context, height *int64) (*coretypes.ResultBlock, error) | ||
BlockchainInfo(ctx context.Context, minHeight, maxHeight int64) (*coretypes.ResultBlockchainInfo, error) | ||
Commit(ctx context.Context, height *int64) (*coretypes.ResultCommit, error) | ||
Tx(ctx context.Context, hash []byte, prove bool) (*coretypes.ResultTx, error) | ||
TxSearch( | ||
ctx context.Context, | ||
query string, | ||
prove bool, | ||
page, perPage *int, | ||
orderBy string, | ||
) (*coretypes.ResultTxSearch, error) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package cli | ||
|
||
import ( | ||
"context" | ||
|
||
tmbytes "github.com/Finschia/ostracon/libs/bytes" | ||
rpcclient "github.com/Finschia/ostracon/rpc/client" | ||
rpcclientmock "github.com/Finschia/ostracon/rpc/client/mock" | ||
coretypes "github.com/Finschia/ostracon/rpc/core/types" | ||
tmtypes "github.com/Finschia/ostracon/types" | ||
abci "github.com/tendermint/tendermint/abci/types" | ||
|
||
"github.com/Finschia/finschia-sdk/client" | ||
) | ||
|
||
var _ client.TendermintRPC = (*MockTendermintRPC)(nil) | ||
|
||
type MockTendermintRPC struct { | ||
rpcclientmock.Client | ||
|
||
responseQuery abci.ResponseQuery | ||
} | ||
|
||
// NewMockTendermintRPC returns a mock TendermintRPC implementation. | ||
// It is used for CLI testing. | ||
func NewMockTendermintRPC(respQuery abci.ResponseQuery) MockTendermintRPC { | ||
return MockTendermintRPC{responseQuery: respQuery} | ||
} | ||
|
||
func (MockTendermintRPC) BroadcastTxSync(context.Context, tmtypes.Tx) (*coretypes.ResultBroadcastTx, error) { | ||
return &coretypes.ResultBroadcastTx{Code: 0}, nil | ||
} | ||
|
||
func (m MockTendermintRPC) ABCIQueryWithOptions( | ||
_ context.Context, | ||
_ string, | ||
_ tmbytes.HexBytes, | ||
_ rpcclient.ABCIQueryOptions, | ||
) (*coretypes.ResultABCIQuery, error) { | ||
return &coretypes.ResultABCIQuery{Response: m.responseQuery}, nil | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
package testutil | ||
|
||
import ( | ||
"github.com/Finschia/finschia-sdk/client" | ||
"github.com/Finschia/finschia-sdk/codec" | ||
"github.com/Finschia/finschia-sdk/codec/types" | ||
"github.com/Finschia/finschia-sdk/std" | ||
"github.com/Finschia/finschia-sdk/types/module" | ||
"github.com/Finschia/finschia-sdk/x/auth/tx" | ||
) | ||
|
||
// TestEncodingConfig defines an encoding configuration that is used for testing | ||
// purposes. Note, MakeTestEncodingConfig takes a series of AppModuleBasic types | ||
// which should only contain the relevant module being tested and any potential | ||
// dependencies. | ||
type TestEncodingConfig struct { | ||
InterfaceRegistry types.InterfaceRegistry | ||
Codec codec.Codec | ||
TxConfig client.TxConfig | ||
Amino *codec.LegacyAmino | ||
} | ||
|
||
func MakeTestEncodingConfig(modules ...module.AppModuleBasic) TestEncodingConfig { | ||
aminoCdc := codec.NewLegacyAmino() | ||
interfaceRegistry := types.NewInterfaceRegistry() | ||
cdc := codec.NewProtoCodec(interfaceRegistry) | ||
|
||
encCfg := TestEncodingConfig{ | ||
InterfaceRegistry: interfaceRegistry, | ||
Codec: cdc, | ||
TxConfig: tx.NewTxConfig(cdc, tx.DefaultSignModes), | ||
Amino: aminoCdc, | ||
} | ||
|
||
mb := module.NewBasicManager(modules...) | ||
|
||
std.RegisterLegacyAminoCodec(encCfg.Amino) | ||
std.RegisterInterfaces(encCfg.InterfaceRegistry) | ||
mb.RegisterLegacyAminoCodec(encCfg.Amino) | ||
mb.RegisterInterfaces(encCfg.InterfaceRegistry) | ||
|
||
return encCfg | ||
} | ||
|
||
func MakeTestTxConfig() client.TxConfig { | ||
interfaceRegistry := types.NewInterfaceRegistry() | ||
cdc := codec.NewProtoCodec(interfaceRegistry) | ||
return tx.NewTxConfig(cdc, tx.DefaultSignModes) | ||
} | ||
|
||
type TestBuilderTxConfig struct { | ||
client.TxConfig | ||
TxBuilder *TestTxBuilder | ||
} | ||
|
||
func MakeBuilderTestTxConfig() TestBuilderTxConfig { | ||
return TestBuilderTxConfig{ | ||
TxConfig: MakeTestTxConfig(), | ||
} | ||
} | ||
|
||
func (cfg TestBuilderTxConfig) NewTxBuilder() client.TxBuilder { | ||
if cfg.TxBuilder == nil { | ||
cfg.TxBuilder = &TestTxBuilder{ | ||
TxBuilder: cfg.TxConfig.NewTxBuilder(), | ||
} | ||
} | ||
return cfg.TxBuilder | ||
} | ||
|
||
type TestTxBuilder struct { | ||
client.TxBuilder | ||
ExtOptions []*types.Any | ||
} | ||
|
||
func (b *TestTxBuilder) SetExtensionOptions(extOpts ...*types.Any) { | ||
b.ExtOptions = extOpts | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.