mirror of
https://github.com/tendermint/tendermint.git
synced 2026-08-21 06:36:19 +00:00
cleanup remaining struct problems
This commit is contained in:
@@ -107,7 +107,7 @@ func TestPersistentKVStoreInfo(t *testing.T) {
|
||||
header := tmproto.Header{
|
||||
Height: height,
|
||||
}
|
||||
kvstore.FinalizeBlock(types.RequestFinalizeBlock{Hash: hash, Header: header, Height: height})
|
||||
kvstore.FinalizeBlock(types.RequestFinalizeBlock{Hash: hash, Header: header})
|
||||
kvstore.Commit()
|
||||
|
||||
resInfo = kvstore.Info(types.RequestInfo{})
|
||||
@@ -196,7 +196,6 @@ func makeApplyBlock(
|
||||
resFinalizeBlock := kvstore.FinalizeBlock(types.RequestFinalizeBlock{
|
||||
Hash: hash,
|
||||
Header: header,
|
||||
Height: height,
|
||||
Txs: txs,
|
||||
})
|
||||
|
||||
|
||||
@@ -13,7 +13,7 @@ import (
|
||||
)
|
||||
|
||||
func TestMarshalJSON(t *testing.T) {
|
||||
b, err := json.Marshal(&ResponseDeliverTx{})
|
||||
b, err := json.Marshal(&ExecTxResult{})
|
||||
assert.NoError(t, err)
|
||||
// include empty fields.
|
||||
assert.True(t, strings.Contains(string(b), "code"))
|
||||
|
||||
@@ -33,6 +33,16 @@ func (r ResponseDeliverTx) IsErr() bool {
|
||||
return r.Code != CodeTypeOK
|
||||
}
|
||||
|
||||
// IsOK returns true if Code is OK.
|
||||
func (r ExecTxResult) IsOK() bool {
|
||||
return r.Code == CodeTypeOK
|
||||
}
|
||||
|
||||
// IsErr returns true if Code is something other than OK.
|
||||
func (r ExecTxResult) IsErr() bool {
|
||||
return r.Code != CodeTypeOK
|
||||
}
|
||||
|
||||
// IsOK returns true if Code is OK.
|
||||
func (r ResponseQuery) IsOK() bool {
|
||||
return r.Code == CodeTypeOK
|
||||
|
||||
@@ -132,7 +132,7 @@ func (b *EventBus) PublishEventStateSyncStatus(ctx context.Context, data types.E
|
||||
// predefined keys (EventTypeKey, TxHashKey). Existing events with the same keys
|
||||
// will be overwritten.
|
||||
func (b *EventBus) PublishEventTx(ctx context.Context, data types.EventDataTx) error {
|
||||
events := data.Result.Events
|
||||
events := data.Result.TxEvents
|
||||
|
||||
// add Tendermint-reserved events
|
||||
events = append(events, types.EventTx)
|
||||
|
||||
@@ -27,9 +27,9 @@ func TestEventBusPublishEventTx(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
tx := types.Tx("foo")
|
||||
result := abci.ResponseDeliverTx{
|
||||
result := abci.ExecTxResult{
|
||||
Data: []byte("bar"),
|
||||
Events: []abci.Event{
|
||||
TxEvents: []abci.Event{
|
||||
{Type: "testType", Attributes: []abci.EventAttribute{{Key: "baz", Value: "1"}}},
|
||||
},
|
||||
}
|
||||
@@ -134,9 +134,9 @@ func TestEventBusPublishEventTxDuplicateKeys(t *testing.T) {
|
||||
require.NoError(t, err)
|
||||
|
||||
tx := types.Tx("foo")
|
||||
result := abci.ResponseDeliverTx{
|
||||
result := abci.ExecTxResult{
|
||||
Data: []byte("bar"),
|
||||
Events: []abci.Event{
|
||||
TxEvents: []abci.Event{
|
||||
{
|
||||
Type: "transfer",
|
||||
Attributes: []abci.EventAttribute{
|
||||
|
||||
@@ -398,7 +398,6 @@ func execBlockOnProxyApp(
|
||||
Txs: block.Txs.ToSliceOfBytes(),
|
||||
Hash: block.Hash(),
|
||||
Header: *pbh,
|
||||
Height: block.Height,
|
||||
LastCommitInfo: buildLastCommitInfo(block, store, initialHeight),
|
||||
ByzantineValidators: block.Evidence.ToABCI(),
|
||||
},
|
||||
|
||||
@@ -80,7 +80,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) {
|
||||
Height: 1,
|
||||
Index: uint32(0),
|
||||
Tx: types.Tx("foo"),
|
||||
Result: abci.ResponseDeliverTx{Code: 0},
|
||||
Result: abci.ExecTxResult{Code: 0},
|
||||
}
|
||||
err = eventBus.PublishEventTx(ctx, types.EventDataTx{TxResult: *txResult1})
|
||||
require.NoError(t, err)
|
||||
@@ -88,7 +88,7 @@ func TestIndexerServiceIndexesBlocks(t *testing.T) {
|
||||
Height: 1,
|
||||
Index: uint32(1),
|
||||
Tx: types.Tx("bar"),
|
||||
Result: abci.ResponseDeliverTx{Code: 0},
|
||||
Result: abci.ExecTxResult{Code: 0},
|
||||
}
|
||||
err = eventBus.PublishEventTx(ctx, types.EventDataTx{TxResult: *txResult2})
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -338,11 +338,11 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult {
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx,
|
||||
Result: abci.ResponseDeliverTx{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
Events: events,
|
||||
Result: abci.ExecTxResult{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
TxEvents: events,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,7 +221,7 @@ INSERT INTO `+tableTxResults+` (block_id, index, created_at, tx_hash, tx_result)
|
||||
return fmt.Errorf("indexing transaction meta-events: %w", err)
|
||||
}
|
||||
// Index any events packaged with the transaction.
|
||||
if err := insertEvents(dbtx, blockID, txID, txr.Result.Events); err != nil {
|
||||
if err := insertEvents(dbtx, blockID, txID, txr.Result.TxEvents); err != nil {
|
||||
return fmt.Errorf("indexing transaction events: %w", err)
|
||||
}
|
||||
return nil
|
||||
|
||||
@@ -266,11 +266,11 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult {
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: types.Tx("HELLO WORLD"),
|
||||
Result: abci.ResponseDeliverTx{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
Events: events,
|
||||
Result: abci.ExecTxResult{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
TxEvents: events,
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -97,7 +97,7 @@ func (txi *TxIndex) Index(results []*abci.TxResult) error {
|
||||
}
|
||||
|
||||
func (txi *TxIndex) indexEvents(result *abci.TxResult, hash []byte, store dbm.Batch) error {
|
||||
for _, event := range result.Result.Events {
|
||||
for _, event := range result.Result.TxEvents {
|
||||
// only index events with a non-empty type
|
||||
if len(event.Type) == 0 {
|
||||
continue
|
||||
|
||||
@@ -43,11 +43,11 @@ func BenchmarkTxSearch(b *testing.B) {
|
||||
Height: int64(i),
|
||||
Index: 0,
|
||||
Tx: types.Tx(string(txBz)),
|
||||
Result: abci.ResponseDeliverTx{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
Events: events,
|
||||
Result: abci.ExecTxResult{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
TxEvents: events,
|
||||
},
|
||||
}
|
||||
|
||||
|
||||
@@ -25,9 +25,9 @@ func TestTxIndex(t *testing.T) {
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx,
|
||||
Result: abci.ResponseDeliverTx{
|
||||
Result: abci.ExecTxResult{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK, Log: "", Events: nil,
|
||||
Code: abci.CodeTypeOK, Log: "", TxEvents: nil,
|
||||
},
|
||||
}
|
||||
hash := tx.Hash()
|
||||
@@ -48,9 +48,9 @@ func TestTxIndex(t *testing.T) {
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx2,
|
||||
Result: abci.ResponseDeliverTx{
|
||||
Result: abci.ExecTxResult{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK, Log: "", Events: nil,
|
||||
Code: abci.CodeTypeOK, Log: "", TxEvents: nil,
|
||||
},
|
||||
}
|
||||
hash2 := tx2.Hash()
|
||||
@@ -322,11 +322,11 @@ func txResultWithEvents(events []abci.Event) *abci.TxResult {
|
||||
Height: 1,
|
||||
Index: 0,
|
||||
Tx: tx,
|
||||
Result: abci.ResponseDeliverTx{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
Events: events,
|
||||
Result: abci.ExecTxResult{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
TxEvents: events,
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -346,11 +346,11 @@ func benchmarkTxIndex(txsCount int64, b *testing.B) {
|
||||
Height: 1,
|
||||
Index: txIndex,
|
||||
Tx: tx,
|
||||
Result: abci.ResponseDeliverTx{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
Events: []abci.Event{},
|
||||
Result: abci.ExecTxResult{
|
||||
Data: []byte{0},
|
||||
Code: abci.CodeTypeOK,
|
||||
Log: "",
|
||||
TxEvents: []abci.Event{},
|
||||
},
|
||||
}
|
||||
if err := batch.Add(txResult); err != nil {
|
||||
|
||||
@@ -111,8 +111,8 @@ func TestABCIResponsesSaveLoad1(t *testing.T) {
|
||||
abciResponses.FinalizeBlock = new(abci.ResponseFinalizeBlock)
|
||||
abciResponses.FinalizeBlock.TxResults = dtxs
|
||||
|
||||
abciResponses.FinalizeBlock.TxResults[0] = &abci.ExecTxResult{Data: []byte("foo"), Events: nil}
|
||||
abciResponses.FinalizeBlock.TxResults[1] = &abci.ExecTxResult{Data: []byte("bar"), Log: "ok", Events: nil}
|
||||
abciResponses.FinalizeBlock.TxResults[0] = &abci.ExecTxResult{Data: []byte("foo"), TxEvents: nil}
|
||||
abciResponses.FinalizeBlock.TxResults[1] = &abci.ExecTxResult{Data: []byte("bar"), Log: "ok", TxEvents: nil}
|
||||
pbpk, err := encoding.PubKeyToProto(ed25519.GenPrivKey().PubKey())
|
||||
require.NoError(t, err)
|
||||
abciResponses.FinalizeBlock.ValidatorUpdates = []abci.ValidatorUpdate{{PubKey: pbpk, Power: 10}}
|
||||
@@ -156,7 +156,7 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
|
||||
{Code: 383},
|
||||
{
|
||||
Data: []byte("Gotcha!"),
|
||||
Events: []abci.Event{
|
||||
TxEvents: []abci.Event{
|
||||
{Type: "type1", Attributes: []abci.EventAttribute{{Key: "a", Value: "1"}}},
|
||||
{Type: "type2", Attributes: []abci.EventAttribute{{Key: "build", Value: "stuff"}}},
|
||||
},
|
||||
@@ -164,7 +164,7 @@ func TestABCIResponsesSaveLoad2(t *testing.T) {
|
||||
},
|
||||
[]*abci.ExecTxResult{
|
||||
{Code: 383, Data: nil},
|
||||
{Code: 0, Data: []byte("Gotcha!"), Events: []abci.Event{
|
||||
{Code: 0, Data: []byte("Gotcha!"), TxEvents: []abci.Event{
|
||||
{Type: "type1", Attributes: []abci.EventAttribute{{Key: "a", Value: "1"}}},
|
||||
{Type: "type2", Attributes: []abci.EventAttribute{{Key: "build", Value: "stuff"}}},
|
||||
}},
|
||||
|
||||
+2
-2
@@ -170,7 +170,7 @@ func (app *Application) FinalizeBlock(req abci.RequestFinalizeBlock) abci.Respon
|
||||
txs[i] = &abci.ExecTxResult{Code: code.CodeTypeOK}
|
||||
}
|
||||
|
||||
valUpdates, err := app.validatorUpdates(uint64(req.Height))
|
||||
valUpdates, err := app.validatorUpdates(uint64(req.Header.Height))
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
@@ -188,7 +188,7 @@ func (app *Application) FinalizeBlock(req abci.RequestFinalizeBlock) abci.Respon
|
||||
},
|
||||
{
|
||||
Key: "height",
|
||||
Value: strconv.Itoa(int(req.Height)),
|
||||
Value: strconv.Itoa(int(req.Header.Height)),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user