...
This commit is contained in:
parent
2b9633db4a
commit
fd1684ab6b
|
@ -32,15 +32,18 @@ type BasecoinApp struct {
|
||||||
|
|
||||||
// NewBasecoinApp - create new BasecoinApp
|
// NewBasecoinApp - create new BasecoinApp
|
||||||
// TODO: This should take in more configuration options.
|
// TODO: This should take in more configuration options.
|
||||||
// TODO: This should be moved into
|
// TODO: This should be moved into baseapp to isolate complexity
|
||||||
func NewBasecoinApp(genesisPath string) *BasecoinApp {
|
func NewBasecoinApp(genesisPath string) *BasecoinApp {
|
||||||
|
|
||||||
// Create and configure app.
|
// Create and configure app.
|
||||||
var app = &BasecoinApp{}
|
var app = &BasecoinApp{}
|
||||||
|
|
||||||
app.initCapKeys() // ./init_capkeys.go
|
// TODO open up out of functions, or introduce clarity,
|
||||||
app.initBaseApp() // ./init_baseapp.go
|
// interdependancies are a nightmare to debug
|
||||||
app.initStores() // ./init_stores.go
|
app.initCapKeys() // ./init_capkeys.go
|
||||||
|
app.initBaseApp() // ./init_baseapp.go
|
||||||
|
app.initStores() // ./init_stores.go
|
||||||
|
app.initBaseAppInitStater()
|
||||||
app.initHandlers() // ./init_handlers.go
|
app.initHandlers() // ./init_handlers.go
|
||||||
|
|
||||||
genesisiDoc, err := bam.GenesisDocFromFile(genesisPath)
|
genesisiDoc, err := bam.GenesisDocFromFile(genesisPath)
|
||||||
|
@ -50,26 +53,27 @@ func NewBasecoinApp(genesisPath string) *BasecoinApp {
|
||||||
|
|
||||||
// TODO: InitChain with validators from genesis transaction bytes
|
// TODO: InitChain with validators from genesis transaction bytes
|
||||||
|
|
||||||
// set first begin block
|
// very first begin block used for context when setting genesis accounts
|
||||||
header := abci.Header{
|
header := abci.Header{
|
||||||
ChainID: "",
|
ChainID: "",
|
||||||
Height: 0,
|
Height: 0,
|
||||||
Time: -1, // TODO
|
Time: -1,
|
||||||
NumTxs: -1, // TODO
|
NumTxs: -1,
|
||||||
LastCommitHash: []byte{0x00},
|
LastCommitHash: []byte{0x00},
|
||||||
DataHash: nil, // TODO
|
DataHash: nil,
|
||||||
ValidatorsHash: nil, // TODO
|
ValidatorsHash: nil,
|
||||||
AppHash: nil, // TODO
|
AppHash: nil,
|
||||||
}
|
}
|
||||||
app.BaseApp.BeginBlock(abci.RequestBeginBlock{
|
app.BaseApp.BeginBlock(abci.RequestBeginBlock{
|
||||||
Hash: nil, // TODO
|
Hash: nil,
|
||||||
Header: header,
|
Header: header,
|
||||||
AbsentValidators: nil, // TODO
|
AbsentValidators: nil,
|
||||||
ByzantineValidators: nil, // TODO
|
ByzantineValidators: nil,
|
||||||
})
|
})
|
||||||
|
|
||||||
ctxCheckTx := app.BaseApp.NewContext(true, nil)
|
ctxCheckTx := app.BaseApp.NewContext(true, nil)
|
||||||
ctxDeliverTx := app.BaseApp.NewContext(false, nil)
|
ctxDeliverTx := app.BaseApp.NewContext(false, nil)
|
||||||
|
|
||||||
err = app.BaseApp.InitStater(ctxCheckTx, ctxDeliverTx, genesisiDoc.AppState)
|
err = app.BaseApp.InitStater(ctxCheckTx, ctxDeliverTx, genesisiDoc.AppState)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(fmt.Errorf("error loading application genesis state: %v", err))
|
panic(fmt.Errorf("error loading application genesis state: %v", err))
|
||||||
|
|
|
@ -57,11 +57,12 @@ func TestSendMsg(t *testing.T) {
|
||||||
PubKey: pk,
|
PubKey: pk,
|
||||||
Sequence: 0,
|
Sequence: 0,
|
||||||
}
|
}
|
||||||
accs := []*GenesisAccount{
|
acc := types.AppAccount{baseAcc, "foobart"}
|
||||||
NewGenesisAccount(types.AppAccount{baseAcc, "foobart"}),
|
|
||||||
NewGenesisAccount(types.AppAccount{baseAcc, "endofzeworld"}),
|
gaccs := []*GenesisAccount{
|
||||||
|
NewGenesisAccount(acc),
|
||||||
}
|
}
|
||||||
bytes, err := json.MarshalIndent(&accs, "", "\t")
|
bytes, err := json.MarshalIndent(&gaccs, "", "\t")
|
||||||
|
|
||||||
app := tba.BasecoinApp
|
app := tba.BasecoinApp
|
||||||
ctxCheckTx := app.BaseApp.NewContext(true, nil)
|
ctxCheckTx := app.BaseApp.NewContext(true, nil)
|
||||||
|
@ -69,4 +70,6 @@ func TestSendMsg(t *testing.T) {
|
||||||
err = app.BaseApp.InitStater(ctxCheckTx, ctxDeliverTx, bytes)
|
err = app.BaseApp.InitStater(ctxCheckTx, ctxDeliverTx, bytes)
|
||||||
require.Nil(t, err)
|
require.Nil(t, err)
|
||||||
|
|
||||||
|
res1 := app.accountMapper.GetAccount(ctxDeliverTx, baseAcc.Address)
|
||||||
|
assert.Equal(t, baseAcc, res1)
|
||||||
}
|
}
|
||||||
|
|
|
@ -93,10 +93,8 @@ func (app *BasecoinApp) initBaseAppInitStater() {
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return sdk.ErrGenesisParse("").TraceCause(err, "")
|
return sdk.ErrGenesisParse("").TraceCause(err, "")
|
||||||
}
|
}
|
||||||
|
accountMapper.SetAccount(ctxCheckTx, acc.BaseAccount)
|
||||||
//panic(fmt.Sprintf("debug acc: %s\n", acc))
|
accountMapper.SetAccount(ctxDeliverTx, acc.BaseAccount)
|
||||||
accountMapper.SetAccount(ctxCheckTx, &acc.BaseAccount)
|
|
||||||
accountMapper.SetAccount(ctxDeliverTx, &acc.BaseAccount)
|
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue