* A few godoc updates * More minor tweaks and reformatting * Implement initial minting querier * Implement stringer interface for minting params * Minor cleanup * Add minting CLI commands * Implement inflation query command * Implement annual provisions query and CLI command * Update x/mint/client/module_client.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update x/mint/client/module_client.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update x/mint/client/module_client.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Update x/mint/querier.go Co-Authored-By: alexanderbez <alexanderbez@users.noreply.github.com> * Add minting REST client routes/handlers * Fix build issues * Implement querier unit tests * Update gaiacli docs * Implement LCD tests * Update Swagger docs * Add pending log entry * add examples Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com> * revert adding examples Signed-off-by: Karoly Albert Szabo <szabo.karoly.a@gmail.com>
75 lines
1.7 KiB
Go
75 lines
1.7 KiB
Go
package mint
|
|
|
|
import (
|
|
"testing"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/stretchr/testify/require"
|
|
|
|
abci "github.com/tendermint/tendermint/abci/types"
|
|
)
|
|
|
|
func TestNewQuerier(t *testing.T) {
|
|
input := newTestInput(t)
|
|
querier := NewQuerier(input.mintKeeper)
|
|
|
|
query := abci.RequestQuery{
|
|
Path: "",
|
|
Data: []byte{},
|
|
}
|
|
|
|
_, err := querier(input.ctx, []string{QueryParameters}, query)
|
|
require.NoError(t, err)
|
|
|
|
_, err = querier(input.ctx, []string{QueryInflation}, query)
|
|
require.NoError(t, err)
|
|
|
|
_, err = querier(input.ctx, []string{QueryAnnualProvisions}, query)
|
|
require.NoError(t, err)
|
|
|
|
_, err = querier(input.ctx, []string{"foo"}, query)
|
|
require.Error(t, err)
|
|
}
|
|
|
|
func TestQueryParams(t *testing.T) {
|
|
input := newTestInput(t)
|
|
|
|
var params Params
|
|
|
|
res, sdkErr := queryParams(input.ctx, input.mintKeeper)
|
|
require.NoError(t, sdkErr)
|
|
|
|
err := input.cdc.UnmarshalJSON(res, ¶ms)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, input.mintKeeper.GetParams(input.ctx), params)
|
|
}
|
|
|
|
func TestQueryInflation(t *testing.T) {
|
|
input := newTestInput(t)
|
|
|
|
var inflation sdk.Dec
|
|
|
|
res, sdkErr := queryInflation(input.ctx, input.mintKeeper)
|
|
require.NoError(t, sdkErr)
|
|
|
|
err := input.cdc.UnmarshalJSON(res, &inflation)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, input.mintKeeper.GetMinter(input.ctx).Inflation, inflation)
|
|
}
|
|
|
|
func TestQueryAnnualProvisions(t *testing.T) {
|
|
input := newTestInput(t)
|
|
|
|
var annualProvisions sdk.Dec
|
|
|
|
res, sdkErr := queryAnnualProvisions(input.ctx, input.mintKeeper)
|
|
require.NoError(t, sdkErr)
|
|
|
|
err := input.cdc.UnmarshalJSON(res, &annualProvisions)
|
|
require.NoError(t, err)
|
|
|
|
require.Equal(t, input.mintKeeper.GetMinter(input.ctx).AnnualProvisions, annualProvisions)
|
|
}
|