AppendTx -> DeliverTx

This commit is contained in:
Ethan Buchman
2017-01-12 15:27:08 -05:00
parent 2e414ebe6b
commit 80f377135b
28 changed files with 168 additions and 168 deletions
+4 -4
View File
@@ -62,15 +62,15 @@ func Commit(client tmspcli.Client, hashExp []byte) {
}
}
func AppendTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
res := client.AppendTxSync(txBytes)
func DeliverTx(client tmspcli.Client, txBytes []byte, codeExp types.CodeType, dataExp []byte) {
res := client.DeliverTxSync(txBytes)
code, data, log := res.Code, res.Data, res.Log
if code != codeExp {
panic(Fmt("AppendTx response code was unexpected. Got %v expected %v. Log: %v",
panic(Fmt("DeliverTx response code was unexpected. Got %v expected %v. Log: %v",
code, codeExp, log))
}
if !bytes.Equal(data, dataExp) {
panic(Fmt("AppendTx response data was unexpected. Got %X expected %X",
panic(Fmt("DeliverTx response data was unexpected. Got %X expected %X",
data, dataExp))
}
}
+8 -8
View File
@@ -34,15 +34,15 @@ func testCounter() {
SetOption(client, "serial", "on")
Commit(client, nil)
AppendTx(client, []byte("abc"), types.CodeType_BadNonce, nil)
DeliverTx(client, []byte("abc"), types.CodeType_BadNonce, nil)
Commit(client, nil)
AppendTx(client, []byte{0x00}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00}, types.CodeType_OK, nil)
Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 1})
AppendTx(client, []byte{0x00}, types.CodeType_BadNonce, nil)
AppendTx(client, []byte{0x01}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil)
AppendTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil)
DeliverTx(client, []byte{0x00}, types.CodeType_BadNonce, nil)
DeliverTx(client, []byte{0x01}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x02}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x03}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x00, 0x04}, types.CodeType_OK, nil)
DeliverTx(client, []byte{0x00, 0x00, 0x06}, types.CodeType_BadNonce, nil)
Commit(client, []byte{0, 0, 0, 0, 0, 0, 0, 5})
}
+2 -2
View File
@@ -1,10 +1,10 @@
echo hello
info
commit
append_tx "abc"
deliver_tx "abc"
info
commit
query "abc"
append_tx "def=xyz"
deliver_tx "def=xyz"
commit
query "def"
+2 -2
View File
@@ -7,7 +7,7 @@
> commit
-> data: 0x
> append_tx "abc"
> deliver_tx "abc"
-> code: OK
> info
@@ -20,7 +20,7 @@
-> code: OK
-> data: {"index":0,"value":"abc","valueHex":"616263","exists":true}
> append_tx "def=xyz"
> deliver_tx "def=xyz"
-> code: OK
> commit
+3 -3
View File
@@ -1,8 +1,8 @@
set_option serial on
check_tx 0x00
check_tx 0xff
append_tx 0x00
deliver_tx 0x00
check_tx 0x00
append_tx 0x01
append_tx 0x04
deliver_tx 0x01
deliver_tx 0x04
info
+3 -3
View File
@@ -7,17 +7,17 @@
> check_tx 0xff
-> code: OK
> append_tx 0x00
> deliver_tx 0x00
-> code: OK
> check_tx 0x00
-> code: BadNonce
-> log: Invalid nonce. Expected >= 1, got 0
> append_tx 0x01
> deliver_tx 0x01
-> code: OK
> append_tx 0x04
> deliver_tx 0x04
-> code: BadNonce
-> log: Invalid nonce. Expected 2, got 4