mirror of
https://github.com/tendermint/tendermint.git
synced 2026-01-08 06:15:33 +00:00
* Rebased and git-squashed the commits in PR #6546 migrate abci to finalizeBlock work on abci, proxy and mempool abciresponse, blok events, indexer, some tests fix some tests fix errors fix errors in abci fix tests amd errors * Fixes after rebasing PR#6546 * Restored height to RequestFinalizeBlock & other * Fixed more UTs * Fixed kvstore * More UT fixes * last TC fixed * make format * Update internal/consensus/mempool_test.go Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com> * Addressed @williambanfield's comments * Fixed UTs * Addressed last comments from @williambanfield * make format Co-authored-by: marbar3778 <marbar3778@yahoo.com> Co-authored-by: William Banfield <4561443+williambanfield@users.noreply.github.com>
42 lines
1008 B
Go
42 lines
1008 B
Go
package factory
|
|
|
|
import (
|
|
"context"
|
|
"sort"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
"github.com/tendermint/tendermint/types"
|
|
)
|
|
|
|
func Validator(ctx context.Context, votingPower int64) (*types.Validator, types.PrivValidator, error) {
|
|
privVal := types.NewMockPV()
|
|
pubKey, err := privVal.GetPubKey(ctx)
|
|
if err != nil {
|
|
return nil, nil, err
|
|
}
|
|
|
|
val := types.NewValidator(pubKey, votingPower)
|
|
return val, privVal, nil
|
|
}
|
|
|
|
func ValidatorSet(ctx context.Context, t *testing.T, numValidators int, votingPower int64) (*types.ValidatorSet, []types.PrivValidator) {
|
|
var (
|
|
valz = make([]*types.Validator, numValidators)
|
|
privValidators = make([]types.PrivValidator, numValidators)
|
|
)
|
|
t.Helper()
|
|
|
|
for i := 0; i < numValidators; i++ {
|
|
val, privValidator, err := Validator(ctx, votingPower)
|
|
require.NoError(t, err)
|
|
valz[i] = val
|
|
privValidators[i] = privValidator
|
|
}
|
|
|
|
sort.Sort(types.PrivValidatorsByAddress(privValidators))
|
|
|
|
return types.NewValidatorSet(valz), privValidators
|
|
}
|