...
This commit is contained in:
committed by
Ethan Buchman
parent
5cc0acf274
commit
8858371c43
@@ -6,6 +6,7 @@ import (
|
||||
dbm "github.com/tendermint/tmlibs/db"
|
||||
)
|
||||
|
||||
// TODO explain what the keybase is used for
|
||||
// GetKeyBase initializes a keybase based on the configuration
|
||||
func GetKeyBase(db dbm.DB) keys.Keybase {
|
||||
keybase := keys.New(
|
||||
|
||||
+11
-8
@@ -117,12 +117,17 @@ func TestVersion(t *testing.T) {
|
||||
}
|
||||
|
||||
func TestNodeStatus(t *testing.T) {
|
||||
_, _ = startServer(t)
|
||||
// TODO need to kill server after
|
||||
prepareClient(t)
|
||||
//ch := server.StartServer(t)
|
||||
//defer close(ch)
|
||||
//prepareClient(t)
|
||||
|
||||
cdc := app.MakeCodec()
|
||||
r := initRouter(cdc)
|
||||
//cdc := app.MakeCodec() // TODO refactor so that cdc is included from a common test init function
|
||||
//r := initRouter(cdc)
|
||||
|
||||
err := tests.InitServer()
|
||||
require.Nil(t, err)
|
||||
err := tests.StartServer()
|
||||
require.Nil(t, err)
|
||||
|
||||
// node info
|
||||
res := request(t, r, "GET", "/node_info", nil)
|
||||
@@ -291,9 +296,6 @@ func prepareClient(t *testing.T) {
|
||||
db := dbm.NewMemDB()
|
||||
app := baseapp.NewBaseApp(t.Name(), defaultLogger(), db)
|
||||
viper.Set(client.FlagNode, "localhost:46657")
|
||||
|
||||
_ = client.GetKeyBase(db)
|
||||
|
||||
header := abci.Header{Height: 1}
|
||||
app.BeginBlock(abci.RequestBeginBlock{Header: header})
|
||||
app.Commit()
|
||||
@@ -372,6 +374,7 @@ func runOrTimeout(cmd *cobra.Command, timeout time.Duration) error {
|
||||
}
|
||||
|
||||
func request(t *testing.T, r http.Handler, method string, path string, payload []byte) *httptest.ResponseRecorder {
|
||||
|
||||
req, err := http.NewRequest(method, path, bytes.NewBuffer(payload))
|
||||
require.Nil(t, err)
|
||||
res := httptest.NewRecorder()
|
||||
|
||||
+2
-1
@@ -51,10 +51,11 @@ func initRouter(cdc *wire.Codec) http.Handler {
|
||||
r := mux.NewRouter()
|
||||
r.HandleFunc("/version", version.VersionRequestHandler).Methods("GET")
|
||||
|
||||
// TODO make more functional? aka r = keys.RegisterRoutes(r)
|
||||
keys.RegisterRoutes(r)
|
||||
rpc.RegisterRoutes(r)
|
||||
tx.RegisterRoutes(r, cdc)
|
||||
auth.RegisterRoutes(r, cdc, "main")
|
||||
auth.RegisterRoutes(r, cdc, "main") // TODO should use a variable not just a string
|
||||
bank.RegisterRoutes(r, cdc)
|
||||
return r
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user