mirror of
https://github.com/tendermint/tendermint.git
synced 2026-02-08 04:50:16 +00:00
* ci: Fix linter complaint (#9645)
Fixes a very silly linter complaint that makes absolutely no sense and is blocking the merging of several PRs.
---
#### PR checklist
- [x] Tests written/updated, or no tests needed
- [x] `CHANGELOG_PENDING.md` updated, or no changelog entry needed
- [x] Updated relevant documentation (`docs/`) and code comments, or no
documentation updates needed
(cherry picked from commit 83b7f4ad5b)
# Conflicts:
# .github/workflows/lint.yml
# .golangci.yml
# cmd/tendermint/commands/debug/util.go
* Resolve conflicts
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* ci: Sync golangci-lint config with main
Minus the spelling configuration that restricts spelling to US English
only.
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* make format
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* Remove usage of deprecated io/ioutil package
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* Remove unused mockBlockStore
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* blockchain/v2: Remove unused method
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* Bulk fix lints
Signed-off-by: Thane Thomson <connect@thanethomson.com>
* lint: Ignore auto-generated query PEG
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Signed-off-by: Thane Thomson <connect@thanethomson.com>
Co-authored-by: Thane Thomson <connect@thanethomson.com>
36 lines
784 B
Go
36 lines
784 B
Go
package addr
|
|
|
|
import (
|
|
"encoding/json"
|
|
"fmt"
|
|
"math/rand"
|
|
|
|
"github.com/tendermint/tendermint/p2p"
|
|
"github.com/tendermint/tendermint/p2p/pex"
|
|
)
|
|
|
|
var addrBook = pex.NewAddrBook("./testdata/addrbook.json", true)
|
|
|
|
func Fuzz(data []byte) int {
|
|
addr := new(p2p.NetAddress)
|
|
if err := json.Unmarshal(data, addr); err != nil {
|
|
return -1
|
|
}
|
|
|
|
// Fuzz AddAddress.
|
|
err := addrBook.AddAddress(addr, addr)
|
|
if err != nil {
|
|
return 0
|
|
}
|
|
|
|
// Also, make sure PickAddress always returns a non-nil address.
|
|
//nolint:gosec // G404: Use of weak random number generator (math/rand instead of crypto/rand)
|
|
bias := rand.Intn(100)
|
|
if p := addrBook.PickAddress(bias); p == nil {
|
|
panic(fmt.Sprintf("picked a nil address (bias: %d, addrBook size: %v)",
|
|
bias, addrBook.Size()))
|
|
}
|
|
|
|
return 1
|
|
}
|