Separation of Tx from Msg; CodeType

This commit is contained in:
Jae Kwon
2018-01-26 06:54:03 -08:00
parent 05036e35d2
commit b95b67d520
14 changed files with 154 additions and 115 deletions
+5 -1
View File
@@ -30,7 +30,11 @@ func TestSendMsg(t *testing.T) {
},
}
// Run a SendMsg.
// Run a Check on SendMsg.
res := tba.RunCheckMsg(msg)
assert.Equal(t, sdk.CodeOK, res.Code, res.Log)
// Run a Deliver on SendMsg.
res = tba.RunDeliverMsg(msg)
assert.Equal(t, sdk.CodeUnrecognizedAddress, res.Code, res.Log)
}
+3 -3
View File
@@ -51,10 +51,10 @@ func main() {
}
func DummyHandler(storeKey sdk.StoreKey) sdk.Handler {
return func(ctx sdk.Context, tx sdk.Tx) sdk.Result {
return func(ctx sdk.Context, msg sdk.Msg) sdk.Result {
// tx is already unmarshalled
key := tx.Get("key").([]byte)
value := tx.Get("value").([]byte)
key := msg.Get("key").([]byte)
value := msg.Get("value").([]byte)
store := ctx.KVStore(storeKey)
store.Set(key, value)
+5
View File
@@ -7,6 +7,7 @@ import (
crypto "github.com/tendermint/go-crypto"
)
// An sdk.Tx which is its own sdk.Msg.
type dummyTx struct {
key []byte
value []byte
@@ -30,6 +31,10 @@ func (tx dummyTx) Type() string {
return "dummy"
}
func (tx dummyTx) GetMsg() sdk.Msg {
return tx
}
func (tx dummyTx) GetSignBytes() []byte {
return tx.bytes
}