keeper_test
This commit is contained in:
parent
3b5e57be08
commit
900a5f47f6
|
@ -19,7 +19,10 @@ func (k Keeper) AllocateFees(ctx sdk.Context) {
|
|||
|
||||
// get the proposer of this block
|
||||
proposerConsAddr := k.GetProposerConsAddr(ctx)
|
||||
fmt.Printf("debug proposerConsAddr: %v\n", proposerConsAddr.String())
|
||||
proposerValidator := k.stakeKeeper.ValidatorByConsAddr(ctx, proposerConsAddr)
|
||||
fmt.Printf("debug in allocate proposerValidator: %v\n", proposerValidator.GetOperator())
|
||||
|
||||
proposerDist := k.GetValidatorDistInfo(ctx, proposerValidator.GetOperator())
|
||||
|
||||
// get the fees which have been getting collected through all the
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
|
@ -39,7 +40,7 @@ func TestAllocateFeesBasic(t *testing.T) {
|
|||
feeInputs := sdk.NewInt(100)
|
||||
fck.SetCollectedFees(sdk.Coins{sdk.NewCoin(denom, feeInputs)})
|
||||
require.Equal(t, feeInputs, fck.GetCollectedFees(ctx).AmountOf(denom))
|
||||
ctx = ctx.WithProposer(valConsAddr1)
|
||||
fmt.Printf("debug valConsAddr1: %v\n", valConsAddr1.String())
|
||||
keeper.SetProposerConsAddr(ctx, valConsAddr1)
|
||||
keeper.SetSumPrecommitPower(ctx, sdk.NewDec(10))
|
||||
keeper.AllocateFees(ctx)
|
||||
|
|
|
@ -10,6 +10,8 @@ import (
|
|||
// Create a new validator distribution record
|
||||
func (k Keeper) onValidatorCreated(ctx sdk.Context, addr sdk.ValAddress) {
|
||||
|
||||
fmt.Printf("debug asdgojasklnaslkjv addr: %v\n", addr)
|
||||
|
||||
height := ctx.BlockHeight()
|
||||
vdi := types.ValidatorDistInfo{
|
||||
OperatorAddr: addr,
|
||||
|
|
|
@ -0,0 +1,46 @@
|
|||
package keeper
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
"github.com/cosmos/cosmos-sdk/x/distribution/types"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
func TestSetGetProposerConsAddr(t *testing.T) {
|
||||
ctx, _, keeper, _, _ := CreateTestInputDefault(t, false, 0)
|
||||
|
||||
keeper.SetProposerConsAddr(ctx, valConsAddr1)
|
||||
res := keeper.GetProposerConsAddr(ctx)
|
||||
require.True(t, res.Equals(valConsAddr1), "expected: %v got: %v", valConsAddr1.String(), res.String())
|
||||
}
|
||||
|
||||
func TestSetGetSumPrecommitPower(t *testing.T) {
|
||||
ctx, _, keeper, _, _ := CreateTestInputDefault(t, false, 0)
|
||||
|
||||
someDec := sdk.NewDec(333)
|
||||
keeper.SetSumPrecommitPower(ctx, someDec)
|
||||
res := keeper.GetSumPrecommitPower(ctx)
|
||||
require.True(sdk.DecEq(t, someDec, res))
|
||||
}
|
||||
|
||||
func TestSetGetCommunityTax(t *testing.T) {
|
||||
ctx, _, keeper, _, _ := CreateTestInputDefault(t, false, 0)
|
||||
|
||||
someDec := sdk.NewDec(333)
|
||||
keeper.SetCommunityTax(ctx, someDec)
|
||||
res := keeper.GetCommunityTax(ctx)
|
||||
require.True(sdk.DecEq(t, someDec, res))
|
||||
}
|
||||
|
||||
func TestSetGetFeePool(t *testing.T) {
|
||||
ctx, _, keeper, _, _ := CreateTestInputDefault(t, false, 0)
|
||||
|
||||
fp := types.InitialFeePool()
|
||||
fp.ValAccum.UpdateHeight = 777
|
||||
|
||||
keeper.SetFeePool(ctx, fp)
|
||||
res := keeper.GetFeePool(ctx)
|
||||
require.Equal(t, fp.ValAccum, res.ValAccum)
|
||||
}
|
Loading…
Reference in New Issue