WIP refactor working

This commit is contained in:
rigelrozanski 2018-02-15 14:35:46 +00:00 committed by Ethan Buchman
parent 6681904af9
commit 938ee94e9e
6 changed files with 25 additions and 15 deletions

View File

@ -196,6 +196,10 @@ func (app *BaseApp) InitChain(req abci.RequestInitChain) (res abci.ResponseInitC
// TODO: Use req.Validators
// TODO: Use req.AppState in InitStater
if app.InitStater == nil {
return
}
app.msDeliver = app.cms.CacheMultiStore()
ctx := app.GenesisContext(nil)

View File

@ -1,24 +1,23 @@
package testapp
package baseapp
import (
abci "github.com/tendermint/abci/types"
bam "github.com/cosmos/cosmos-sdk/baseapp"
x "github.com/cosmos/cosmos-sdk/baseapp/testapp/x"
"github.com/cosmos/cosmos-sdk/baseapp/testtx"
sdk "github.com/cosmos/cosmos-sdk/types"
)
// TestApp wraps BaseApp with helper methods,
// and exposes more functionality than otherwise needed.
type TestApp struct {
*bam.BaseApp
*BaseApp
// These get set as we receive them.
*abci.ResponseBeginBlock
*abci.ResponseEndBlock
}
func NewTestApp(bapp *bam.BaseApp) *TestApp {
func NewTestApp(bapp *BaseApp) *TestApp {
app := &TestApp{
BaseApp: bapp,
}
@ -78,14 +77,14 @@ func (tapp *TestApp) RunDeliverTx(tx sdk.Tx) sdk.Result {
// run tx through CheckTx of TestApp
// NOTE: Skips authentication by wrapping msg in TestTx{}.
func (tapp *TestApp) RunCheckMsg(msg sdk.Msg) sdk.Result {
var tx = x.TestTx{msg}
var tx = testtx.TestTx{msg}
return tapp.RunCheckTx(tx)
}
// run tx through DeliverTx of TestApp
// NOTE: Skips authentication by wrapping msg in TestTx{}.
func (tapp *TestApp) RunDeliverMsg(msg sdk.Msg) sdk.Result {
var tx = x.TestTx{msg}
var tx = testtx.TestTx{msg}
return tapp.RunDeliverTx(tx)
}

View File

@ -1,4 +1,4 @@
package baseapp
package testtx
import (
"github.com/tendermint/go-crypto"

View File

@ -44,17 +44,18 @@ func NewBasecoinApp(genesisPath string) *BasecoinApp {
)
cdc := accountMapper.WireCodec()
auth.RegisterWireBaseAccount(cdc)
// Make accountMapper's WireCodec() inaccessible.
app.accountMapper = accountMapper.Seal()
// create your application object
var app = &BasecoinApp{
BaseApp: bam.NewBaseApp(appName, accountMapper),
BaseApp: bam.NewBaseApp(appName),
cdc: makeTxCodec(),
capKeyMainStore: mainKey,
capKeyIBCStore: ibcKey,
}
// Make accountMapper's WireCodec() inaccessible.
app.accountMapper = accountMapper.Seal()
app.initBaseAppTxDecoder()
app.initBaseAppInitStater(genesisPath)
@ -110,6 +111,12 @@ func (app *BasecoinApp) initBaseAppInitStater(genesisPath string) {
}
app.BaseApp.SetInitStater(func(ctx sdk.Context, state json.RawMessage) sdk.Error {
// TODO use state ABCI
if state == nil {
state = genesisAppState
}
if state == nil {
return nil
}

View File

@ -26,7 +26,7 @@ func newTestBasecoinApp() *testBasecoinApp {
tba := &testBasecoinApp{
BasecoinApp: app,
}
tba.TestApp = testapp.NewTestApp(app.BaseApp)
tba.TestApp = bam.NewTestApp(app.BaseApp)
return tba
}

View File

@ -1,7 +1,7 @@
package auth
import (
tax "github.com/cosmos/cosmos-sdk/baseapp/testapp/x"
"github.com/cosmos/cosmos-sdk/baseapp/testtx"
sdk "github.com/cosmos/cosmos-sdk/types"
)
@ -32,7 +32,7 @@ func NewAnteHandler(accountMapper sdk.AccountMapper) sdk.AnteHandler {
var sigs = tx.GetSignatures()
// Assert that there are signatures.
if !tax.IsTestAppTx(tx) {
if !testtx.IsTestAppTx(tx) {
if len(sigs) == 0 {
return ctx,
sdk.ErrUnauthorized("no signers").Result(),
@ -46,7 +46,7 @@ func NewAnteHandler(accountMapper sdk.AccountMapper) sdk.AnteHandler {
var signerAccs = make([]sdk.Account, len(signerAddrs))
// Assert that number of signatures is correct.
if !tax.IsTestAppTx(tx) {
if !testtx.IsTestAppTx(tx) {
if len(sigs) != len(signerAddrs) {
return ctx,
sdk.ErrUnauthorized("wrong number of signers").Result(),