Eyes takes init state, fix cli test about genesis
This commit is contained in:
parent
3316bfcfb8
commit
9b206153e2
|
@ -11,6 +11,7 @@ import (
|
||||||
"github.com/cosmos/cosmos-sdk/modules/auth"
|
"github.com/cosmos/cosmos-sdk/modules/auth"
|
||||||
"github.com/cosmos/cosmos-sdk/modules/base"
|
"github.com/cosmos/cosmos-sdk/modules/base"
|
||||||
"github.com/cosmos/cosmos-sdk/modules/coin"
|
"github.com/cosmos/cosmos-sdk/modules/coin"
|
||||||
|
"github.com/cosmos/cosmos-sdk/modules/eyes"
|
||||||
"github.com/cosmos/cosmos-sdk/modules/fee"
|
"github.com/cosmos/cosmos-sdk/modules/fee"
|
||||||
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
"github.com/cosmos/cosmos-sdk/modules/ibc"
|
||||||
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
"github.com/cosmos/cosmos-sdk/modules/nonce"
|
||||||
|
@ -45,6 +46,8 @@ func BuildApp(feeDenom string) sdk.Handler {
|
||||||
coin.NewHandler(),
|
coin.NewHandler(),
|
||||||
stack.WrapHandler(roles.NewHandler()),
|
stack.WrapHandler(roles.NewHandler()),
|
||||||
stack.WrapHandler(ibc.NewHandler()),
|
stack.WrapHandler(ibc.NewHandler()),
|
||||||
|
// and just for run, add eyes as well
|
||||||
|
stack.WrapHandler(eyes.NewHandler()),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,7 @@ test01initOption() {
|
||||||
GENESIS_FILE=${SERVE_DIR}/genesis.json
|
GENESIS_FILE=${SERVE_DIR}/genesis.json
|
||||||
HEX="deadbeef1234deadbeef1234deadbeef1234aaaa"
|
HEX="deadbeef1234deadbeef1234deadbeef1234aaaa"
|
||||||
|
|
||||||
${SERVER_EXE} init ${HEX} --home="$SERVE_DIR" -p=app1/key1/val1 -p='"app2/key2/{""name"": ""joe"", ""age"": ""100""}"' >/dev/null
|
${SERVER_EXE} init ${HEX} --home="$SERVE_DIR" -p=eyes/key1/val1 -p='"eyes/key2/{""name"": ""joe"", ""age"": ""100""}"' >/dev/null
|
||||||
if ! assertTrue "line=${LINENO}" $?; then return 1; fi
|
if ! assertTrue "line=${LINENO}" $?; then return 1; fi
|
||||||
|
|
||||||
OPTION1KEY=$(cat ${GENESIS_FILE} | jq '.app_options.plugin_options[2]')
|
OPTION1KEY=$(cat ${GENESIS_FILE} | jq '.app_options.plugin_options[2]')
|
||||||
|
@ -21,9 +21,9 @@ test01initOption() {
|
||||||
OPTION2VAL=$(cat ${GENESIS_FILE} | jq '.app_options.plugin_options[5]')
|
OPTION2VAL=$(cat ${GENESIS_FILE} | jq '.app_options.plugin_options[5]')
|
||||||
OPTION2VALEXPECTED=$(echo '{"name": "joe", "age": "100"}' | jq '.')
|
OPTION2VALEXPECTED=$(echo '{"name": "joe", "age": "100"}' | jq '.')
|
||||||
|
|
||||||
assertEquals "line=${LINENO}" '"app1/key1"' $OPTION1KEY
|
assertEquals "line=${LINENO}" '"eyes/key1"' $OPTION1KEY
|
||||||
assertEquals "line=${LINENO}" '"val1"' $OPTION1VAL
|
assertEquals "line=${LINENO}" '"val1"' $OPTION1VAL
|
||||||
assertEquals "line=${LINENO}" '"app2/key2"' $OPTION2KEY
|
assertEquals "line=${LINENO}" '"eyes/key2"' $OPTION2KEY
|
||||||
assertEquals "line=${LINENO}" "$OPTION2VALEXPECTED" "$OPTION2VAL"
|
assertEquals "line=${LINENO}" "$OPTION2VALEXPECTED" "$OPTION2VAL"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,10 +1,12 @@
|
||||||
package eyes
|
package eyes
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
wire "github.com/tendermint/go-wire"
|
||||||
|
"github.com/tendermint/tmlibs/log"
|
||||||
|
|
||||||
sdk "github.com/cosmos/cosmos-sdk"
|
sdk "github.com/cosmos/cosmos-sdk"
|
||||||
"github.com/cosmos/cosmos-sdk/errors"
|
"github.com/cosmos/cosmos-sdk/errors"
|
||||||
"github.com/cosmos/cosmos-sdk/state"
|
"github.com/cosmos/cosmos-sdk/state"
|
||||||
wire "github.com/tendermint/go-wire"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
@ -19,7 +21,6 @@ const (
|
||||||
|
|
||||||
// Handler allows us to set and remove data
|
// Handler allows us to set and remove data
|
||||||
type Handler struct {
|
type Handler struct {
|
||||||
sdk.NopInitState
|
|
||||||
sdk.NopInitValidate
|
sdk.NopInitValidate
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +36,16 @@ func (Handler) Name() string {
|
||||||
return Name
|
return Name
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// InitState - sets the genesis state
|
||||||
|
func (h Handler) InitState(l log.Logger, store state.SimpleDB,
|
||||||
|
module, key, value string) (log string, err error) {
|
||||||
|
if module != Name {
|
||||||
|
return "", errors.ErrUnknownModule(module)
|
||||||
|
}
|
||||||
|
store.Set([]byte(key), []byte(value))
|
||||||
|
return key, nil
|
||||||
|
}
|
||||||
|
|
||||||
// CheckTx verifies if the transaction is properly formated
|
// CheckTx verifies if the transaction is properly formated
|
||||||
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) {
|
func (h Handler) CheckTx(ctx sdk.Context, store state.SimpleDB, tx sdk.Tx) (res sdk.CheckResult, err error) {
|
||||||
err = tx.ValidateBasic()
|
err = tx.ValidateBasic()
|
||||||
|
|
Loading…
Reference in New Issue