* Update Tendermint to v0.32.0-dev0 * Initial refactor of tags * Update event types and add unit tests * Refactor context * Update module manager * Update result godoc * Implement ToABCIEvents * Update BaseApp * Minor cleanup * Fix typo * Update x/bank message handler * Update x/bank keeper * Update x/bank * Update x/bank events docs * Update x/crisis module events * Reset context with events on each message exec * Update x/distribution events and docs * Update BaseApp to not set empty events manually * Implement simple event manager * Update module manager * Update modules to use event manager * Update x/gov module to use events * Update events docs * Update gov queries and crisis app module * Update bank keeper * Add events to minting begin blocker * Update modules to use types/events.go * Cleanup x/mint * Update x/staking events * Update x/staking events * Update events to have sender part of message.sender * Fix build * Fix module unit tests * Add pending log entry * Update deps * Update x/crisis/types/events.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/bank/internal/types/events.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/distribution/types/events.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/mint/internal/types/events.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/slashing/types/events.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/staking/types/events.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/gov/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/gov/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/mint/abci.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/mint/abci.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/slashing/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/staking/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/slashing/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/staking/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/staking/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Update x/staking/handler.go Co-Authored-By: Federico Kunze <31522760+fedekunze@users.noreply.github.com> * Upgrade TM to v0.32.0-dev1 * Update events as strings * Update Tendermint to v0.32.0-dev2 * Fix BaseApp unit tests * Fix unit tests * Bump tendermint version to v0.32.0 * typos
80 lines
1.9 KiB
Go
80 lines
1.9 KiB
Go
package mock
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/tendermint/tendermint/types"
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
)
|
|
|
|
// TestInitApp makes sure we can initialize this thing without an error
|
|
func TestInitApp(t *testing.T) {
|
|
// set up an app
|
|
app, closer, err := SetupApp()
|
|
|
|
// closer may need to be run, even when error in later stage
|
|
if closer != nil {
|
|
defer closer()
|
|
}
|
|
require.NoError(t, err)
|
|
|
|
// initialize it future-way
|
|
appState, err := AppGenState(nil, types.GenesisDoc{}, nil)
|
|
require.NoError(t, err)
|
|
|
|
//TODO test validators in the init chain?
|
|
req := abci.RequestInitChain{
|
|
AppStateBytes: appState,
|
|
}
|
|
app.InitChain(req)
|
|
app.Commit()
|
|
|
|
// make sure we can query these values
|
|
query := abci.RequestQuery{
|
|
Path: "/store/main/key",
|
|
Data: []byte("foo"),
|
|
}
|
|
qres := app.Query(query)
|
|
require.Equal(t, uint32(0), qres.Code, qres.Log)
|
|
require.Equal(t, []byte("bar"), qres.Value)
|
|
}
|
|
|
|
// TextDeliverTx ensures we can write a tx
|
|
func TestDeliverTx(t *testing.T) {
|
|
// set up an app
|
|
app, closer, err := SetupApp()
|
|
// closer may need to be run, even when error in later stage
|
|
if closer != nil {
|
|
defer closer()
|
|
}
|
|
require.NoError(t, err)
|
|
|
|
key := "my-special-key"
|
|
value := "top-secret-data!!"
|
|
tx := NewTx(key, value)
|
|
txBytes := tx.GetSignBytes()
|
|
|
|
header := abci.Header{
|
|
AppHash: []byte("apphash"),
|
|
Height: 1,
|
|
}
|
|
app.BeginBlock(abci.RequestBeginBlock{Header: header})
|
|
dres := app.DeliverTx(abci.RequestDeliverTx{Tx: txBytes})
|
|
require.Equal(t, uint32(0), dres.Code, dres.Log)
|
|
app.EndBlock(abci.RequestEndBlock{})
|
|
cres := app.Commit()
|
|
require.NotEmpty(t, cres.Data)
|
|
|
|
// make sure we can query these values
|
|
query := abci.RequestQuery{
|
|
Path: "/store/main/key",
|
|
Data: []byte(key),
|
|
}
|
|
qres := app.Query(query)
|
|
require.Equal(t, uint32(0), qres.Code, qres.Log)
|
|
require.Equal(t, []byte(value), qres.Value)
|
|
}
|