2019-02-05 19:11:57 -08:00
|
|
|
package baseapp
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/stretchr/testify/require"
|
|
|
|
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
|
|
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
|
|
)
|
|
|
|
|
2019-12-27 09:57:54 -08:00
|
|
|
var testQuerier = func(_ sdk.Context, _ []string, _ abci.RequestQuery) ([]byte, error) {
|
2019-02-05 19:11:57 -08:00
|
|
|
return nil, nil
|
|
|
|
}
|
|
|
|
|
|
|
|
func TestQueryRouter(t *testing.T) {
|
|
|
|
qr := NewQueryRouter()
|
|
|
|
|
|
|
|
// require panic on invalid route
|
|
|
|
require.Panics(t, func() {
|
|
|
|
qr.AddRoute("*", testQuerier)
|
|
|
|
})
|
|
|
|
|
|
|
|
qr.AddRoute("testRoute", testQuerier)
|
|
|
|
q := qr.Route("testRoute")
|
|
|
|
require.NotNil(t, q)
|
|
|
|
|
|
|
|
// require panic on duplicate route
|
|
|
|
require.Panics(t, func() {
|
|
|
|
qr.AddRoute("testRoute", testQuerier)
|
|
|
|
})
|
|
|
|
}
|