cosmos-sdk/x/supply/internal/keeper/keeper_test.go

39 lines
986 B
Go
Raw Normal View History

package keeper_test
2019-06-28 13:11:27 -07:00
import (
"testing"
"github.com/stretchr/testify/require"
sdk "github.com/cosmos/cosmos-sdk/types"
"github.com/cosmos/cosmos-sdk/x/supply/internal/types"
2019-06-28 13:11:27 -07:00
)
func TestSupply(t *testing.T) {
initialPower := int64(100)
initTokens := sdk.TokensFromConsensusPower(initialPower)
app, ctx := createTestApp(false)
totalSupply := sdk.NewCoins(sdk.NewCoin(sdk.DefaultBondDenom, initTokens))
app.SupplyKeeper.SetSupply(ctx, types.NewSupply(totalSupply))
2019-06-28 13:11:27 -07:00
total := app.SupplyKeeper.GetSupply(ctx).GetTotal()
2019-06-28 13:11:27 -07:00
require.Equal(t, totalSupply, total)
2019-06-28 13:11:27 -07:00
}
func TestValidatePermissions(t *testing.T) {
app, _ := createTestApp(false)
err := app.SupplyKeeper.ValidatePermissions(multiPermAcc)
require.NoError(t, err)
err = app.SupplyKeeper.ValidatePermissions(randomPermAcc)
require.NoError(t, err)
// unregistered permissions
otherAcc := types.NewEmptyModuleAccount("other", "other")
err = app.SupplyKeeper.ValidatePermissions(otherAcc)
require.Error(t, err)
}