From 4b69f1d5bad35dab3107e54f3c3b98e9a4627c46 Mon Sep 17 00:00:00 2001 From: Ethan Frey Date: Sun, 30 Jul 2017 12:57:48 -0400 Subject: [PATCH] Rename SetOption to InitState --- TODO.md | 8 +++++ app/app.go | 12 +++++-- app/app_test.go | 20 ++++++------ app/genesis.go | 6 ++-- benchmarks/app_test.go | 4 +-- .../counter/plugins/counter/counter_test.go | 4 +-- handler.go | 22 +++++++------ modules/base/logger.go | 10 +++--- modules/coin/bench_test.go | 2 +- modules/coin/handler.go | 6 ++-- modules/coin/handler_test.go | 10 +++--- modules/coin/helper.go | 2 +- modules/coin/ibc_test.go | 2 +- modules/fee/handler_test.go | 4 +-- modules/ibc/handler.go | 6 ++-- modules/ibc/ibc_test.go | 2 +- modules/ibc/test_helpers.go | 6 ++-- stack/dispatcher.go | 8 ++--- stack/interface.go | 32 +++++++++---------- stack/middleware.go | 4 +-- stack/recovery.go | 6 ++-- stack/state_space_test.go | 8 ++--- 22 files changed, 100 insertions(+), 84 deletions(-) create mode 100644 TODO.md diff --git a/TODO.md b/TODO.md new file mode 100644 index 0000000000..2eb6af8702 --- /dev/null +++ b/TODO.md @@ -0,0 +1,8 @@ +# TODO for rewrite + +* Reimplement MultiTx in base + +* FeeTx and CheckTx changes logic to estimate, not validate +* Add tests for new CheckTx +* Handle ValidatorSet responses from DeliverTx calls in EndBlock +* Add InitValidator call to all modules diff --git a/app/app.go b/app/app.go index ca62ea80f8..d054592978 100644 --- a/app/app.go +++ b/app/app.go @@ -65,8 +65,9 @@ func (app *Basecoin) Info() abci.ResponseInfo { } } -// SetOption - ABCI -func (app *Basecoin) SetOption(key string, value string) string { +// InitState - used to setup state (was SetOption) +// to be used by InitChain later +func (app *Basecoin) InitState(key string, value string) string { module, key := splitKey(key) state := app.state.Append() @@ -79,13 +80,18 @@ func (app *Basecoin) SetOption(key string, value string) string { return fmt.Sprintf("Error: unknown base option: %s", key) } - log, err := app.handler.SetOption(app.logger, state, module, key, value) + log, err := app.handler.InitState(app.logger, state, module, key, value) if err == nil { return log } return "Error: " + err.Error() } +// SetOption - ABCI +func (app *Basecoin) SetOption(key string, value string) string { + return "Not Implemented" +} + // DeliverTx - ABCI func (app *Basecoin) DeliverTx(txBytes []byte) abci.Result { tx, err := basecoin.LoadTx(txBytes) diff --git a/app/app_test.go b/app/app_test.go index 4bef8443c8..0da5b31c1a 100644 --- a/app/app_test.go +++ b/app/app_test.go @@ -98,9 +98,9 @@ func (at *appTest) feeTx(coins coin.Coins, toll coin.Coin, sequence uint32) base return at.signTx(tx) } -// set the account on the app through SetOption +// set the account on the app through InitState func (at *appTest) initAccount(acct *coin.AccountWithKey) { - res := at.app.SetOption("coin/account", acct.MakeOption()) + res := at.app.InitState("coin/account", acct.MakeOption()) require.EqualValues(at.t, res, "Success") } @@ -121,7 +121,7 @@ func (at *appTest) reset() { logger.With("module", "app"), ) - res := at.app.SetOption("base/chain_id", at.chainID) + res := at.app.InitState("base/chain_id", at.chainID) require.EqualValues(at.t, res, "Success") at.initAccount(at.acctIn) @@ -167,7 +167,7 @@ func (at *appTest) exec(t *testing.T, tx basecoin.Tx, checkTx bool) (res abci.Re //-------------------------------------------------------- -func TestSetOption(t *testing.T) { +func TestInitState(t *testing.T) { assert := assert.New(t) require := require.New(t) @@ -183,14 +183,14 @@ func TestSetOption(t *testing.T) { //testing ChainID chainID := "testChain" - res := app.SetOption("base/chain_id", chainID) + res := app.InitState("base/chain_id", chainID) assert.EqualValues(app.GetChainID(), chainID) assert.EqualValues(res, "Success") // make a nice account... bal := coin.Coins{{"atom", 77}, {"eth", 12}} acct := coin.NewAccountWithKey(bal) - res = app.SetOption("coin/account", acct.MakeOption()) + res = app.InitState("coin/account", acct.MakeOption()) require.EqualValues(res, "Success") // make sure it is set correctly, with some balance @@ -218,7 +218,7 @@ func TestSetOption(t *testing.T) { } ] }` - res = app.SetOption("coin/account", unsortAcc) + res = app.InitState("coin/account", unsortAcc) require.EqualValues(res, "Success") coins, err = getAddr(unsortAddr, app.GetState()) @@ -226,13 +226,13 @@ func TestSetOption(t *testing.T) { assert.True(coins.IsValid()) assert.Equal(unsortCoins, coins) - res = app.SetOption("base/dslfkgjdas", "") + res = app.InitState("base/dslfkgjdas", "") assert.NotEqual(res, "Success") - res = app.SetOption("dslfkgjdas", "") + res = app.InitState("dslfkgjdas", "") assert.NotEqual(res, "Success") - res = app.SetOption("dslfkgjdas/szfdjzs", "") + res = app.InitState("dslfkgjdas/szfdjzs", "") assert.NotEqual(res, "Success") } diff --git a/app/genesis.go b/app/genesis.go index 87c60227f9..81d99fead9 100644 --- a/app/genesis.go +++ b/app/genesis.go @@ -16,16 +16,16 @@ func (app *Basecoin) LoadGenesis(path string) error { } // set chain_id - app.SetOption("base/chain_id", genDoc.ChainID) + app.InitState("base/chain_id", genDoc.ChainID) // set accounts for _, acct := range genDoc.AppOptions.Accounts { - _ = app.SetOption("coin/account", string(acct)) + _ = app.InitState("coin/account", string(acct)) } // set plugin options for _, kv := range genDoc.AppOptions.pluginOptions { - _ = app.SetOption(kv.Key, kv.Value) + _ = app.InitState(kv.Key, kv.Value) } return nil diff --git a/benchmarks/app_test.go b/benchmarks/app_test.go index 96487afe09..b25ffce0cc 100644 --- a/benchmarks/app_test.go +++ b/benchmarks/app_test.go @@ -72,7 +72,7 @@ func NewBenchApp(h basecoin.Handler, chainID string, n int, store, logger.With("module", "app"), ) - res := app.SetOption("base/chain_id", chainID) + res := app.InitState("base/chain_id", chainID) if res != "Success" { panic("cannot set chain") } @@ -82,7 +82,7 @@ func NewBenchApp(h basecoin.Handler, chainID string, n int, accts := make([]*coin.AccountWithKey, n) for i := 0; i < n; i++ { accts[i] = coin.NewAccountWithKey(money) - res := app.SetOption("coin/account", accts[i].MakeOption()) + res := app.InitState("coin/account", accts[i].MakeOption()) if res != "Success" { panic("can't set account") } diff --git a/docs/guide/counter/plugins/counter/counter_test.go b/docs/guide/counter/plugins/counter/counter_test.go index b9fb9c2d59..968760492d 100644 --- a/docs/guide/counter/plugins/counter/counter_test.go +++ b/docs/guide/counter/plugins/counter/counter_test.go @@ -36,12 +36,12 @@ func TestCounterPlugin(t *testing.T) { store, logger.With("module", "app"), ) - bcApp.SetOption("base/chain_id", chainID) + bcApp.InitState("base/chain_id", chainID) // Account initialization bal := coin.Coins{{"", 1000}, {"gold", 1000}} acct := coin.NewAccountWithKey(bal) - log := bcApp.SetOption("coin/account", acct.MakeOption()) + log := bcApp.InitState("coin/account", acct.MakeOption()) require.Equal("Success", log) // Deliver a CounterTx diff --git a/handler.go b/handler.go index d2858ea949..a7e2b7334f 100644 --- a/handler.go +++ b/handler.go @@ -12,12 +12,14 @@ import ( type Handler interface { Checker Deliver - SetOptioner + // This is for app options + InitStater Named - // TODO: flesh these out as well - // InitChain(store state.SimpleDB, vals []*abci.Validator) + // TODO: for staker + // InitChain(log log.Logger, store state.SimpleDB, vals []*abci.Validator) + + // TODO???? // BeginBlock(store state.SimpleDB, hash []byte, header *abci.Header) - // EndBlock(store state.SimpleDB, height uint64) abci.ResponseEndBlock } type Named interface { @@ -46,14 +48,14 @@ func (c DeliverFunc) DeliverTx(ctx Context, store state.SimpleDB, tx Tx) (Delive return c(ctx, store, tx) } -type SetOptioner interface { - SetOption(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) +type InitStater interface { + InitState(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) } -// SetOptionFunc (like http.HandlerFunc) is a shortcut for making wrapers -type SetOptionFunc func(log.Logger, state.SimpleDB, string, string, string) (string, error) +// InitStateFunc (like http.HandlerFunc) is a shortcut for making wrapers +type InitStateFunc func(log.Logger, state.SimpleDB, string, string, string) (string, error) -func (c SetOptionFunc) SetOption(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) { +func (c InitStateFunc) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) { return c(l, store, module, key, value) } @@ -119,6 +121,6 @@ func (_ NopDeliver) DeliverTx(Context, state.SimpleDB, Tx) (r DeliverResult, e e type NopOption struct{} -func (_ NopOption) SetOption(log.Logger, state.SimpleDB, string, string, string) (string, error) { +func (_ NopOption) InitState(log.Logger, state.SimpleDB, string, string, string) (string, error) { return "", nil } diff --git a/modules/base/logger.go b/modules/base/logger.go index 126e3d056a..581fcfb42b 100644 --- a/modules/base/logger.go +++ b/modules/base/logger.go @@ -55,17 +55,17 @@ func (Logger) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoin. return } -// SetOption logs time and result - fulfills Middlware interface -func (Logger) SetOption(l log.Logger, store state.SimpleDB, module, key, value string, next basecoin.SetOptioner) (string, error) { +// InitState logs time and result - fulfills Middlware interface +func (Logger) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next basecoin.InitStater) (string, error) { start := time.Now() - res, err := next.SetOption(l, store, module, key, value) + res, err := next.InitState(l, store, module, key, value) delta := time.Now().Sub(start) // TODO: log the value being set also? l = l.With("duration", micros(delta)).With("mod", module).With("key", key) if err == nil { - l.Info("SetOption", "log", res) + l.Info("InitState", "log", res) } else { - l.Error("SetOption", "err", err) + l.Error("InitState", "err", err) } return res, err } diff --git a/modules/coin/bench_test.go b/modules/coin/bench_test.go index bc83ea90cc..cfa7b708b8 100644 --- a/modules/coin/bench_test.go +++ b/modules/coin/bench_test.go @@ -28,7 +28,7 @@ func BenchmarkSimpleTransfer(b *testing.B) { // set the initial account acct := NewAccountWithKey(Coins{{"mycoin", 1234567890}}) - h.SetOption(logger, store, NameCoin, "account", acct.MakeOption(), nil) + h.InitState(logger, store, NameCoin, "account", acct.MakeOption(), nil) sender := acct.Actor() receiver := basecoin.Actor{App: "foo", Address: cmn.RandBytes(20)} diff --git a/modules/coin/handler.go b/modules/coin/handler.go index cb1f4093dc..dfaa2fa173 100644 --- a/modules/coin/handler.go +++ b/modules/coin/handler.go @@ -69,9 +69,9 @@ func (h Handler) DeliverTx(ctx basecoin.Context, store state.SimpleDB, return res, errors.ErrUnknownTxType(tx.Unwrap()) } -// SetOption - sets the genesis account balance -func (h Handler) SetOption(l log.Logger, store state.SimpleDB, - module, key, value string, cb basecoin.SetOptioner) (log string, err error) { +// InitState - sets the genesis account balance +func (h Handler) InitState(l log.Logger, store state.SimpleDB, + module, key, value string, cb basecoin.InitStater) (log string, err error) { if module != NameCoin { return "", errors.ErrUnknownModule(module) } diff --git a/modules/coin/handler_test.go b/modules/coin/handler_test.go index b0f20c42fd..d43e20fa4e 100644 --- a/modules/coin/handler_test.go +++ b/modules/coin/handler_test.go @@ -167,7 +167,7 @@ func TestDeliverSendTx(t *testing.T) { } } -func TestSetOption(t *testing.T) { +func TestInitState(t *testing.T) { assert := assert.New(t) require := require.New(t) @@ -205,7 +205,7 @@ func TestSetOption(t *testing.T) { for j, gen := range tc.init { value, err := json.Marshal(gen) require.Nil(err, "%d,%d: %+v", i, j, err) - _, err = h.SetOption(l, store, NameCoin, key, string(value), nil) + _, err = h.InitState(l, store, NameCoin, key, string(value), nil) require.Nil(err) } @@ -239,7 +239,7 @@ func TestSetIssuer(t *testing.T) { value, err := json.Marshal(tc.issuer) require.Nil(err, "%d,%d: %+v", i, err) - _, err = h.SetOption(l, store, NameCoin, key, string(value), nil) + _, err = h.InitState(l, store, NameCoin, key, string(value), nil) require.Nil(err, "%+v", err) // check state is proper @@ -274,11 +274,11 @@ func TestDeliverCreditTx(t *testing.T) { // set the owner who can issue credit js, err := json.Marshal(owner) require.Nil(err, "%+v", err) - _, err = h.SetOption(log.NewNopLogger(), store, "coin", "issuer", string(js), nil) + _, err = h.InitState(log.NewNopLogger(), store, "coin", "issuer", string(js), nil) require.Nil(err, "%+v", err) // give addr2 some coins to start - _, err = h.SetOption(log.NewNopLogger(), store, "coin", "account", key.MakeOption(), nil) + _, err = h.InitState(log.NewNopLogger(), store, "coin", "account", key.MakeOption(), nil) require.Nil(err, "%+v", err) cases := []struct { diff --git a/modules/coin/helper.go b/modules/coin/helper.go index 4bf98cddc7..c4af2f080e 100644 --- a/modules/coin/helper.go +++ b/modules/coin/helper.go @@ -41,7 +41,7 @@ func (a *AccountWithKey) NextSequence() uint32 { return a.Sequence } -// MakeOption returns a string to use with SetOption to initialize this account +// MakeOption returns a string to use with InitState to initialize this account // // This is intended for use in test cases func (a *AccountWithKey) MakeOption() string { diff --git a/modules/coin/ibc_test.go b/modules/coin/ibc_test.go index 7b4014a324..81aeb83655 100644 --- a/modules/coin/ibc_test.go +++ b/modules/coin/ibc_test.go @@ -44,7 +44,7 @@ func TestIBCPostPacket(t *testing.T) { // set up a rich guy on this chain wealth := Coins{{"btc", 300}, {"eth", 2000}, {"ltc", 5000}} rich := NewAccountWithKey(wealth) - _, err = ourChain.SetOption("coin", "account", rich.MakeOption()) + _, err = ourChain.InitState("coin", "account", rich.MakeOption()) require.Nil(err, "%+v", err) // sends money to another guy on a different chain, now other chain has credit diff --git a/modules/fee/handler_test.go b/modules/fee/handler_test.go index 000d99f0ba..3fb72abaa3 100644 --- a/modules/fee/handler_test.go +++ b/modules/fee/handler_test.go @@ -50,9 +50,9 @@ func TestFeeChecks(t *testing.T) { // set up the store and init the accounts store := state.NewMemKVStore() l := log.NewNopLogger() - _, err := app1.SetOption(l, store, "coin", "account", key1.MakeOption()) + _, err := app1.InitState(l, store, "coin", "account", key1.MakeOption()) require.Nil(err, "%+v", err) - _, err = app2.SetOption(l, store, "coin", "account", key2.MakeOption()) + _, err = app2.InitState(l, store, "coin", "account", key2.MakeOption()) require.Nil(err, "%+v", err) cases := []struct { diff --git a/modules/ibc/handler.go b/modules/ibc/handler.go index 297957af9a..298f62780e 100644 --- a/modules/ibc/handler.go +++ b/modules/ibc/handler.go @@ -39,7 +39,7 @@ type Handler struct{} var _ basecoin.Handler = Handler{} // NewHandler returns a Handler that allows all chains to connect via IBC. -// Set a Registrar via SetOption to restrict it. +// Set a Registrar via InitState to restrict it. func NewHandler() Handler { return Handler{} } @@ -49,8 +49,8 @@ func (Handler) Name() string { return NameIBC } -// SetOption sets the registrar for IBC -func (h Handler) SetOption(l log.Logger, store state.SimpleDB, module, key, value string) (log string, err error) { +// InitState sets the registrar for IBC +func (h Handler) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (log string, err error) { if module != NameIBC { return "", errors.ErrUnknownModule(module) } diff --git a/modules/ibc/ibc_test.go b/modules/ibc/ibc_test.go index c31aeae53a..1fb0394194 100644 --- a/modules/ibc/ibc_test.go +++ b/modules/ibc/ibc_test.go @@ -130,7 +130,7 @@ func TestIBCRegisterPermissions(t *testing.T) { // set option specifies the registrar msg, err := json.Marshal(tc.registrar) require.Nil(err, "%+v", err) - _, err = app.SetOption(log.NewNopLogger(), store, + _, err = app.InitState(log.NewNopLogger(), store, NameIBC, OptionRegistrar, string(msg)) require.Nil(err, "%+v", err) diff --git a/modules/ibc/test_helpers.go b/modules/ibc/test_helpers.go index 089bc5d9f5..d2272a0e08 100644 --- a/modules/ibc/test_helpers.go +++ b/modules/ibc/test_helpers.go @@ -118,9 +118,9 @@ func (a *AppChain) Update(tx UpdateChainTx) error { return err } -// SetOption sets the option on our app -func (a *AppChain) SetOption(mod, key, value string) (string, error) { - return a.app.SetOption(log.NewNopLogger(), a.store, mod, key, value) +// InitState sets the option on our app +func (a *AppChain) InitState(mod, key, value string) (string, error) { + return a.app.InitState(log.NewNopLogger(), a.store, mod, key, value) } // GetStore is used to get the app-specific sub-store diff --git a/stack/dispatcher.go b/stack/dispatcher.go index 0efd7d3396..e4a34c0b7f 100644 --- a/stack/dispatcher.go +++ b/stack/dispatcher.go @@ -101,11 +101,11 @@ func (d *Dispatcher) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx ba return r.DeliverTx(ctx, store, tx, cb) } -// SetOption - implements Handler interface +// InitState - implements Handler interface // // Tries to find a registered module (Dispatchable) based on the -// module name from SetOption of the tx. -func (d *Dispatcher) SetOption(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) { +// module name from InitState of the tx. +func (d *Dispatcher) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) { r, err := d.lookupModule(module) if err != nil { return "", err @@ -116,7 +116,7 @@ func (d *Dispatcher) SetOption(l log.Logger, store state.SimpleDB, module, key, // but isolate data space store = stateSpace(store, r.Name()) - return r.SetOption(l, store, module, key, value, cb) + return r.InitState(l, store, module, key, value, cb) } func (d *Dispatcher) lookupTx(tx basecoin.Tx) (Dispatchable, error) { diff --git a/stack/interface.go b/stack/interface.go index 81cdbffad5..173e61d143 100644 --- a/stack/interface.go +++ b/stack/interface.go @@ -15,7 +15,7 @@ import ( type Middleware interface { CheckerMiddle DeliverMiddle - SetOptionMiddle + InitStateMiddle basecoin.Named } @@ -45,16 +45,16 @@ func (d DeliverMiddleFunc) DeliverTx(ctx basecoin.Context, store state.SimpleDB, return d(ctx, store, tx, next) } -type SetOptionMiddle interface { - SetOption(l log.Logger, store state.SimpleDB, module, - key, value string, next basecoin.SetOptioner) (string, error) +type InitStateMiddle interface { + InitState(l log.Logger, store state.SimpleDB, module, + key, value string, next basecoin.InitStater) (string, error) } -type SetOptionMiddleFunc func(log.Logger, state.SimpleDB, - string, string, string, basecoin.SetOptioner) (string, error) +type InitStateMiddleFunc func(log.Logger, state.SimpleDB, + string, string, string, basecoin.InitStater) (string, error) -func (c SetOptionMiddleFunc) SetOption(l log.Logger, store state.SimpleDB, - module, key, value string, next basecoin.SetOptioner) (string, error) { +func (c InitStateMiddleFunc) InitState(l log.Logger, store state.SimpleDB, + module, key, value string, next basecoin.InitStater) (string, error) { return c(l, store, module, key, value, next) } @@ -75,15 +75,15 @@ func (_ PassDeliver) DeliverTx(ctx basecoin.Context, store state.SimpleDB, type PassOption struct{} -func (_ PassOption) SetOption(l log.Logger, store state.SimpleDB, module, - key, value string, next basecoin.SetOptioner) (string, error) { - return next.SetOption(l, store, module, key, value) +func (_ PassOption) InitState(l log.Logger, store state.SimpleDB, module, + key, value string, next basecoin.InitStater) (string, error) { + return next.InitState(l, store, module, key, value) } type NopOption struct{} -func (_ NopOption) SetOption(l log.Logger, store state.SimpleDB, module, - key, value string, next basecoin.SetOptioner) (string, error) { +func (_ NopOption) InitState(l log.Logger, store state.SimpleDB, module, + key, value string, next basecoin.InitStater) (string, error) { return "", nil } @@ -122,7 +122,7 @@ func (w wrapped) DeliverTx(ctx basecoin.Context, store state.SimpleDB, return w.h.DeliverTx(ctx, store, tx) } -func (w wrapped) SetOption(l log.Logger, store state.SimpleDB, - module, key, value string, _ basecoin.SetOptioner) (string, error) { - return w.h.SetOption(l, store, module, key, value) +func (w wrapped) InitState(l log.Logger, store state.SimpleDB, + module, key, value string, _ basecoin.InitStater) (string, error) { + return w.h.InitState(l, store, module, key, value) } diff --git a/stack/middleware.go b/stack/middleware.go index e24e86bde0..4ba29a2023 100644 --- a/stack/middleware.go +++ b/stack/middleware.go @@ -52,11 +52,11 @@ func (m *middleware) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx ba return m.middleware.DeliverTx(ctx, store, tx, next) } -func (m *middleware) SetOption(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) { +func (m *middleware) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) { // set the namespace for the app store = stateSpace(store, m.space) - return m.middleware.SetOption(l, store, module, key, value, m.next) + return m.middleware.InitState(l, store, module, key, value, m.next) } // builder is used to associate info with the middleware, so we can build diff --git a/stack/recovery.go b/stack/recovery.go index eae976ad0a..e5b986ef27 100644 --- a/stack/recovery.go +++ b/stack/recovery.go @@ -45,14 +45,14 @@ func (Recovery) DeliverTx(ctx basecoin.Context, store state.SimpleDB, tx basecoi return next.DeliverTx(ctx, store, tx) } -// SetOption catches any panic and converts to error - fulfills Middlware interface -func (Recovery) SetOption(l log.Logger, store state.SimpleDB, module, key, value string, next basecoin.SetOptioner) (log string, err error) { +// InitState catches any panic and converts to error - fulfills Middlware interface +func (Recovery) InitState(l log.Logger, store state.SimpleDB, module, key, value string, next basecoin.InitStater) (log string, err error) { defer func() { if r := recover(); r != nil { err = normalizePanic(r) } }() - return next.SetOption(l, store, module, key, value) + return next.InitState(l, store, module, key, value) } // normalizePanic makes sure we can get a nice TMError (with stack) out of it diff --git a/stack/state_space_test.go b/stack/state_space_test.go index 1b3a6f3683..b18671106d 100644 --- a/stack/state_space_test.go +++ b/stack/state_space_test.go @@ -35,10 +35,10 @@ func (w writerMid) DeliverTx(ctx basecoin.Context, store state.SimpleDB, return next.DeliverTx(ctx, store, tx) } -func (w writerMid) SetOption(l log.Logger, store state.SimpleDB, module, - key, value string, next basecoin.SetOptioner) (string, error) { +func (w writerMid) InitState(l log.Logger, store state.SimpleDB, module, + key, value string, next basecoin.InitStater) (string, error) { store.Set([]byte(key), []byte(value)) - return next.SetOption(l, store, module, key, value) + return next.InitState(l, store, module, key, value) } // writerHand is a middleware that writes the given bytes on CheckTx and DeliverTx @@ -63,7 +63,7 @@ func (w writerHand) DeliverTx(ctx basecoin.Context, store state.SimpleDB, return basecoin.DeliverResult{}, nil } -func (w writerHand) SetOption(l log.Logger, store state.SimpleDB, module, +func (w writerHand) InitState(l log.Logger, store state.SimpleDB, module, key, value string) (string, error) { store.Set([]byte(key), []byte(value)) return "Success", nil