cosmos-sdk/server/mock/helpers.go
Christopher Goes 59aadf42aa
Ledger integration (#931)
Merges the keybase and Ledger code from go-crypto (which is no more) into the SDK
Adds support for Ledger into gaiacli
Cherry-picks updated error handling from #1158
2018-06-29 02:54:47 +02:00

32 lines
707 B
Go

package mock
import (
"fmt"
"io/ioutil"
"os"
abci "github.com/tendermint/tendermint/abci/types"
"github.com/tendermint/tmlibs/log"
)
// SetupApp returns an application as well as a clean-up function
// to be used to quickly setup a test case with an app
func SetupApp() (abci.Application, func(), error) {
logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)).
With("module", "mock")
rootDir, err := ioutil.TempDir("", "mock-sdk")
if err != nil {
return nil, nil, err
}
cleanup := func() {
err := os.RemoveAll(rootDir)
if err != nil {
fmt.Printf("could not delete %s, had error %s\n", rootDir, err.Error())
}
}
app, err := NewApp(rootDir, logger)
return app, cleanup, err
}