-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: poa fixes, tweaks, and chores (#237)
* H-01: deny duplicate submission for a pending validator * M-01(refactor): simplify removing validators by grabbing directly * test: pending and duplicate removal * L-01: Params.Validate staking * L-02: panic if floor > ciel * L-03: fix validators if commission is below updated commission rate * L-04: duplicate validator verification on InitGenesis * chore: lint * fix: simulation (no duplicate create validators) * fix lint * lint remove fmt prints * refactor/lint: remove typecast from int64 -> uint64
- Loading branch information
1 parent
6922e22
commit 9e804c6
Showing
13 changed files
with
206 additions
and
39 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package keeper_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/stretchr/testify/require" | ||
|
||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
|
||
"github.com/strangelove-ventures/poa" | ||
) | ||
|
||
func TestAddPending(t *testing.T) { | ||
f := SetupTest(t, 2_000_000) | ||
require := require.New(t) | ||
|
||
val := GenAcc() | ||
valAddr := sdk.ValAddress(val.addr) | ||
v := poa.ConvertPOAToStaking(CreateNewValidator( | ||
"myval", | ||
valAddr.String(), | ||
val.valKey.PubKey(), | ||
1_000_000, | ||
)) | ||
|
||
// successful add | ||
err := f.k.AddPendingValidator(f.ctx, v, val.valKey.PubKey()) | ||
require.NoError(err) | ||
|
||
// duplicate (fails) | ||
err = f.k.AddPendingValidator(f.ctx, v, val.valKey.PubKey()) | ||
require.Error(err) | ||
require.Equal(poa.ErrValidatorAlreadyPending, err) | ||
|
||
// remove pending | ||
err = f.k.RemovePendingValidator(f.ctx, v.OperatorAddress) | ||
require.NoError(err) | ||
|
||
pending, err := f.k.GetPendingValidators(f.ctx) | ||
require.NoError(err) | ||
require.Empty(pending.Validators) | ||
} |
Oops, something went wrong.