-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Test: add IsAllowedSender test * Test: test for validateAllowList * Tidy: readability of params_test.go * Refactor: change WhiteList to AllowList * Refactor: correct and tidy code * tidy: remove unnecessary file * tidy: run goimports * Tidy: call goimports on all x/airdrop * Tidy: remove junk code from genesis.go
- Loading branch information
Showing
18 changed files
with
102 additions
and
36 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,55 @@ | ||
package types_test | ||
|
||
import ( | ||
"testing" | ||
|
||
"github.com/cosmos/cosmos-sdk/simapp" | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/cosmos/cosmos-sdk/x/airdrop/types" | ||
"github.com/stretchr/testify/suite" | ||
tmproto "github.com/tendermint/tendermint/proto/tendermint/types" | ||
"github.com/tendermint/tendermint/types/time" | ||
) | ||
|
||
var ( | ||
allowedAddress = sdk.AccAddress([]byte("allowed_____________")) | ||
blockedAddress1 = sdk.AccAddress([]byte("blocked_____________")) | ||
blockedAddress2 = sdk.AccAddress([]byte("")) | ||
) | ||
|
||
type ParamsTestSuite struct { | ||
suite.Suite | ||
app *simapp.SimApp | ||
ctx sdk.Context | ||
} | ||
|
||
func (s *ParamsTestSuite) SetupTest() { | ||
app := simapp.Setup(false) | ||
s.app = app | ||
s.ctx = app.BaseApp.NewContext(false, tmproto.Header{ | ||
Time: time.Now(), | ||
Height: 10, | ||
}) | ||
} | ||
|
||
func (s *ParamsTestSuite) TestIsAllowedSender() { | ||
correct := types.NewParams(allowedAddress.String()) // New set of parameters with a new AllowList | ||
s.Require().True(correct.IsAllowedSender(allowedAddress)) // Address is in AllowList and has correct format | ||
s.Require().False(correct.IsAllowedSender(blockedAddress1)) // Address is not in AllowList and has correct format | ||
s.Require().False(correct.IsAllowedSender(blockedAddress2)) // Address is not in AllowList and has incorrect format | ||
} | ||
|
||
func (s *ParamsTestSuite) TestValidateAllowList() { | ||
correct := types.NewParams(allowedAddress.String()) // Allow list contains address with correct format | ||
incorrect := types.NewParams(allowedAddress.String(), blockedAddress2.String()) // Allow list contains address with incorrect format | ||
for _, paramPairs := range correct.ParamSetPairs() { | ||
s.Require().NoError(paramPairs.ValidatorFn(correct.AllowList)) | ||
} | ||
for _, paramPairs := range incorrect.ParamSetPairs() { | ||
s.Require().Error(paramPairs.ValidatorFn(incorrect.AllowList)) | ||
} | ||
} | ||
|
||
func TestParamsTestSuite(t *testing.T) { | ||
suite.Run(t, new(ParamsTestSuite)) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.