mirror of
https://github.com/tendermint/tendermint.git
synced 2026-09-25 01:14:28 +00:00
make the rest of the code compile
This commit is contained in:
@@ -10,11 +10,11 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/pkg/abci"
|
||||
types "github.com/tendermint/tendermint/pkg/events"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
var waitForEventTimeout = 8 * time.Second
|
||||
|
||||
+12
-10
@@ -9,15 +9,17 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/crypto/ed25519"
|
||||
cryptoenc "github.com/tendermint/tendermint/crypto/encoding"
|
||||
"github.com/tendermint/tendermint/crypto/tmhash"
|
||||
tmrand "github.com/tendermint/tendermint/libs/rand"
|
||||
"github.com/tendermint/tendermint/pkg/abci"
|
||||
"github.com/tendermint/tendermint/pkg/consensus"
|
||||
types "github.com/tendermint/tendermint/pkg/evidence"
|
||||
"github.com/tendermint/tendermint/pkg/metadata"
|
||||
"github.com/tendermint/tendermint/privval"
|
||||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// For some reason the empty node used in tests has a time of
|
||||
@@ -27,7 +29,7 @@ import (
|
||||
var defaultTestTime = time.Date(2018, 10, 10, 8, 20, 13, 695936996, time.UTC)
|
||||
|
||||
func newEvidence(t *testing.T, val *privval.FilePV,
|
||||
vote *types.Vote, vote2 *types.Vote,
|
||||
vote *consensus.Vote, vote2 *consensus.Vote,
|
||||
chainID string) *types.DuplicateVoteEvidence {
|
||||
|
||||
var err error
|
||||
@@ -35,14 +37,14 @@ func newEvidence(t *testing.T, val *privval.FilePV,
|
||||
v := vote.ToProto()
|
||||
v2 := vote2.ToProto()
|
||||
|
||||
vote.Signature, err = val.Key.PrivKey.Sign(types.VoteSignBytes(chainID, v))
|
||||
vote.Signature, err = val.Key.PrivKey.Sign(consensus.VoteSignBytes(chainID, v))
|
||||
require.NoError(t, err)
|
||||
|
||||
vote2.Signature, err = val.Key.PrivKey.Sign(types.VoteSignBytes(chainID, v2))
|
||||
vote2.Signature, err = val.Key.PrivKey.Sign(consensus.VoteSignBytes(chainID, v2))
|
||||
require.NoError(t, err)
|
||||
|
||||
validator := types.NewValidator(val.Key.PubKey, 10)
|
||||
valSet := types.NewValidatorSet([]*types.Validator{validator})
|
||||
validator := consensus.NewValidator(val.Key.PubKey, 10)
|
||||
valSet := consensus.NewValidatorSet([]*consensus.Validator{validator})
|
||||
|
||||
return types.NewDuplicateVoteEvidence(vote, vote2, defaultTestTime, valSet)
|
||||
}
|
||||
@@ -52,16 +54,16 @@ func makeEvidences(
|
||||
val *privval.FilePV,
|
||||
chainID string,
|
||||
) (correct *types.DuplicateVoteEvidence, fakes []*types.DuplicateVoteEvidence) {
|
||||
vote := types.Vote{
|
||||
vote := consensus.Vote{
|
||||
ValidatorAddress: val.Key.Address,
|
||||
ValidatorIndex: 0,
|
||||
Height: 1,
|
||||
Round: 0,
|
||||
Type: tmproto.PrevoteType,
|
||||
Timestamp: defaultTestTime,
|
||||
BlockID: types.BlockID{
|
||||
BlockID: metadata.BlockID{
|
||||
Hash: tmhash.Sum(tmrand.Bytes(tmhash.Size)),
|
||||
PartSetHeader: types.PartSetHeader{
|
||||
PartSetHeader: metadata.PartSetHeader{
|
||||
Total: 1000,
|
||||
Hash: tmhash.Sum([]byte("partset")),
|
||||
},
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
"github.com/tendermint/tendermint/types"
|
||||
"github.com/tendermint/tendermint/pkg/events"
|
||||
)
|
||||
|
||||
// Waiter is informed of current height, decided whether to quit early
|
||||
@@ -57,13 +57,13 @@ func WaitForHeight(c StatusClient, h int64, waiter Waiter) error {
|
||||
// when the timeout duration has expired.
|
||||
//
|
||||
// This handles subscribing and unsubscribing under the hood
|
||||
func WaitForOneEvent(c EventsClient, eventValue string, timeout time.Duration) (types.TMEventData, error) {
|
||||
func WaitForOneEvent(c EventsClient, eventValue string, timeout time.Duration) (events.TMEventData, error) {
|
||||
const subscriber = "helpers"
|
||||
ctx, cancel := context.WithTimeout(context.Background(), timeout)
|
||||
defer cancel()
|
||||
|
||||
// register for the next event of this type
|
||||
eventCh, err := c.Subscribe(ctx, subscriber, types.QueryForEvent(eventValue).String())
|
||||
eventCh, err := c.Subscribe(ctx, subscriber, events.QueryForEvent(eventValue).String())
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to subscribe: %w", err)
|
||||
}
|
||||
@@ -77,7 +77,7 @@ func WaitForOneEvent(c EventsClient, eventValue string, timeout time.Duration) (
|
||||
|
||||
select {
|
||||
case event := <-eventCh:
|
||||
return event.Data.(types.TMEventData), nil
|
||||
return event.Data.(events.TMEventData), nil
|
||||
case <-ctx.Done():
|
||||
return nil, errors.New("timed out waiting for event")
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
"github.com/tendermint/tendermint/pkg/evidence"
|
||||
"github.com/tendermint/tendermint/pkg/mempool"
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
jsonrpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -250,7 +251,7 @@ func (c *baseRPCClient) ABCIQueryWithOptions(
|
||||
|
||||
func (c *baseRPCClient) BroadcastTxCommit(
|
||||
ctx context.Context,
|
||||
tx types.Tx,
|
||||
tx mempool.Tx,
|
||||
) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
result := new(ctypes.ResultBroadcastTxCommit)
|
||||
_, err := c.caller.Call(ctx, "broadcast_tx_commit", map[string]interface{}{"tx": tx}, result)
|
||||
@@ -262,14 +263,14 @@ func (c *baseRPCClient) BroadcastTxCommit(
|
||||
|
||||
func (c *baseRPCClient) BroadcastTxAsync(
|
||||
ctx context.Context,
|
||||
tx types.Tx,
|
||||
tx mempool.Tx,
|
||||
) (*ctypes.ResultBroadcastTx, error) {
|
||||
return c.broadcastTX(ctx, "broadcast_tx_async", tx)
|
||||
}
|
||||
|
||||
func (c *baseRPCClient) BroadcastTxSync(
|
||||
ctx context.Context,
|
||||
tx types.Tx,
|
||||
tx mempool.Tx,
|
||||
) (*ctypes.ResultBroadcastTx, error) {
|
||||
return c.broadcastTX(ctx, "broadcast_tx_sync", tx)
|
||||
}
|
||||
@@ -277,7 +278,7 @@ func (c *baseRPCClient) BroadcastTxSync(
|
||||
func (c *baseRPCClient) broadcastTX(
|
||||
ctx context.Context,
|
||||
route string,
|
||||
tx types.Tx,
|
||||
tx mempool.Tx,
|
||||
) (*ctypes.ResultBroadcastTx, error) {
|
||||
result := new(ctypes.ResultBroadcastTx)
|
||||
_, err := c.caller.Call(ctx, route, map[string]interface{}{"tx": tx}, result)
|
||||
@@ -312,7 +313,7 @@ func (c *baseRPCClient) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUn
|
||||
return result, nil
|
||||
}
|
||||
|
||||
func (c *baseRPCClient) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
|
||||
func (c *baseRPCClient) CheckTx(ctx context.Context, tx mempool.Tx) (*ctypes.ResultCheckTx, error) {
|
||||
result := new(ctypes.ResultCheckTx)
|
||||
_, err := c.caller.Call(ctx, "check_tx", map[string]interface{}{"tx": tx}, result)
|
||||
if err != nil {
|
||||
@@ -558,7 +559,7 @@ func (c *baseRPCClient) Validators(
|
||||
|
||||
func (c *baseRPCClient) BroadcastEvidence(
|
||||
ctx context.Context,
|
||||
ev types.Evidence,
|
||||
ev evidence.Evidence,
|
||||
) (*ctypes.ResultBroadcastEvidence, error) {
|
||||
result := new(ctypes.ResultBroadcastEvidence)
|
||||
_, err := c.caller.Call(ctx, "broadcast_evidence", map[string]interface{}{"evidence": ev}, result)
|
||||
|
||||
@@ -25,8 +25,9 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/pkg/evidence"
|
||||
"github.com/tendermint/tendermint/pkg/mempool"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
//go:generate ../../scripts/mockery_generate.sh Client
|
||||
@@ -58,9 +59,9 @@ type ABCIClient interface {
|
||||
opts ABCIQueryOptions) (*ctypes.ResultABCIQuery, error)
|
||||
|
||||
// Writing to abci app
|
||||
BroadcastTxCommit(context.Context, types.Tx) (*ctypes.ResultBroadcastTxCommit, error)
|
||||
BroadcastTxAsync(context.Context, types.Tx) (*ctypes.ResultBroadcastTx, error)
|
||||
BroadcastTxSync(context.Context, types.Tx) (*ctypes.ResultBroadcastTx, error)
|
||||
BroadcastTxCommit(context.Context, mempool.Tx) (*ctypes.ResultBroadcastTxCommit, error)
|
||||
BroadcastTxAsync(context.Context, mempool.Tx) (*ctypes.ResultBroadcastTx, error)
|
||||
BroadcastTxSync(context.Context, mempool.Tx) (*ctypes.ResultBroadcastTx, error)
|
||||
}
|
||||
|
||||
// SignClient groups together the functionality needed to get valid signatures
|
||||
@@ -136,13 +137,13 @@ type EventsClient interface {
|
||||
type MempoolClient interface {
|
||||
UnconfirmedTxs(ctx context.Context, limit *int) (*ctypes.ResultUnconfirmedTxs, error)
|
||||
NumUnconfirmedTxs(context.Context) (*ctypes.ResultUnconfirmedTxs, error)
|
||||
CheckTx(context.Context, types.Tx) (*ctypes.ResultCheckTx, error)
|
||||
CheckTx(context.Context, mempool.Tx) (*ctypes.ResultCheckTx, error)
|
||||
}
|
||||
|
||||
// EvidenceClient is used for submitting an evidence of the malicious
|
||||
// behavior.
|
||||
type EvidenceClient interface {
|
||||
BroadcastEvidence(context.Context, types.Evidence) (*ctypes.ResultBroadcastEvidence, error)
|
||||
BroadcastEvidence(context.Context, evidence.Evidence) (*ctypes.ResultBroadcastEvidence, error)
|
||||
}
|
||||
|
||||
// RemoteClient is a Client, which can also return the remote network address.
|
||||
|
||||
+13
-11
@@ -9,11 +9,13 @@ import (
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmpubsub "github.com/tendermint/tendermint/libs/pubsub"
|
||||
tmquery "github.com/tendermint/tendermint/libs/pubsub/query"
|
||||
"github.com/tendermint/tendermint/pkg/events"
|
||||
"github.com/tendermint/tendermint/pkg/evidence"
|
||||
"github.com/tendermint/tendermint/pkg/mempool"
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/client"
|
||||
rpccore "github.com/tendermint/tendermint/rpc/core"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
/*
|
||||
@@ -37,7 +39,7 @@ don't need to do anything). It will keep trying indefinitely with exponential
|
||||
backoff (10ms -> 20ms -> 40ms) until successful.
|
||||
*/
|
||||
type Local struct {
|
||||
*types.EventBus
|
||||
*events.EventBus
|
||||
Logger log.Logger
|
||||
ctx *rpctypes.Context
|
||||
env *rpccore.Environment
|
||||
@@ -47,7 +49,7 @@ type Local struct {
|
||||
// local RPC client constructor needs to build a local client.
|
||||
type NodeService interface {
|
||||
ConfigureRPC() (*rpccore.Environment, error)
|
||||
EventBus() *types.EventBus
|
||||
EventBus() *events.EventBus
|
||||
}
|
||||
|
||||
// New configures a client that calls the Node directly.
|
||||
@@ -91,15 +93,15 @@ func (c *Local) ABCIQueryWithOptions(
|
||||
return c.env.ABCIQuery(c.ctx, path, data, opts.Height, opts.Prove)
|
||||
}
|
||||
|
||||
func (c *Local) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func (c *Local) BroadcastTxCommit(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
return c.env.BroadcastTxCommit(c.ctx, tx)
|
||||
}
|
||||
|
||||
func (c *Local) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (c *Local) BroadcastTxAsync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
return c.env.BroadcastTxAsync(c.ctx, tx)
|
||||
}
|
||||
|
||||
func (c *Local) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (c *Local) BroadcastTxSync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
return c.env.BroadcastTxSync(c.ctx, tx)
|
||||
}
|
||||
|
||||
@@ -111,7 +113,7 @@ func (c *Local) NumUnconfirmedTxs(ctx context.Context) (*ctypes.ResultUnconfirme
|
||||
return c.env.NumUnconfirmedTxs(c.ctx)
|
||||
}
|
||||
|
||||
func (c *Local) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
|
||||
func (c *Local) CheckTx(ctx context.Context, tx mempool.Tx) (*ctypes.ResultCheckTx, error) {
|
||||
return c.env.CheckTx(c.ctx, tx)
|
||||
}
|
||||
|
||||
@@ -205,7 +207,7 @@ func (c *Local) BlockSearch(
|
||||
return c.env.BlockSearch(c.ctx, query, page, perPage, orderBy)
|
||||
}
|
||||
|
||||
func (c *Local) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
|
||||
func (c *Local) BroadcastEvidence(ctx context.Context, ev evidence.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
|
||||
return c.env.BroadcastEvidence(c.ctx, ev)
|
||||
}
|
||||
|
||||
@@ -224,7 +226,7 @@ func (c *Local) Subscribe(
|
||||
outCap = outCapacity[0]
|
||||
}
|
||||
|
||||
var sub types.Subscription
|
||||
var sub events.Subscription
|
||||
if outCap > 0 {
|
||||
sub, err = c.EventBus.Subscribe(ctx, subscriber, q, outCap)
|
||||
} else {
|
||||
@@ -241,7 +243,7 @@ func (c *Local) Subscribe(
|
||||
}
|
||||
|
||||
func (c *Local) eventsRoutine(
|
||||
sub types.Subscription,
|
||||
sub events.Subscription,
|
||||
subscriber string,
|
||||
q tmpubsub.Query,
|
||||
outc chan<- ctypes.ResultEvent) {
|
||||
@@ -281,7 +283,7 @@ func (c *Local) eventsRoutine(
|
||||
}
|
||||
|
||||
// Try to resubscribe with exponential backoff.
|
||||
func (c *Local) resubscribe(subscriber string, q tmpubsub.Query) types.Subscription {
|
||||
func (c *Local) resubscribe(subscriber string, q tmpubsub.Query) events.Subscription {
|
||||
attempts := 0
|
||||
for {
|
||||
if !c.IsRunning() {
|
||||
|
||||
+11
-11
@@ -3,12 +3,12 @@ package mock
|
||||
import (
|
||||
"context"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/pkg/abci"
|
||||
"github.com/tendermint/tendermint/pkg/mempool"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// ABCIApp will send all abci related request to the named app,
|
||||
@@ -49,7 +49,7 @@ func (a ABCIApp) ABCIQueryWithOptions(
|
||||
// NOTE: Caller should call a.App.Commit() separately,
|
||||
// this function does not actually wait for a commit.
|
||||
// TODO: Make it wait for a commit and set res.Height appropriately.
|
||||
func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
res := ctypes.ResultBroadcastTxCommit{}
|
||||
res.CheckTx = a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
|
||||
if res.CheckTx.IsErr() {
|
||||
@@ -60,7 +60,7 @@ func (a ABCIApp) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.Re
|
||||
return &res, nil
|
||||
}
|
||||
|
||||
func (a ABCIApp) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (a ABCIApp) BroadcastTxAsync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
c := a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
|
||||
// and this gets written in a background thread...
|
||||
if !c.IsErr() {
|
||||
@@ -75,7 +75,7 @@ func (a ABCIApp) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.Res
|
||||
}, nil
|
||||
}
|
||||
|
||||
func (a ABCIApp) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (a ABCIApp) BroadcastTxSync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
c := a.App.CheckTx(abci.RequestCheckTx{Tx: tx})
|
||||
// and this gets written in a background thread...
|
||||
if !c.IsErr() {
|
||||
@@ -125,7 +125,7 @@ func (m ABCIMock) ABCIQueryWithOptions(
|
||||
return &ctypes.ResultABCIQuery{Response: resQuery}, nil
|
||||
}
|
||||
|
||||
func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
res, err := m.BroadcastCommit.GetResponse(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -133,7 +133,7 @@ func (m ABCIMock) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.R
|
||||
return res.(*ctypes.ResultBroadcastTxCommit), nil
|
||||
}
|
||||
|
||||
func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
res, err := m.Broadcast.GetResponse(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -141,7 +141,7 @@ func (m ABCIMock) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.Re
|
||||
return res.(*ctypes.ResultBroadcastTx), nil
|
||||
}
|
||||
|
||||
func (m ABCIMock) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (m ABCIMock) BroadcastTxSync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
res, err := m.Broadcast.GetResponse(tx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
@@ -207,7 +207,7 @@ func (r *ABCIRecorder) ABCIQueryWithOptions(
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *ABCIRecorder) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func (r *ABCIRecorder) BroadcastTxCommit(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
res, err := r.Client.BroadcastTxCommit(ctx, tx)
|
||||
r.addCall(Call{
|
||||
Name: "broadcast_tx_commit",
|
||||
@@ -218,7 +218,7 @@ func (r *ABCIRecorder) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*cty
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *ABCIRecorder) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (r *ABCIRecorder) BroadcastTxAsync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
res, err := r.Client.BroadcastTxAsync(ctx, tx)
|
||||
r.addCall(Call{
|
||||
Name: "broadcast_tx_async",
|
||||
@@ -229,7 +229,7 @@ func (r *ABCIRecorder) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctyp
|
||||
return res, err
|
||||
}
|
||||
|
||||
func (r *ABCIRecorder) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (r *ABCIRecorder) BroadcastTxSync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
res, err := r.Client.BroadcastTxSync(ctx, tx)
|
||||
r.addCall(Call{
|
||||
Name: "broadcast_tx_sync",
|
||||
|
||||
@@ -10,12 +10,12 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
"github.com/tendermint/tendermint/abci/example/kvstore"
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/pkg/abci"
|
||||
"github.com/tendermint/tendermint/pkg/mempool"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
"github.com/tendermint/tendermint/rpc/client/mock"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
func TestABCIMock(t *testing.T) {
|
||||
@@ -23,8 +23,8 @@ func TestABCIMock(t *testing.T) {
|
||||
|
||||
key, value := []byte("foo"), []byte("bar")
|
||||
height := int64(10)
|
||||
goodTx := types.Tx{0x01, 0xff}
|
||||
badTx := types.Tx{0x12, 0x21}
|
||||
goodTx := mempool.Tx{0x01, 0xff}
|
||||
badTx := mempool.Tx{0x12, 0x21}
|
||||
|
||||
m := mock.ABCIMock{
|
||||
Info: mock.Call{Error: errors.New("foobar")},
|
||||
@@ -130,7 +130,7 @@ func TestABCIRecorder(t *testing.T) {
|
||||
assert.False(qa.Prove)
|
||||
|
||||
// now add some broadcasts (should all err)
|
||||
txs := []types.Tx{{1}, {2}, {3}}
|
||||
txs := []mempool.Tx{{1}, {2}, {3}}
|
||||
_, err = r.BroadcastTxCommit(context.Background(), txs[0])
|
||||
assert.NotNil(err, "expected err on broadcast")
|
||||
_, err = r.BroadcastTxSync(context.Background(), txs[1])
|
||||
@@ -172,7 +172,7 @@ func TestABCIApp(t *testing.T) {
|
||||
// add a key
|
||||
key, value := "foo", "bar"
|
||||
tx := fmt.Sprintf("%s=%s", key, value)
|
||||
res, err := m.BroadcastTxCommit(context.Background(), types.Tx(tx))
|
||||
res, err := m.BroadcastTxCommit(context.Background(), mempool.Tx(tx))
|
||||
require.Nil(err)
|
||||
assert.True(res.CheckTx.IsOK())
|
||||
require.NotNil(res.DeliverTx)
|
||||
|
||||
@@ -20,11 +20,12 @@ import (
|
||||
|
||||
"github.com/tendermint/tendermint/libs/bytes"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/pkg/evidence"
|
||||
"github.com/tendermint/tendermint/pkg/mempool"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
"github.com/tendermint/tendermint/rpc/core"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
rpctypes "github.com/tendermint/tendermint/rpc/jsonrpc/types"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
// Client wraps arbitrary implementations of the various interfaces.
|
||||
@@ -104,19 +105,19 @@ func (c Client) ABCIQueryWithOptions(
|
||||
return c.env.ABCIQuery(&rpctypes.Context{}, path, data, opts.Height, opts.Prove)
|
||||
}
|
||||
|
||||
func (c Client) BroadcastTxCommit(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
func (c Client) BroadcastTxCommit(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTxCommit, error) {
|
||||
return c.env.BroadcastTxCommit(&rpctypes.Context{}, tx)
|
||||
}
|
||||
|
||||
func (c Client) BroadcastTxAsync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (c Client) BroadcastTxAsync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
return c.env.BroadcastTxAsync(&rpctypes.Context{}, tx)
|
||||
}
|
||||
|
||||
func (c Client) BroadcastTxSync(ctx context.Context, tx types.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
func (c Client) BroadcastTxSync(ctx context.Context, tx mempool.Tx) (*ctypes.ResultBroadcastTx, error) {
|
||||
return c.env.BroadcastTxSync(&rpctypes.Context{}, tx)
|
||||
}
|
||||
|
||||
func (c Client) CheckTx(ctx context.Context, tx types.Tx) (*ctypes.ResultCheckTx, error) {
|
||||
func (c Client) CheckTx(ctx context.Context, tx mempool.Tx) (*ctypes.ResultCheckTx, error) {
|
||||
return c.env.CheckTx(&rpctypes.Context{}, tx)
|
||||
}
|
||||
|
||||
@@ -178,6 +179,6 @@ func (c Client) Validators(ctx context.Context, height *int64, page, perPage *in
|
||||
return c.env.Validators(&rpctypes.Context{}, height, page, perPage)
|
||||
}
|
||||
|
||||
func (c Client) BroadcastEvidence(ctx context.Context, ev types.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
|
||||
func (c Client) BroadcastEvidence(ctx context.Context, ev evidence.Evidence) (*ctypes.ResultBroadcastEvidence, error) {
|
||||
return c.env.BroadcastEvidence(&rpctypes.Context{}, ev)
|
||||
}
|
||||
|
||||
+19
-17
@@ -10,11 +10,13 @@ import (
|
||||
|
||||
coretypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
|
||||
evidence "github.com/tendermint/tendermint/pkg/evidence"
|
||||
|
||||
log "github.com/tendermint/tendermint/libs/log"
|
||||
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
mempool "github.com/tendermint/tendermint/pkg/mempool"
|
||||
|
||||
types "github.com/tendermint/tendermint/types"
|
||||
mock "github.com/stretchr/testify/mock"
|
||||
)
|
||||
|
||||
// Client is an autogenerated mock type for the Client type
|
||||
@@ -207,11 +209,11 @@ func (_m *Client) BlockchainInfo(ctx context.Context, minHeight int64, maxHeight
|
||||
}
|
||||
|
||||
// BroadcastEvidence provides a mock function with given fields: _a0, _a1
|
||||
func (_m *Client) BroadcastEvidence(_a0 context.Context, _a1 types.Evidence) (*coretypes.ResultBroadcastEvidence, error) {
|
||||
func (_m *Client) BroadcastEvidence(_a0 context.Context, _a1 evidence.Evidence) (*coretypes.ResultBroadcastEvidence, error) {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
var r0 *coretypes.ResultBroadcastEvidence
|
||||
if rf, ok := ret.Get(0).(func(context.Context, types.Evidence) *coretypes.ResultBroadcastEvidence); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, evidence.Evidence) *coretypes.ResultBroadcastEvidence); ok {
|
||||
r0 = rf(_a0, _a1)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
@@ -220,7 +222,7 @@ func (_m *Client) BroadcastEvidence(_a0 context.Context, _a1 types.Evidence) (*c
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, types.Evidence) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(context.Context, evidence.Evidence) error); ok {
|
||||
r1 = rf(_a0, _a1)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
@@ -230,11 +232,11 @@ func (_m *Client) BroadcastEvidence(_a0 context.Context, _a1 types.Evidence) (*c
|
||||
}
|
||||
|
||||
// BroadcastTxAsync provides a mock function with given fields: _a0, _a1
|
||||
func (_m *Client) BroadcastTxAsync(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultBroadcastTx, error) {
|
||||
func (_m *Client) BroadcastTxAsync(_a0 context.Context, _a1 mempool.Tx) (*coretypes.ResultBroadcastTx, error) {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
var r0 *coretypes.ResultBroadcastTx
|
||||
if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultBroadcastTx); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, mempool.Tx) *coretypes.ResultBroadcastTx); ok {
|
||||
r0 = rf(_a0, _a1)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
@@ -243,7 +245,7 @@ func (_m *Client) BroadcastTxAsync(_a0 context.Context, _a1 types.Tx) (*coretype
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(context.Context, mempool.Tx) error); ok {
|
||||
r1 = rf(_a0, _a1)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
@@ -253,11 +255,11 @@ func (_m *Client) BroadcastTxAsync(_a0 context.Context, _a1 types.Tx) (*coretype
|
||||
}
|
||||
|
||||
// BroadcastTxCommit provides a mock function with given fields: _a0, _a1
|
||||
func (_m *Client) BroadcastTxCommit(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
|
||||
func (_m *Client) BroadcastTxCommit(_a0 context.Context, _a1 mempool.Tx) (*coretypes.ResultBroadcastTxCommit, error) {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
var r0 *coretypes.ResultBroadcastTxCommit
|
||||
if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultBroadcastTxCommit); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, mempool.Tx) *coretypes.ResultBroadcastTxCommit); ok {
|
||||
r0 = rf(_a0, _a1)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
@@ -266,7 +268,7 @@ func (_m *Client) BroadcastTxCommit(_a0 context.Context, _a1 types.Tx) (*coretyp
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(context.Context, mempool.Tx) error); ok {
|
||||
r1 = rf(_a0, _a1)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
@@ -276,11 +278,11 @@ func (_m *Client) BroadcastTxCommit(_a0 context.Context, _a1 types.Tx) (*coretyp
|
||||
}
|
||||
|
||||
// BroadcastTxSync provides a mock function with given fields: _a0, _a1
|
||||
func (_m *Client) BroadcastTxSync(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultBroadcastTx, error) {
|
||||
func (_m *Client) BroadcastTxSync(_a0 context.Context, _a1 mempool.Tx) (*coretypes.ResultBroadcastTx, error) {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
var r0 *coretypes.ResultBroadcastTx
|
||||
if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultBroadcastTx); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, mempool.Tx) *coretypes.ResultBroadcastTx); ok {
|
||||
r0 = rf(_a0, _a1)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
@@ -289,7 +291,7 @@ func (_m *Client) BroadcastTxSync(_a0 context.Context, _a1 types.Tx) (*coretypes
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(context.Context, mempool.Tx) error); ok {
|
||||
r1 = rf(_a0, _a1)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
@@ -299,11 +301,11 @@ func (_m *Client) BroadcastTxSync(_a0 context.Context, _a1 types.Tx) (*coretypes
|
||||
}
|
||||
|
||||
// CheckTx provides a mock function with given fields: _a0, _a1
|
||||
func (_m *Client) CheckTx(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultCheckTx, error) {
|
||||
func (_m *Client) CheckTx(_a0 context.Context, _a1 mempool.Tx) (*coretypes.ResultCheckTx, error) {
|
||||
ret := _m.Called(_a0, _a1)
|
||||
|
||||
var r0 *coretypes.ResultCheckTx
|
||||
if rf, ok := ret.Get(0).(func(context.Context, types.Tx) *coretypes.ResultCheckTx); ok {
|
||||
if rf, ok := ret.Get(0).(func(context.Context, mempool.Tx) *coretypes.ResultCheckTx); ok {
|
||||
r0 = rf(_a0, _a1)
|
||||
} else {
|
||||
if ret.Get(0) != nil {
|
||||
@@ -312,7 +314,7 @@ func (_m *Client) CheckTx(_a0 context.Context, _a1 types.Tx) (*coretypes.ResultC
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(context.Context, types.Tx) error); ok {
|
||||
if rf, ok := ret.Get(1).(func(context.Context, mempool.Tx) error); ok {
|
||||
r1 = rf(_a0, _a1)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
|
||||
+11
-10
@@ -14,19 +14,20 @@ import (
|
||||
"github.com/stretchr/testify/assert"
|
||||
"github.com/stretchr/testify/require"
|
||||
|
||||
abci "github.com/tendermint/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/config"
|
||||
mempl "github.com/tendermint/tendermint/internal/mempool"
|
||||
tmjson "github.com/tendermint/tendermint/libs/json"
|
||||
"github.com/tendermint/tendermint/libs/log"
|
||||
tmmath "github.com/tendermint/tendermint/libs/math"
|
||||
"github.com/tendermint/tendermint/libs/service"
|
||||
"github.com/tendermint/tendermint/pkg/abci"
|
||||
"github.com/tendermint/tendermint/pkg/consensus"
|
||||
"github.com/tendermint/tendermint/pkg/mempool"
|
||||
"github.com/tendermint/tendermint/rpc/client"
|
||||
rpchttp "github.com/tendermint/tendermint/rpc/client/http"
|
||||
rpclocal "github.com/tendermint/tendermint/rpc/client/local"
|
||||
ctypes "github.com/tendermint/tendermint/rpc/core/types"
|
||||
rpcclient "github.com/tendermint/tendermint/rpc/jsonrpc/client"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
)
|
||||
|
||||
func getHTTPClient(t *testing.T, conf *config.Config) *rpchttp.HTTP {
|
||||
@@ -253,7 +254,7 @@ func TestGenesisChunked(t *testing.T) {
|
||||
}
|
||||
doc := []byte(strings.Join(decoded, ""))
|
||||
|
||||
var out types.GenesisDoc
|
||||
var out consensus.GenesisDoc
|
||||
require.NoError(t, tmjson.Unmarshal(doc, &out),
|
||||
"first: %+v, doc: %s", first, string(doc))
|
||||
}
|
||||
@@ -477,8 +478,8 @@ func TestUnconfirmedTxs(t *testing.T) {
|
||||
ch := make(chan *abci.Response, 1)
|
||||
|
||||
n, conf := NodeSuite(t)
|
||||
mempool := getMempool(t, n)
|
||||
err := mempool.CheckTx(ctx, tx, func(resp *abci.Response) { ch <- resp }, mempl.TxInfo{})
|
||||
m := getMempool(t, n)
|
||||
err := m.CheckTx(ctx, tx, func(resp *abci.Response) { ch <- resp }, mempl.TxInfo{})
|
||||
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -497,11 +498,11 @@ func TestUnconfirmedTxs(t *testing.T) {
|
||||
|
||||
assert.Equal(t, 1, res.Count)
|
||||
assert.Equal(t, 1, res.Total)
|
||||
assert.Equal(t, mempool.SizeBytes(), res.TotalBytes)
|
||||
assert.Exactly(t, types.Txs{tx}, types.Txs(res.Txs))
|
||||
assert.Equal(t, m.SizeBytes(), res.TotalBytes)
|
||||
assert.Exactly(t, mempool.Txs{tx}, mempool.Txs(res.Txs))
|
||||
}
|
||||
|
||||
mempool.Flush()
|
||||
m.Flush()
|
||||
}
|
||||
|
||||
func TestNumUnconfirmedTxs(t *testing.T) {
|
||||
@@ -572,7 +573,7 @@ func TestTx(t *testing.T) {
|
||||
txHeight := bres.Height
|
||||
txHash := bres.Hash
|
||||
|
||||
anotherTxHash := types.Tx("a different tx").Hash()
|
||||
anotherTxHash := mempool.Tx("a different tx").Hash()
|
||||
|
||||
cases := []struct {
|
||||
valid bool
|
||||
@@ -652,7 +653,7 @@ func TestTxSearch(t *testing.T) {
|
||||
|
||||
// pick out the last tx to have something to search for in tests
|
||||
find := result.Txs[len(result.Txs)-1]
|
||||
anotherTxHash := types.Tx("a different tx").Hash()
|
||||
anotherTxHash := mempool.Tx("a different tx").Hash()
|
||||
|
||||
for i, c := range GetClients(t, n, conf) {
|
||||
t.Logf("client %d", i)
|
||||
|
||||
Reference in New Issue
Block a user