diff --git a/abci/cmd/abci-cli/abci-cli.go b/abci/cmd/abci-cli/abci-cli.go index 3888b3637..16b210709 100644 --- a/abci/cmd/abci-cli/abci-cli.go +++ b/abci/cmd/abci-cli/abci-cli.go @@ -332,9 +332,7 @@ func cmdTest(cmd *cobra.Command, args []string) error { func() error { return servertest.PrepareProposal(client, [][]byte{ {0x01}, - }, []types.TxRecord_TxAction{ - types.TxRecord_UNMODIFIED, - }, nil) + }, [][]byte{{0x01}}, nil) }, func() error { return servertest.ProcessProposal(client, [][]byte{ @@ -638,22 +636,12 @@ func cmdPrepareProposal(cmd *cobra.Command, args []string) error { if err != nil { return err } - resps := make([]response, 0, len(res.TxRecords)+1) - for _, tx := range res.TxRecords { - existingTx := inTxArray(txsBytesArray, tx.Tx) - if tx.Action == types.TxRecord_UNKNOWN || - (existingTx && tx.Action == types.TxRecord_ADDED) || - (!existingTx && (tx.Action == types.TxRecord_UNMODIFIED || tx.Action == types.TxRecord_REMOVED)) { - resps = append(resps, response{ - Code: codeBad, - Log: "Failed. Tx: " + string(tx.GetTx()) + " action: " + tx.Action.String(), - }) - } else { - resps = append(resps, response{ - Code: code.CodeTypeOK, - Log: "Succeeded. Tx: " + string(tx.Tx) + " action: " + tx.Action.String(), - }) - } + resps := make([]response, 0, len(res.Txs)) + for _, tx := range res.Txs { + resps = append(resps, response{ + Code: code.CodeTypeOK, + Log: "Succeeded. Tx: " + string(tx), + }) } printResponse(cmd, args, resps...) diff --git a/abci/example/kvstore/persistent_kvstore.go b/abci/example/kvstore/persistent_kvstore.go index dfc7a96d7..500d4c5c9 100644 --- a/abci/example/kvstore/persistent_kvstore.go +++ b/abci/example/kvstore/persistent_kvstore.go @@ -310,9 +310,7 @@ const ( ReplacePrefix = "replace" ) -func isPrepareTx(tx []byte) bool { - return bytes.HasPrefix(tx, []byte(PreparePrefix)) -} +func isPrepareTx(tx []byte) bool { return bytes.HasPrefix(tx, []byte(PreparePrefix)) } func isReplacedTx(tx []byte) bool { return bytes.HasPrefix(tx, []byte(ReplacePrefix)) @@ -339,7 +337,7 @@ func (app *PersistentKVStoreApplication) substPrepareTx(blockData [][]byte, maxT if totalBytes > maxTxBytes { break } - txs = append(txs, tx) + txs = append(txs, txMod) } return txs } diff --git a/abci/tests/server/client.go b/abci/tests/server/client.go index 0de84471a..76d315216 100644 --- a/abci/tests/server/client.go +++ b/abci/tests/server/client.go @@ -65,13 +65,13 @@ func DeliverTx(client abcicli.Client, txBytes []byte, codeExp uint32, dataExp [] return nil } -func PrepareProposal(client abcicli.Client, txBytes [][]byte, codeExp []types.TxRecord_TxAction, dataExp []byte) error { +func PrepareProposal(client abcicli.Client, txBytes [][]byte, txExpected [][]byte, dataExp []byte) error { res, _ := client.PrepareProposalSync(types.RequestPrepareProposal{Txs: txBytes}) - for i, tx := range res.TxRecords { - if tx.Action != codeExp[i] { + for i, tx := range res.Txs { + if !bytes.Equal(tx, txExpected[i]) { fmt.Println("Failed test: PrepareProposal") - fmt.Printf("PrepareProposal response code was unexpected. Got %v expected %v.", - tx.Action, codeExp) + fmt.Printf("PrepareProposal transaction was unexpected. Got %x expected %x.", + tx, txExpected[i]) return errors.New("PrepareProposal error") } } diff --git a/abci/tests/test_cli/ex1.abci b/abci/tests/test_cli/ex1.abci index f9817928a..e772593cc 100644 --- a/abci/tests/test_cli/ex1.abci +++ b/abci/tests/test_cli/ex1.abci @@ -11,7 +11,7 @@ deliver_tx "def=xyz" commit query "def" prepare_proposal "preparedef" -process_proposal "def" +process_proposal "replacedef" process_proposal "preparedef" prepare_proposal process_proposal diff --git a/abci/tests/test_cli/ex1.abci.out b/abci/tests/test_cli/ex1.abci.out index 2cc1ad7c1..dbc818855 100644 --- a/abci/tests/test_cli/ex1.abci.out +++ b/abci/tests/test_cli/ex1.abci.out @@ -10,7 +10,7 @@ > prepare_proposal "abc" -> code: OK --> log: Succeeded. Tx: abc action: UNMODIFIED +-> log: Succeeded. Tx: abc > process_proposal "abc" -> code: OK @@ -59,11 +59,9 @@ > prepare_proposal "preparedef" -> code: OK --> log: Succeeded. Tx: def action: ADDED --> code: OK --> log: Succeeded. Tx: preparedef action: REMOVED +-> log: Succeeded. Tx: replacedef -> process_proposal "def" +> process_proposal "replacedef" -> code: OK -> status: ACCEPT