style: enable strict gofumpt (#15579)
This commit is contained in:
@@ -88,6 +88,6 @@ func Module(moduleName string, derivationKeys ...[]byte) []byte {
|
||||
// Derive derives a new address from the main `address` and a derivation `key`.
|
||||
// This function is used to create a sub accounts. To create a module accounts use the
|
||||
// `Module` function.
|
||||
func Derive(address []byte, key []byte) []byte {
|
||||
func Derive(address, key []byte) []byte {
|
||||
return Hash(conv.UnsafeBytesToStr(address), key)
|
||||
}
|
||||
|
||||
@@ -44,7 +44,7 @@ var invalidStrs = []string{
|
||||
types.Bech32PrefixConsPub + "6789",
|
||||
}
|
||||
|
||||
func (s *addressTestSuite) testMarshal(original interface{}, res interface{}, marshal func() ([]byte, error), unmarshal func([]byte) error) {
|
||||
func (s *addressTestSuite) testMarshal(original, res interface{}, marshal func() ([]byte, error), unmarshal func([]byte) error) {
|
||||
bz, err := marshal()
|
||||
s.Require().Nil(err)
|
||||
s.Require().Nil(unmarshal(bz))
|
||||
|
||||
@@ -11,7 +11,7 @@ func coinName(suffix int) string {
|
||||
|
||||
func BenchmarkCoinsAdditionIntersect(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
|
||||
benchmarkingFunc := func(numCoinsA, numCoinsB int) func(b *testing.B) {
|
||||
return func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
coinsA := Coins(make([]Coin, numCoinsA))
|
||||
@@ -42,7 +42,7 @@ func BenchmarkCoinsAdditionIntersect(b *testing.B) {
|
||||
|
||||
func BenchmarkCoinsAdditionNoIntersect(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
benchmarkingFunc := func(numCoinsA int, numCoinsB int) func(b *testing.B) {
|
||||
benchmarkingFunc := func(numCoinsA, numCoinsB int) func(b *testing.B) {
|
||||
return func(b *testing.B) {
|
||||
b.ReportAllocs()
|
||||
coinsA := Coins(make([]Coin, numCoinsA))
|
||||
|
||||
@@ -36,7 +36,7 @@ func (t testPubKey) Address() cryptotypes.Address { return t.address.Bytes() }
|
||||
|
||||
func (t testPubKey) Bytes() []byte { panic("not implemented") }
|
||||
|
||||
func (t testPubKey) VerifySignature(msg []byte, sig []byte) bool { panic("not implemented") }
|
||||
func (t testPubKey) VerifySignature(msg, sig []byte) bool { panic("not implemented") }
|
||||
|
||||
func (t testPubKey) Equals(key cryptotypes.PubKey) bool { panic("not implemented") }
|
||||
|
||||
|
||||
@@ -464,7 +464,7 @@ func (s *MempoolTestSuite) TestRandomWalkTxs() {
|
||||
seed, s.iterations, duration.Milliseconds())
|
||||
}
|
||||
|
||||
func genRandomTxs(seed int64, countTx int, countAccount int) (res []testTx) {
|
||||
func genRandomTxs(seed int64, countTx, countAccount int) (res []testTx) {
|
||||
maxPriority := 100
|
||||
r := rand.New(rand.NewSource(seed))
|
||||
accounts := simtypes.RandomAccounts(r, countAccount)
|
||||
@@ -491,7 +491,7 @@ func genRandomTxs(seed int64, countTx int, countAccount int) (res []testTx) {
|
||||
|
||||
// since there are multiple valid ordered graph traversals for a given set of txs strict
|
||||
// validation against the ordered txs generated from this function is not possible as written
|
||||
func genOrderedTxs(seed int64, maxTx int, numAcc int) (ordered []testTx, shuffled []testTx) {
|
||||
func genOrderedTxs(seed int64, maxTx, numAcc int) (ordered, shuffled []testTx) {
|
||||
r := rand.New(rand.NewSource(seed))
|
||||
accountNonces := make(map[string]uint64)
|
||||
prange := 10
|
||||
|
||||
@@ -85,7 +85,7 @@ func (c *configurator) Error() error {
|
||||
}
|
||||
|
||||
// NewConfigurator returns a new Configurator instance
|
||||
func NewConfigurator(cdc codec.Codec, msgServer grpc.Server, queryServer grpc.Server) Configurator {
|
||||
func NewConfigurator(cdc codec.Codec, msgServer, queryServer grpc.Server) Configurator {
|
||||
return &configurator{
|
||||
cdc: cdc,
|
||||
msgServer: msgServer,
|
||||
|
||||
@@ -258,7 +258,7 @@ func encodeCollKey[K, V any, C Collection[K, V]](coll C, key K) ([]byte, error)
|
||||
return buffer, err
|
||||
}
|
||||
|
||||
func getCollIter[K, V any, C Collection[K, V]](ctx context.Context, coll C, prefix []byte, start []byte, reverse bool) (collections.Iterator[K, V], error) {
|
||||
func getCollIter[K, V any, C Collection[K, V]](ctx context.Context, coll C, prefix, start []byte, reverse bool) (collections.Iterator[K, V], error) {
|
||||
var end []byte
|
||||
if prefix != nil {
|
||||
start = append(prefix, start...)
|
||||
|
||||
@@ -48,7 +48,7 @@ func TestCollectionPagination(t *testing.T) {
|
||||
type test struct {
|
||||
req *PageRequest
|
||||
expResp *PageResponse
|
||||
filter func(key uint64, value uint64) bool
|
||||
filter func(key, value uint64) bool
|
||||
expResults []collections.KeyValue[uint64, uint64]
|
||||
wantErr error
|
||||
}
|
||||
@@ -101,7 +101,7 @@ func TestCollectionPagination(t *testing.T) {
|
||||
expResp: &PageResponse{
|
||||
NextKey: encodeKey(5),
|
||||
},
|
||||
filter: func(key uint64, value uint64) bool {
|
||||
filter: func(key, value uint64) bool {
|
||||
return key%2 == 0
|
||||
},
|
||||
expResults: []collections.KeyValue[uint64, uint64]{
|
||||
@@ -118,7 +118,7 @@ func TestCollectionPagination(t *testing.T) {
|
||||
expResp: &PageResponse{
|
||||
NextKey: encodeKey(7),
|
||||
},
|
||||
filter: func(key uint64, value uint64) bool {
|
||||
filter: func(key, value uint64) bool {
|
||||
return key%2 == 0
|
||||
},
|
||||
expResults: []collections.KeyValue[uint64, uint64]{
|
||||
|
||||
@@ -20,7 +20,7 @@ import (
|
||||
func FilteredPaginate(
|
||||
prefixStore types.KVStore,
|
||||
pageRequest *PageRequest,
|
||||
onResult func(key []byte, value []byte, accumulate bool) (bool, error),
|
||||
onResult func(key, value []byte, accumulate bool) (bool, error),
|
||||
) (*PageResponse, error) {
|
||||
// if the PageRequest is nil, use default PageRequest
|
||||
if pageRequest == nil {
|
||||
|
||||
@@ -195,7 +195,7 @@ func (s *paginationTestSuite) TestFilteredPaginate() {
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
|
||||
var balResult sdk.Coins
|
||||
pageRes, err := query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
pageRes, err := query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
@@ -226,7 +226,7 @@ func execFilterPaginate(store storetypes.KVStore, pageReq *query.PageRequest, ap
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
|
||||
var balResult sdk.Coins
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
@@ -268,7 +268,7 @@ func (s *paginationTestSuite) TestFilteredPaginationsNextKey() {
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
|
||||
var balResult sdk.Coins
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key []byte, value []byte, accumulate bool) (bool, error) {
|
||||
res, err = query.FilteredPaginate(accountStore, pageReq, func(key, value []byte, accumulate bool) (bool, error) {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
|
||||
@@ -85,7 +85,7 @@ func FuzzPagination(f *testing.F) {
|
||||
authStore := suite.ctx.KVStore(suite.app.UnsafeFindStoreKey(types.StoreKey))
|
||||
balancesStore := prefix.NewStore(authStore, types.BalancesPrefix)
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
_, _ = query.Paginate(accountStore, req.Pagination, func(key []byte, value []byte) error {
|
||||
_, _ = query.Paginate(accountStore, req.Pagination, func(key, value []byte) error {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
|
||||
@@ -52,7 +52,7 @@ func ParsePagination(pageReq *PageRequest) (page, limit int, err error) {
|
||||
func Paginate(
|
||||
prefixStore types.KVStore,
|
||||
pageRequest *PageRequest,
|
||||
onResult func(key []byte, value []byte) error,
|
||||
onResult func(key, value []byte) error,
|
||||
) (*PageResponse, error) {
|
||||
// if the PageRequest is nil, use default PageRequest
|
||||
if pageRequest == nil {
|
||||
|
||||
@@ -354,7 +354,7 @@ func (s *paginationTestSuite) TestPaginate() {
|
||||
authStore := s.ctx.KVStore(s.app.UnsafeFindStoreKey(types.StoreKey))
|
||||
balancesStore := prefix.NewStore(authStore, types.BalancesPrefix)
|
||||
accountStore := prefix.NewStore(balancesStore, address.MustLengthPrefix(addr1))
|
||||
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key []byte, value []byte) error {
|
||||
pageRes, err := query.Paginate(accountStore, request.Pagination, func(key, value []byte) error {
|
||||
var amount math.Int
|
||||
err := amount.Unmarshal(value)
|
||||
if err != nil {
|
||||
|
||||
+1
-1
@@ -230,7 +230,7 @@ func WrapServiceResult(ctx Context, res proto.Message, err error) (*Result, erro
|
||||
}
|
||||
|
||||
// calculate total pages in an overflow safe manner
|
||||
func calcTotalPages(totalCount int64, limit int64) int64 {
|
||||
func calcTotalPages(totalCount, limit int64) int64 {
|
||||
totalPages := int64(0)
|
||||
if totalCount != 0 && limit != 0 {
|
||||
if totalCount%limit > 0 {
|
||||
|
||||
+1
-1
@@ -25,7 +25,7 @@ var (
|
||||
)
|
||||
|
||||
// TokensToConsensusPower - convert input tokens to potential consensus-engine power
|
||||
func TokensToConsensusPower(tokens sdkmath.Int, powerReduction sdkmath.Int) int64 {
|
||||
func TokensToConsensusPower(tokens, powerReduction sdkmath.Int) int64 {
|
||||
return (tokens.Quo(powerReduction)).Int64()
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -127,7 +127,7 @@ func AppendLengthPrefixedBytes(args ...[]byte) []byte {
|
||||
}
|
||||
|
||||
// ParseLengthPrefixedBytes panics when store key length is not equal to the given length.
|
||||
func ParseLengthPrefixedBytes(key []byte, startIndex int, sliceLength int) ([]byte, int) {
|
||||
func ParseLengthPrefixedBytes(key []byte, startIndex, sliceLength int) ([]byte, int) {
|
||||
neededLength := startIndex + sliceLength
|
||||
endIndex := neededLength - 1
|
||||
kv.AssertKeyAtLeastLength(key, neededLength)
|
||||
|
||||
Reference in New Issue
Block a user