mirror of
https://github.com/tendermint/tendermint.git
synced 2026-07-29 03:22:51 +00:00
update for sdk2 libs. need to fix kv test
NOTE we only updating for tmlibs and abci
This commit is contained in:
+8
-19
@@ -141,13 +141,7 @@ func (blockExec *BlockExecutor) Commit(block *types.Block) ([]byte, error) {
|
||||
blockExec.logger.Error("Client error during proxyAppConn.CommitSync", "err", err)
|
||||
return nil, err
|
||||
}
|
||||
if res.IsErr() {
|
||||
blockExec.logger.Error("Error in proxyAppConn.CommitSync", "err", res)
|
||||
return nil, res
|
||||
}
|
||||
if res.Log != "" {
|
||||
blockExec.logger.Debug("Commit.Log: " + res.Log)
|
||||
}
|
||||
// ResponseCommit has no error code - just data
|
||||
|
||||
blockExec.logger.Info("Committed state", "height", block.Height, "txs", block.NumTxs, "appHash", res.Data)
|
||||
|
||||
@@ -198,10 +192,11 @@ func execBlockOnProxyApp(logger log.Logger, proxyAppConn proxy.AppConnConsensus,
|
||||
}
|
||||
}
|
||||
|
||||
byzantineVals := make([]*abci.Evidence, len(block.Evidence.Evidence))
|
||||
// TODO: determine which validators were byzantine
|
||||
byzantineVals := make([]abci.Evidence, len(block.Evidence.Evidence))
|
||||
for i, ev := range block.Evidence.Evidence {
|
||||
byzantineVals[i] = &abci.Evidence{
|
||||
PubKey: ev.Address(), // XXX/TODO
|
||||
byzantineVals[i] = abci.Evidence{
|
||||
PubKey: ev.Address(), // XXX
|
||||
Height: ev.Height(),
|
||||
}
|
||||
}
|
||||
@@ -243,7 +238,7 @@ func execBlockOnProxyApp(logger log.Logger, proxyAppConn proxy.AppConnConsensus,
|
||||
return abciResponses, nil
|
||||
}
|
||||
|
||||
func updateValidators(currentSet *types.ValidatorSet, updates []*abci.Validator) error {
|
||||
func updateValidators(currentSet *types.ValidatorSet, updates []abci.Validator) error {
|
||||
// If more or equal than 1/3 of total voting power changed in one block, then
|
||||
// a light client could never prove the transition externally. See
|
||||
// ./lite/doc.go for details on how a light client tracks validators.
|
||||
@@ -293,7 +288,7 @@ func updateValidators(currentSet *types.ValidatorSet, updates []*abci.Validator)
|
||||
return nil
|
||||
}
|
||||
|
||||
func changeInVotingPowerMoreOrEqualToOneThird(currentSet *types.ValidatorSet, updates []*abci.Validator) (bool, error) {
|
||||
func changeInVotingPowerMoreOrEqualToOneThird(currentSet *types.ValidatorSet, updates []abci.Validator) (bool, error) {
|
||||
threshold := currentSet.TotalVotingPower() * 1 / 3
|
||||
acc := int64(0)
|
||||
|
||||
@@ -424,12 +419,6 @@ func ExecCommitBlock(appConnConsensus proxy.AppConnConsensus, block *types.Block
|
||||
logger.Error("Client error during proxyAppConn.CommitSync", "err", res)
|
||||
return nil, err
|
||||
}
|
||||
if res.IsErr() {
|
||||
logger.Error("Error in proxyAppConn.CommitSync", "err", res)
|
||||
return nil, res
|
||||
}
|
||||
if res.Log != "" {
|
||||
logger.Info("Commit.Log: " + res.Log)
|
||||
}
|
||||
// ResponseCommit has no error or log, just data
|
||||
return res.Data, nil
|
||||
}
|
||||
|
||||
@@ -12,6 +12,7 @@ import (
|
||||
crypto "github.com/tendermint/go-crypto"
|
||||
"github.com/tendermint/tendermint/proxy"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
"github.com/tendermint/tmlibs/log"
|
||||
)
|
||||
@@ -105,11 +106,11 @@ func TestBeginBlockByzantineValidators(t *testing.T) {
|
||||
testCases := []struct {
|
||||
desc string
|
||||
evidence []types.Evidence
|
||||
expectedByzantineValidators []*abci.Evidence
|
||||
expectedByzantineValidators []abci.Evidence
|
||||
}{
|
||||
{"none byzantine", []types.Evidence{}, []*abci.Evidence{}},
|
||||
{"one byzantine", []types.Evidence{ev1}, []*abci.Evidence{{ev1.Address(), ev1.Height()}}},
|
||||
{"multiple byzantine", []types.Evidence{ev1, ev2}, []*abci.Evidence{
|
||||
{"none byzantine", []types.Evidence{}, []abci.Evidence{}},
|
||||
{"one byzantine", []types.Evidence{ev1}, []abci.Evidence{{ev1.Address(), ev1.Height()}}},
|
||||
{"multiple byzantine", []types.Evidence{ev1, ev2}, []abci.Evidence{
|
||||
{ev1.Address(), ev1.Height()},
|
||||
{ev2.Address(), ev2.Height()}}},
|
||||
}
|
||||
@@ -161,7 +162,7 @@ type testApp struct {
|
||||
abci.BaseApplication
|
||||
|
||||
AbsentValidators []int32
|
||||
ByzantineValidators []*abci.Evidence
|
||||
ByzantineValidators []abci.Evidence
|
||||
}
|
||||
|
||||
func NewDummyApplication() *testApp {
|
||||
@@ -179,7 +180,7 @@ func (app *testApp) BeginBlock(req abci.RequestBeginBlock) abci.ResponseBeginBlo
|
||||
}
|
||||
|
||||
func (app *testApp) DeliverTx(tx []byte) abci.ResponseDeliverTx {
|
||||
return abci.ResponseDeliverTx{Tags: []*abci.KVPair{}}
|
||||
return abci.ResponseDeliverTx{Tags: []cmn.KVPair{}}
|
||||
}
|
||||
|
||||
func (app *testApp) CheckTx(tx []byte) abci.ResponseCheckTx {
|
||||
|
||||
+30
-30
@@ -77,9 +77,9 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
|
||||
// build mock responses
|
||||
block := makeBlock(state, 2)
|
||||
abciResponses := NewABCIResponses(block)
|
||||
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []*abci.KVPair{}}
|
||||
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []*abci.KVPair{}}
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{
|
||||
abciResponses.DeliverTx[0] = &abci.ResponseDeliverTx{Data: []byte("foo"), Tags: []cmn.KVPair{}}
|
||||
abciResponses.DeliverTx[1] = &abci.ResponseDeliverTx{Data: []byte("bar"), Log: "ok", Tags: []cmn.KVPair{}}
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{
|
||||
{
|
||||
PubKey: crypto.GenPrivKeyEd25519().PubKey().Bytes(),
|
||||
Power: 10,
|
||||
@@ -122,9 +122,9 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
|
||||
[]*abci.ResponseDeliverTx{
|
||||
{Code: 383},
|
||||
{Data: []byte("Gotcha!"),
|
||||
Tags: []*abci.KVPair{
|
||||
abci.KVPairInt("a", 1),
|
||||
abci.KVPairString("build", "stuff"),
|
||||
Tags: []cmn.KVPair{
|
||||
cmn.KVPair{[]byte("a"), []byte{1}},
|
||||
cmn.KVPair{[]byte("build"), []byte("stuff")},
|
||||
}},
|
||||
},
|
||||
types.ABCIResults{
|
||||
@@ -378,44 +378,44 @@ func TestLessThanOneThirdOfVotingPowerPerBlockEnforced(t *testing.T) {
|
||||
testCases := []struct {
|
||||
initialValSetSize int
|
||||
shouldErr bool
|
||||
valUpdatesFn func(vals *types.ValidatorSet) []*abci.Validator
|
||||
valUpdatesFn func(vals *types.ValidatorSet) []abci.Validator
|
||||
}{
|
||||
///////////// 1 val (vp: 10) => less than 3 is ok ////////////////////////
|
||||
// adding 1 validator => 10
|
||||
0: {1, false, func(vals *types.ValidatorSet) []*abci.Validator {
|
||||
return []*abci.Validator{
|
||||
0: {1, false, func(vals *types.ValidatorSet) []abci.Validator {
|
||||
return []abci.Validator{
|
||||
{PubKey: pk(), Power: 2},
|
||||
}
|
||||
}},
|
||||
1: {1, true, func(vals *types.ValidatorSet) []*abci.Validator {
|
||||
return []*abci.Validator{
|
||||
1: {1, true, func(vals *types.ValidatorSet) []abci.Validator {
|
||||
return []abci.Validator{
|
||||
{PubKey: pk(), Power: 3},
|
||||
}
|
||||
}},
|
||||
2: {1, true, func(vals *types.ValidatorSet) []*abci.Validator {
|
||||
return []*abci.Validator{
|
||||
2: {1, true, func(vals *types.ValidatorSet) []abci.Validator {
|
||||
return []abci.Validator{
|
||||
{PubKey: pk(), Power: 100},
|
||||
}
|
||||
}},
|
||||
|
||||
///////////// 3 val (vp: 30) => less than 10 is ok ////////////////////////
|
||||
// adding and removing validator => 20
|
||||
3: {3, true, func(vals *types.ValidatorSet) []*abci.Validator {
|
||||
3: {3, true, func(vals *types.ValidatorSet) []abci.Validator {
|
||||
_, firstVal := vals.GetByIndex(0)
|
||||
return []*abci.Validator{
|
||||
return []abci.Validator{
|
||||
{PubKey: firstVal.PubKey.Bytes(), Power: 0},
|
||||
{PubKey: pk(), Power: 10},
|
||||
}
|
||||
}},
|
||||
// adding 1 validator => 10
|
||||
4: {3, true, func(vals *types.ValidatorSet) []*abci.Validator {
|
||||
return []*abci.Validator{
|
||||
4: {3, true, func(vals *types.ValidatorSet) []abci.Validator {
|
||||
return []abci.Validator{
|
||||
{PubKey: pk(), Power: 10},
|
||||
}
|
||||
}},
|
||||
// adding 2 validators => 8
|
||||
5: {3, false, func(vals *types.ValidatorSet) []*abci.Validator {
|
||||
return []*abci.Validator{
|
||||
5: {3, false, func(vals *types.ValidatorSet) []abci.Validator {
|
||||
return []abci.Validator{
|
||||
{PubKey: pk(), Power: 4},
|
||||
{PubKey: pk(), Power: 4},
|
||||
}
|
||||
@@ -450,20 +450,20 @@ func TestApplyUpdates(t *testing.T) {
|
||||
|
||||
cases := [...]struct {
|
||||
init types.ConsensusParams
|
||||
updates *abci.ConsensusParams
|
||||
updates abci.ConsensusParams
|
||||
expected types.ConsensusParams
|
||||
}{
|
||||
0: {initParams, nil, initParams},
|
||||
1: {initParams, &abci.ConsensusParams{}, initParams},
|
||||
0: {initParams, abci.ConsensusParams{}, initParams},
|
||||
1: {initParams, abci.ConsensusParams{}, initParams},
|
||||
2: {initParams,
|
||||
&abci.ConsensusParams{
|
||||
abci.ConsensusParams{
|
||||
TxSize: &abci.TxSize{
|
||||
MaxBytes: 123,
|
||||
},
|
||||
},
|
||||
makeParams(1, 2, 3, 123, 5, 6)},
|
||||
3: {initParams,
|
||||
&abci.ConsensusParams{
|
||||
abci.ConsensusParams{
|
||||
BlockSize: &abci.BlockSize{
|
||||
MaxTxs: 44,
|
||||
MaxGas: 55,
|
||||
@@ -471,7 +471,7 @@ func TestApplyUpdates(t *testing.T) {
|
||||
},
|
||||
makeParams(1, 44, 55, 4, 5, 6)},
|
||||
4: {initParams,
|
||||
&abci.ConsensusParams{
|
||||
abci.ConsensusParams{
|
||||
BlockSize: &abci.BlockSize{
|
||||
MaxTxs: 789,
|
||||
},
|
||||
@@ -486,7 +486,7 @@ func TestApplyUpdates(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
res := tc.init.Update(tc.updates)
|
||||
res := tc.init.Update(&(tc.updates))
|
||||
assert.Equal(t, tc.expected, res, "case %d", i)
|
||||
}
|
||||
}
|
||||
@@ -496,14 +496,14 @@ func makeHeaderPartsResponsesValPubKeyChange(state State, height int64,
|
||||
|
||||
block := makeBlock(state, height)
|
||||
abciResponses := &ABCIResponses{
|
||||
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{}},
|
||||
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{}},
|
||||
}
|
||||
|
||||
// if the pubkey is new, remove the old and add the new
|
||||
_, val := state.Validators.GetByIndex(0)
|
||||
if !bytes.Equal(pubkey.Bytes(), val.PubKey.Bytes()) {
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
||||
ValidatorUpdates: []*abci.Validator{
|
||||
ValidatorUpdates: []abci.Validator{
|
||||
{val.PubKey.Bytes(), 0},
|
||||
{pubkey.Bytes(), 10},
|
||||
},
|
||||
@@ -518,14 +518,14 @@ func makeHeaderPartsResponsesValPowerChange(state State, height int64,
|
||||
|
||||
block := makeBlock(state, height)
|
||||
abciResponses := &ABCIResponses{
|
||||
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []*abci.Validator{}},
|
||||
EndBlock: &abci.ResponseEndBlock{ValidatorUpdates: []abci.Validator{}},
|
||||
}
|
||||
|
||||
// if the pubkey is new, remove the old and add the new
|
||||
_, val := state.Validators.GetByIndex(0)
|
||||
if val.VotingPower != power {
|
||||
abciResponses.EndBlock = &abci.ResponseEndBlock{
|
||||
ValidatorUpdates: []*abci.Validator{
|
||||
ValidatorUpdates: []abci.Validator{
|
||||
{val.PubKey.Bytes(), power},
|
||||
},
|
||||
}
|
||||
|
||||
+19
-28
@@ -10,13 +10,13 @@ import (
|
||||
|
||||
"github.com/pkg/errors"
|
||||
|
||||
abci "github.com/tendermint/abci/types"
|
||||
wire "github.com/tendermint/go-wire"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
"github.com/tendermint/tmlibs/pubsub/query"
|
||||
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
db "github.com/tendermint/tmlibs/db"
|
||||
"github.com/tendermint/tmlibs/pubsub/query"
|
||||
)
|
||||
|
||||
const (
|
||||
@@ -27,13 +27,13 @@ var _ txindex.TxIndexer = (*TxIndex)(nil)
|
||||
|
||||
// TxIndex is the simplest possible indexer, backed by key-value storage (levelDB).
|
||||
type TxIndex struct {
|
||||
store db.DB
|
||||
store dbm.DB
|
||||
tagsToIndex []string
|
||||
indexAllTags bool
|
||||
}
|
||||
|
||||
// NewTxIndex creates new KV indexer.
|
||||
func NewTxIndex(store db.DB, options ...func(*TxIndex)) *TxIndex {
|
||||
func NewTxIndex(store dbm.DB, options ...func(*TxIndex)) *TxIndex {
|
||||
txi := &TxIndex{store: store, tagsToIndex: make([]string, 0), indexAllTags: false}
|
||||
for _, o := range options {
|
||||
o(txi)
|
||||
@@ -87,7 +87,7 @@ func (txi *TxIndex) AddBatch(b *txindex.Batch) error {
|
||||
|
||||
// index tx by tags
|
||||
for _, tag := range result.Result.Tags {
|
||||
if txi.indexAllTags || cmn.StringInSlice(tag.Key, txi.tagsToIndex) {
|
||||
if txi.indexAllTags || cmn.StringInSlice(string(tag.Key), txi.tagsToIndex) {
|
||||
storeBatch.Set(keyForTag(tag, result), hash)
|
||||
}
|
||||
}
|
||||
@@ -109,7 +109,7 @@ func (txi *TxIndex) Index(result *types.TxResult) error {
|
||||
|
||||
// index tx by tags
|
||||
for _, tag := range result.Result.Tags {
|
||||
if txi.indexAllTags || cmn.StringInSlice(tag.Key, txi.tagsToIndex) {
|
||||
if txi.indexAllTags || cmn.StringInSlice(string(tag.Key), txi.tagsToIndex) {
|
||||
b.Set(keyForTag(tag, result), hash)
|
||||
}
|
||||
}
|
||||
@@ -270,18 +270,18 @@ func isRangeOperation(op query.Operator) bool {
|
||||
|
||||
func (txi *TxIndex) match(c query.Condition, startKey []byte) (hashes [][]byte) {
|
||||
if c.Op == query.OpEqual {
|
||||
it := txi.store.IteratorPrefix(startKey)
|
||||
defer it.Release()
|
||||
for it.Next() {
|
||||
it := dbm.IteratePrefix(txi.store, startKey)
|
||||
defer it.Close()
|
||||
for ; it.Valid(); it.Next() {
|
||||
hashes = append(hashes, it.Value())
|
||||
}
|
||||
} else if c.Op == query.OpContains {
|
||||
// XXX: doing full scan because startKey does not apply here
|
||||
// For example, if startKey = "account.owner=an" and search query = "accoutn.owner CONSISTS an"
|
||||
// we can't iterate with prefix "account.owner=an" because we might miss keys like "account.owner=Ulan"
|
||||
it := txi.store.Iterator()
|
||||
defer it.Release()
|
||||
for it.Next() {
|
||||
it := txi.store.Iterator(nil, nil)
|
||||
defer it.Close()
|
||||
for ; it.Valid(); it.Next() {
|
||||
if !isTagKey(it.Key()) {
|
||||
continue
|
||||
}
|
||||
@@ -296,10 +296,10 @@ func (txi *TxIndex) match(c query.Condition, startKey []byte) (hashes [][]byte)
|
||||
}
|
||||
|
||||
func (txi *TxIndex) matchRange(r queryRange, startKey []byte) (hashes [][]byte) {
|
||||
it := txi.store.IteratorPrefix(startKey)
|
||||
defer it.Release()
|
||||
it := dbm.IteratePrefix(txi.store, startKey)
|
||||
defer it.Close()
|
||||
LOOP:
|
||||
for it.Next() {
|
||||
for ; it.Valid(); it.Next() {
|
||||
if !isTagKey(it.Key()) {
|
||||
continue
|
||||
}
|
||||
@@ -376,17 +376,8 @@ func extractValueFromKey(key []byte) string {
|
||||
return parts[1]
|
||||
}
|
||||
|
||||
func keyForTag(tag *abci.KVPair, result *types.TxResult) []byte {
|
||||
switch tag.ValueType {
|
||||
case abci.KVPair_STRING:
|
||||
return []byte(fmt.Sprintf("%s/%v/%d/%d", tag.Key, tag.ValueString, result.Height, result.Index))
|
||||
case abci.KVPair_INT:
|
||||
return []byte(fmt.Sprintf("%s/%v/%d/%d", tag.Key, tag.ValueInt, result.Height, result.Index))
|
||||
// case abci.KVPair_TIME:
|
||||
// return []byte(fmt.Sprintf("%s/%d/%d/%d", tag.Key, tag.ValueTime.Unix(), result.Height, result.Index))
|
||||
default:
|
||||
panic(fmt.Sprintf("Undefined value type: %v", tag.ValueType))
|
||||
}
|
||||
func keyForTag(tag cmn.KVPair, result *types.TxResult) []byte {
|
||||
return []byte(fmt.Sprintf("%s/%d/%d", tag.Key, result.Height, result.Index))
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
+15
-14
@@ -11,6 +11,7 @@ import (
|
||||
abci "github.com/tendermint/abci/types"
|
||||
"github.com/tendermint/tendermint/state/txindex"
|
||||
"github.com/tendermint/tendermint/types"
|
||||
cmn "github.com/tendermint/tmlibs/common"
|
||||
db "github.com/tendermint/tmlibs/db"
|
||||
"github.com/tendermint/tmlibs/pubsub/query"
|
||||
)
|
||||
@@ -19,7 +20,7 @@ func TestTxIndex(t *testing.T) {
|
||||
indexer := NewTxIndex(db.NewMemDB())
|
||||
|
||||
tx := types.Tx("HELLO WORLD")
|
||||
txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []*abci.KVPair{}}}
|
||||
txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []cmn.KVPair{}}}
|
||||
hash := tx.Hash()
|
||||
|
||||
batch := txindex.NewBatch(1)
|
||||
@@ -34,7 +35,7 @@ func TestTxIndex(t *testing.T) {
|
||||
assert.Equal(t, txResult, loadedTxResult)
|
||||
|
||||
tx2 := types.Tx("BYE BYE WORLD")
|
||||
txResult2 := &types.TxResult{1, 0, tx2, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []*abci.KVPair{}}}
|
||||
txResult2 := &types.TxResult{1, 0, tx2, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []cmn.KVPair{}}}
|
||||
hash2 := tx2.Hash()
|
||||
|
||||
err = indexer.Index(txResult2)
|
||||
@@ -49,10 +50,10 @@ func TestTxSearch(t *testing.T) {
|
||||
allowedTags := []string{"account.number", "account.owner", "account.date"}
|
||||
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
|
||||
|
||||
txResult := txResultWithTags([]*abci.KVPair{
|
||||
{Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 1},
|
||||
{Key: "account.owner", ValueType: abci.KVPair_STRING, ValueString: "Ivan"},
|
||||
{Key: "not_allowed", ValueType: abci.KVPair_STRING, ValueString: "Vlad"},
|
||||
txResult := txResultWithTags([]cmn.KVPair{
|
||||
{Key: []byte("account.number"), Value: []byte{1}},
|
||||
{Key: []byte("account.owner"), Value: []byte("Ivan")},
|
||||
{Key: []byte("not_allowed"), Value: []byte("Vlad")},
|
||||
})
|
||||
hash := txResult.Tx.Hash()
|
||||
|
||||
@@ -106,9 +107,9 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) {
|
||||
allowedTags := []string{"account.number"}
|
||||
indexer := NewTxIndex(db.NewMemDB(), IndexTags(allowedTags))
|
||||
|
||||
txResult := txResultWithTags([]*abci.KVPair{
|
||||
{Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 1},
|
||||
{Key: "account.number", ValueType: abci.KVPair_INT, ValueInt: 2},
|
||||
txResult := txResultWithTags([]cmn.KVPair{
|
||||
{Key: []byte("account.number"), Value: []byte{1}},
|
||||
{Key: []byte("account.number"), Value: []byte{2}},
|
||||
})
|
||||
|
||||
err := indexer.Index(txResult)
|
||||
@@ -124,9 +125,9 @@ func TestTxSearchOneTxWithMultipleSameTagsButDifferentValues(t *testing.T) {
|
||||
func TestIndexAllTags(t *testing.T) {
|
||||
indexer := NewTxIndex(db.NewMemDB(), IndexAllTags())
|
||||
|
||||
txResult := txResultWithTags([]*abci.KVPair{
|
||||
abci.KVPairString("account.owner", "Ivan"),
|
||||
abci.KVPairInt("account.number", 1),
|
||||
txResult := txResultWithTags([]cmn.KVPair{
|
||||
cmn.KVPair{[]byte("account.owner"), []byte("Ivan")},
|
||||
cmn.KVPair{[]byte("account.number"), []byte{1}},
|
||||
})
|
||||
|
||||
err := indexer.Index(txResult)
|
||||
@@ -143,14 +144,14 @@ func TestIndexAllTags(t *testing.T) {
|
||||
assert.Equal(t, []*types.TxResult{txResult}, results)
|
||||
}
|
||||
|
||||
func txResultWithTags(tags []*abci.KVPair) *types.TxResult {
|
||||
func txResultWithTags(tags []cmn.KVPair) *types.TxResult {
|
||||
tx := types.Tx("HELLO WORLD")
|
||||
return &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: tags}}
|
||||
}
|
||||
|
||||
func benchmarkTxIndex(txsCount int, b *testing.B) {
|
||||
tx := types.Tx("HELLO WORLD")
|
||||
txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []*abci.KVPair{}}}
|
||||
txResult := &types.TxResult{1, 0, tx, abci.ResponseDeliverTx{Data: []byte{0}, Code: abci.CodeTypeOK, Log: "", Tags: []cmn.KVPair{}}}
|
||||
|
||||
dir, err := ioutil.TempDir("", "tx_index_db")
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user