refactor: Improve x/bank deterministic tests (#13450)
* refactor: Improve x/bank deterministic tests * typo * Less changes * Rename var * Fix SpendableBalances * Fix pagination tests * Fix TestGRPCQueryTotalSupply * Remove explicit SetupTest() * Fix TestGRPCSendEnabled Co-authored-by: Aleksandr Bezobchuk <alexanderbez@users.noreply.github.com>
This commit is contained in:
co-authored by
Aleksandr Bezobchuk
parent
bb54c597de
commit
ff39d243d4
Vendored
+14
@@ -11,6 +11,7 @@ import (
|
||||
cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types"
|
||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||
sdkerrors "github.com/cosmos/cosmos-sdk/types/errors"
|
||||
"github.com/cosmos/cosmos-sdk/types/query"
|
||||
)
|
||||
|
||||
// AddressGenerator creates and returns a random address generator using rapid.
|
||||
@@ -21,6 +22,19 @@ func AddressGenerator(t *rapid.T) *rapid.Generator[sdk.AccAddress] {
|
||||
})
|
||||
}
|
||||
|
||||
// PaginationGenerator creates and returns a pagination PageRequest generator
|
||||
// using rapid.
|
||||
func PaginationGenerator(t *rapid.T, maxLimit uint64) *rapid.Generator[*query.PageRequest] {
|
||||
return rapid.Custom(func(t *rapid.T) *query.PageRequest {
|
||||
return &query.PageRequest{
|
||||
Offset: rapid.Uint64Range(0, maxLimit).Draw(t, "offset"),
|
||||
Limit: rapid.Uint64Range(0, maxLimit).Draw(t, "limit"),
|
||||
CountTotal: rapid.Bool().Draw(t, "count-total"),
|
||||
Reverse: rapid.Bool().Draw(t, "reverse"),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// KeyTestPubAddr generates a new secp256k1 keypair.
|
||||
func KeyTestPubAddr() (cryptotypes.PrivKey, cryptotypes.PubKey, sdk.AccAddress) {
|
||||
key := secp256k1.GenPrivKey()
|
||||
|
||||
Reference in New Issue
Block a user