mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-25 14:52:17 +00:00
Merge pull request #741 from tendermint/client-compile-time-assertions
rpc/client: use compile time assertions instead of methods
This commit is contained in:
commit
b234f7aba2
@ -39,17 +39,12 @@ func NewHTTP(remote, wsEndpoint string) *HTTP {
|
||||
}
|
||||
}
|
||||
|
||||
func (c *HTTP) _assertIsClient() Client {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *HTTP) _assertIsNetworkClient() NetworkClient {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c *HTTP) _assertIsEventSwitch() types.EventSwitch {
|
||||
return c
|
||||
}
|
||||
var (
|
||||
_ Client = (*HTTP)(nil)
|
||||
_ NetworkClient = (*HTTP)(nil)
|
||||
_ types.EventSwitch = (*HTTP)(nil)
|
||||
_ types.EventSwitch = (*WSEvents)(nil)
|
||||
)
|
||||
|
||||
func (c *HTTP) Status() (*ctypes.ResultStatus, error) {
|
||||
result := new(ctypes.ResultStatus)
|
||||
@ -220,10 +215,6 @@ func newWSEvents(remote, endpoint string) *WSEvents {
|
||||
}
|
||||
}
|
||||
|
||||
func (w *WSEvents) _assertIsEventSwitch() types.EventSwitch {
|
||||
return w
|
||||
}
|
||||
|
||||
// Start is the only way I could think the extend OnStart from
|
||||
// events.eventSwitch. If only it wasn't private...
|
||||
// BaseService.Start -> eventSwitch.OnStart -> WSEvents.Start
|
||||
|
@ -41,13 +41,10 @@ func NewLocal(node *nm.Node) Local {
|
||||
}
|
||||
}
|
||||
|
||||
func (c Local) _assertIsClient() Client {
|
||||
return c
|
||||
}
|
||||
|
||||
func (c Local) _assertIsNetworkClient() NetworkClient {
|
||||
return c
|
||||
}
|
||||
var (
|
||||
_ Client = Local{}
|
||||
_ NetworkClient = Local{}
|
||||
)
|
||||
|
||||
func (c Local) Status() (*ctypes.ResultStatus, error) {
|
||||
return core.Status()
|
||||
|
@ -16,9 +16,11 @@ type ABCIApp struct {
|
||||
App abci.Application
|
||||
}
|
||||
|
||||
func (a ABCIApp) _assertABCIClient() client.ABCIClient {
|
||||
return a
|
||||
}
|
||||
var (
|
||||
_ client.ABCIClient = ABCIApp{}
|
||||
_ client.ABCIClient = ABCIMock{}
|
||||
_ client.ABCIClient = (*ABCIRecorder)(nil)
|
||||
)
|
||||
|
||||
func (a ABCIApp) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
||||
return &ctypes.ResultABCIInfo{a.App.Info(abci.RequestInfo{version.Version})}, nil
|
||||
@ -71,10 +73,6 @@ type ABCIMock struct {
|
||||
Broadcast Call
|
||||
}
|
||||
|
||||
func (m ABCIMock) _assertABCIClient() client.ABCIClient {
|
||||
return m
|
||||
}
|
||||
|
||||
func (m ABCIMock) ABCIInfo() (*ctypes.ResultABCIInfo, error) {
|
||||
res, err := m.Info.GetResponse(nil)
|
||||
if err != nil {
|
||||
@ -134,10 +132,6 @@ func NewABCIRecorder(client client.ABCIClient) *ABCIRecorder {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *ABCIRecorder) _assertABCIClient() client.ABCIClient {
|
||||
return r
|
||||
}
|
||||
|
||||
type QueryArgs struct {
|
||||
Path string
|
||||
Data data.Bytes
|
||||
|
@ -37,9 +37,7 @@ type Client struct {
|
||||
types.EventSwitch
|
||||
}
|
||||
|
||||
func (c Client) _assertIsClient() client.Client {
|
||||
return c
|
||||
}
|
||||
var _ client.Client = Client{}
|
||||
|
||||
// Call is used by recorders to save a call and response.
|
||||
// It can also be used to configure mock responses.
|
||||
|
@ -10,9 +10,10 @@ type StatusMock struct {
|
||||
Call
|
||||
}
|
||||
|
||||
func (m *StatusMock) _assertStatusClient() client.StatusClient {
|
||||
return m
|
||||
}
|
||||
var (
|
||||
_ client.StatusClient = (*StatusMock)(nil)
|
||||
_ client.StatusClient = (*StatusRecorder)(nil)
|
||||
)
|
||||
|
||||
func (m *StatusMock) Status() (*ctypes.ResultStatus, error) {
|
||||
res, err := m.GetResponse(nil)
|
||||
@ -36,10 +37,6 @@ func NewStatusRecorder(client client.StatusClient) *StatusRecorder {
|
||||
}
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) _assertStatusClient() client.StatusClient {
|
||||
return r
|
||||
}
|
||||
|
||||
func (r *StatusRecorder) addCall(call Call) {
|
||||
r.Calls = append(r.Calls, call)
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user