mirror of
https://github.com/fluencelabs/tendermint
synced 2025-04-24 14:22:16 +00:00
linters: enable scopelint (#3963)
* Pin range scope vars * Don't disable scopelint This PR repairs linter errors seen when running the following commands: golangci-lint run --no-config --disable-all=true --enable=scopelint Contributes to #3262
This commit is contained in:
parent
961e1d360f
commit
d1d517a9b7
@ -13,7 +13,6 @@ linters:
|
||||
- lll
|
||||
- gochecknoglobals
|
||||
- gochecknoinits
|
||||
- scopelint
|
||||
- stylecheck
|
||||
# linters-settings:
|
||||
# govet:
|
||||
|
@ -258,6 +258,7 @@ func TestBcBlockRequestMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
request := bcBlockRequestMessage{Height: tc.requestHeight}
|
||||
assert.Equal(t, tc.expectErr, request.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
@ -277,6 +278,7 @@ func TestBcNoBlockResponseMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
nonResponse := bcNoBlockResponseMessage{Height: tc.nonResponseHeight}
|
||||
assert.Equal(t, tc.expectErr, nonResponse.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
@ -296,6 +298,7 @@ func TestBcStatusRequestMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
request := bcStatusRequestMessage{Height: tc.requestHeight}
|
||||
assert.Equal(t, tc.expectErr, request.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
@ -315,6 +318,7 @@ func TestBcStatusResponseMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
response := bcStatusResponseMessage{Height: tc.responseHeight}
|
||||
assert.Equal(t, tc.expectErr, response.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
|
@ -125,6 +125,7 @@ func TestPeerGetAndRemoveBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// try to get the block
|
||||
b, err := peer.BlockAtHeight(tt.height)
|
||||
@ -167,6 +168,7 @@ func TestPeerAddBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// try to get the block
|
||||
err := peer.AddBlock(makeSmallBlock(int(tt.height)), 10)
|
||||
|
@ -159,6 +159,7 @@ func TestBlockPoolUpdatePeer(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
pool := tt.pool
|
||||
err := pool.UpdatePeer(tt.args.id, tt.args.height)
|
||||
@ -232,6 +233,7 @@ func TestBlockPoolRemovePeer(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.pool.RemovePeer(tt.args.peerID, tt.args.err)
|
||||
assertBlockPoolEquivalent(t, tt.poolWanted, tt.pool)
|
||||
@ -272,6 +274,7 @@ func TestBlockPoolRemoveShortPeers(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
pool := tt.pool
|
||||
pool.removeShortPeers()
|
||||
@ -317,6 +320,7 @@ func TestBlockPoolSendRequestBatch(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
resetPoolTestResults()
|
||||
|
||||
@ -421,6 +425,7 @@ func TestBlockPoolAddBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
err := tt.pool.AddBlock(tt.args.peerID, tt.args.block, tt.args.blockSize)
|
||||
assert.Equal(t, tt.errWanted, err)
|
||||
@ -473,6 +478,7 @@ func TestBlockPoolFirstTwoBlocksAndPeers(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
pool := tt.pool
|
||||
gotFirst, gotSecond, err := pool.FirstTwoBlocksAndPeers()
|
||||
@ -544,6 +550,7 @@ func TestBlockPoolInvalidateFirstTwoBlocks(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.pool.InvalidateFirstTwoBlocks(errNoPeerResponse)
|
||||
assertBlockPoolEquivalent(t, tt.poolWanted, tt.pool)
|
||||
@ -584,6 +591,7 @@ func TestProcessedCurrentHeightBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.pool.ProcessedCurrentHeightBlock()
|
||||
assertBlockPoolEquivalent(t, tt.poolWanted, tt.pool)
|
||||
@ -642,6 +650,7 @@ func TestRemovePeerAtCurrentHeight(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
tt.pool.RemovePeerAtCurrentHeights(errNoPeerResponse)
|
||||
assertBlockPoolEquivalent(t, tt.poolWanted, tt.pool)
|
||||
|
@ -211,6 +211,7 @@ type testFields struct {
|
||||
|
||||
func executeFSMTests(t *testing.T, tests []testFields, matchRespToReq bool) {
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Create test reactor
|
||||
testBcR := newTestReactor(tt.startingHeight)
|
||||
@ -220,6 +221,7 @@ func executeFSMTests(t *testing.T, tests []testFields, matchRespToReq bool) {
|
||||
}
|
||||
|
||||
for _, step := range tt.steps {
|
||||
step := step
|
||||
assert.Equal(t, step.currentState, testBcR.fsm.state.name)
|
||||
|
||||
var heightBefore int64
|
||||
@ -862,6 +864,7 @@ func TestFSMCorrectTransitionSequences(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// Create test reactor
|
||||
testBcR := newTestReactor(tt.startingHeight)
|
||||
@ -871,6 +874,7 @@ func TestFSMCorrectTransitionSequences(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, step := range tt.steps {
|
||||
step := step
|
||||
assert.Equal(t, step.currentState, testBcR.fsm.state.name)
|
||||
|
||||
oldNumStatusRequests := testBcR.numStatusRequests
|
||||
|
@ -329,6 +329,7 @@ func TestBcBlockRequestMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
request := bcBlockRequestMessage{Height: tc.requestHeight}
|
||||
assert.Equal(t, tc.expectErr, request.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
@ -348,6 +349,7 @@ func TestBcNoBlockResponseMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
nonResponse := bcNoBlockResponseMessage{Height: tc.nonResponseHeight}
|
||||
assert.Equal(t, tc.expectErr, nonResponse.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
@ -367,6 +369,7 @@ func TestBcStatusRequestMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
request := bcStatusRequestMessage{Height: tc.requestHeight}
|
||||
assert.Equal(t, tc.expectErr, request.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
@ -386,6 +389,7 @@ func TestBcStatusResponseMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
response := bcStatusResponseMessage{Height: tc.responseHeight}
|
||||
assert.Equal(t, tc.expectErr, response.ValidateBasic() != nil, "Validate Basic had an unexpected result")
|
||||
|
@ -656,6 +656,7 @@ func TestNewRoundStepMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
message := NewRoundStepMessage{
|
||||
Height: tc.messageHeight,
|
||||
@ -685,6 +686,7 @@ func TestNewValidBlockMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
message := NewValidBlockMessage{
|
||||
Height: tc.messageHeight,
|
||||
@ -715,6 +717,7 @@ func TestProposalPOLMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
message := ProposalPOLMessage{
|
||||
Height: tc.messageHeight,
|
||||
@ -742,6 +745,7 @@ func TestBlockPartMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
message := BlockPartMessage{
|
||||
Height: tc.messageHeight,
|
||||
@ -781,6 +785,7 @@ func TestHasVoteMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
message := HasVoteMessage{
|
||||
Height: tc.messageHeight,
|
||||
@ -825,6 +830,7 @@ func TestVoteSetMaj23MessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
message := VoteSetMaj23Message{
|
||||
Height: tc.messageHeight,
|
||||
@ -871,6 +877,7 @@ func TestVoteSetBitsMessageValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
message := VoteSetBitsMessage{
|
||||
Height: tc.messageHeight,
|
||||
|
@ -123,6 +123,7 @@ func TestWALCrash(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
tc := tc
|
||||
consensusReplayConfig := ResetConfig(fmt.Sprintf("%s_%d", t.Name(), i))
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
crashWALandCheckLiveness(t, consensusReplayConfig, tc.initFn, tc.heightToStop)
|
||||
|
@ -86,6 +86,8 @@ func TestWALEncoderDecoder(t *testing.T) {
|
||||
b := new(bytes.Buffer)
|
||||
|
||||
for _, msg := range msgs {
|
||||
msg := msg
|
||||
|
||||
b.Reset()
|
||||
|
||||
enc := NewWALEncoder(b)
|
||||
|
@ -56,6 +56,7 @@ func TestRFC6962Hasher(t *testing.T) {
|
||||
got: innerHash([]byte("N123"), []byte("N456")),
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.desc, func(t *testing.T) {
|
||||
wantBytes, err := hex.DecodeString(tc.want)
|
||||
if err != nil {
|
||||
|
@ -72,6 +72,7 @@ func TestJSONMarshalUnmarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.bA.String(), func(t *testing.T) {
|
||||
bz, err := json.Marshal(tc.bA)
|
||||
require.NoError(t, err)
|
||||
@ -131,6 +132,7 @@ func TestCompactMarshalUnmarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.bA.String(), func(t *testing.T) {
|
||||
bz := tc.bA.CompactMarshal()
|
||||
|
||||
@ -165,12 +167,15 @@ func TestCompactBitArrayNumOfTrueBitsBefore(t *testing.T) {
|
||||
{`"______________xx"`, []int{14, 15}, []int{0, 1}},
|
||||
}
|
||||
for tcIndex, tc := range testCases {
|
||||
tc := tc
|
||||
tcIndex := tcIndex
|
||||
t.Run(tc.marshalledBA, func(t *testing.T) {
|
||||
var bA *CompactBitArray
|
||||
err := json.Unmarshal([]byte(tc.marshalledBA), &bA)
|
||||
require.NoError(t, err)
|
||||
|
||||
for i := 0; i < len(tc.bAIndex); i++ {
|
||||
|
||||
require.Equal(t, tc.trueValueIndex[i], bA.NumTrueBitsBefore(tc.bAIndex[i]), "tc %d, i %d", tcIndex, i)
|
||||
}
|
||||
})
|
||||
|
@ -29,6 +29,7 @@ func Test_genPrivKey(t *testing.T) {
|
||||
{"valid because 0 < 1 < N", validOne, false},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
if tt.shouldPanic {
|
||||
require.Panics(t, func() {
|
||||
|
@ -100,6 +100,7 @@ func TestGenPrivKeySecp256k1(t *testing.T) {
|
||||
{"another seed used in cosmos tests #3", []byte("")},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
gotPrivKey := secp256k1.GenPrivKeySecp256k1(tt.secret)
|
||||
require.NotNil(t, gotPrivKey)
|
||||
|
@ -203,6 +203,7 @@ func TestEvidenceListMessageValidationBasic(t *testing.T) {
|
||||
}, true},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
evListMsg := &EvidenceListMessage{}
|
||||
n := 3
|
||||
|
@ -232,6 +232,7 @@ func TestJSONMarshalUnmarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.bA.String(), func(t *testing.T) {
|
||||
bz, err := json.Marshal(tc.bA)
|
||||
require.NoError(t, err)
|
||||
|
@ -40,6 +40,7 @@ func TestJSONMarshal(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(fmt.Sprintf("Case %d", i), func(t *testing.T) {
|
||||
ts := TestStruct{B1: tc.input, B2: tc.input}
|
||||
|
||||
|
@ -89,6 +89,7 @@ func TestReader(t *testing.T) {
|
||||
{false, start, _300ms, 0, 20, 3, 0, 0, 67, 100, 0, 0, 0},
|
||||
}
|
||||
for i, s := range status {
|
||||
s := s
|
||||
if !statusesAreEqual(&s, &want[i]) {
|
||||
t.Errorf("r.Status(%v)\nexpected: %v\ngot : %v", i, want[i], s)
|
||||
}
|
||||
@ -143,6 +144,7 @@ func TestWriter(t *testing.T) {
|
||||
{true, start, _500ms, _100ms, 100, 5, 200, 200, 200, 200, 0, 0, 100000},
|
||||
}
|
||||
for i, s := range status {
|
||||
s := s
|
||||
if !statusesAreEqual(&s, &want[i]) {
|
||||
t.Errorf("w.Status(%v)\nexpected: %v\ngot : %v\n", i, want[i], s)
|
||||
}
|
||||
|
@ -55,6 +55,7 @@ func TestVariousLevels(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
var buf bytes.Buffer
|
||||
logger := log.NewFilter(log.NewTMJSONLogger(&buf), tc.allowed)
|
||||
|
@ -110,6 +110,7 @@ func TestShareLowOrderPubkey(t *testing.T) {
|
||||
|
||||
// all blacklisted low order points:
|
||||
for _, remLowOrderPubKey := range blacklist {
|
||||
remLowOrderPubKey := remLowOrderPubKey
|
||||
_, _ = cmn.Parallel(
|
||||
func(_ int) (val interface{}, err error, abort bool) {
|
||||
_, err = shareEphPubKey(fooConn, locEphPub)
|
||||
@ -135,6 +136,7 @@ func TestShareLowOrderPubkey(t *testing.T) {
|
||||
func TestComputeDHFailsOnLowOrder(t *testing.T) {
|
||||
_, locPrivKey := genEphKeys()
|
||||
for _, remLowOrderPubKey := range blacklist {
|
||||
remLowOrderPubKey := remLowOrderPubKey
|
||||
shared, err := computeDHSecret(&remLowOrderPubKey, locPrivKey)
|
||||
assert.Error(t, err)
|
||||
|
||||
|
@ -67,6 +67,7 @@ func TestNewNetAddressString(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
addr, err := NewNetAddressString(tc.addr)
|
||||
if tc.correct {
|
||||
|
@ -394,6 +394,7 @@ func unmarshalResponseBytesArray(cdc *amino.Codec, responseBytes []byte, expecte
|
||||
}
|
||||
|
||||
for i, response := range responses {
|
||||
response := response
|
||||
// From the JSON-RPC 2.0 spec:
|
||||
// id: It MUST be the same as the value of the id member in the Request Object.
|
||||
if err := validateResponseID(&response, expectedID); err != nil {
|
||||
|
@ -129,6 +129,7 @@ func makeJSONRPCHandler(funcMap map[string]*RPCFunc, cdc *amino.Codec, logger lo
|
||||
}
|
||||
|
||||
for _, request := range requests {
|
||||
request := request
|
||||
// A Notification is a Request object without an "id" member.
|
||||
// The Server MUST NOT reply to a Notification, including those that are within a batch request.
|
||||
if request.ID == types.JSONRPCStringID("") {
|
||||
|
@ -75,6 +75,7 @@ func TestLoadAndUpgrade(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
// need to re-write the file everytime because upgrading renames it
|
||||
err := ioutil.WriteFile(oldFilePath, []byte(oldPrivvalContent), 0600)
|
||||
|
@ -210,6 +210,7 @@ func TestValidateValidatorUpdates(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
err := sm.ValidateValidatorUpdates(tc.abciUpdates, tc.validatorParams)
|
||||
if tc.shouldErr {
|
||||
@ -275,6 +276,7 @@ func TestUpdateValidators(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
updates, err := types.PB2TM.ValidatorUpdates(tc.abciUpdates)
|
||||
assert.NoError(t, err)
|
||||
|
@ -70,6 +70,7 @@ func BenchmarkLoadValidators(b *testing.B) {
|
||||
sm.SaveState(stateDB, state)
|
||||
|
||||
for i := 10; i < 10000000000; i *= 10 { // 10, 100, 1000, ...
|
||||
i := i
|
||||
sm.SaveValidatorsInfo(stateDB, int64(i), state.LastHeightValidatorsChanged, state.NextValidators)
|
||||
|
||||
b.Run(fmt.Sprintf("height=%d", i), func(b *testing.B) {
|
||||
|
@ -118,6 +118,7 @@ func TestTxSearch(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.q, func(t *testing.T) {
|
||||
results, err := indexer.Search(query.MustParse(tc.q))
|
||||
assert.NoError(t, err)
|
||||
@ -191,6 +192,7 @@ func TestTxSearchDeprecatedIndexing(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.q, func(t *testing.T) {
|
||||
results, err := indexer.Search(query.MustParse(tc.q))
|
||||
require.NoError(t, err)
|
||||
|
@ -84,6 +84,7 @@ func TestNewBlockStore(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tt := range panicCausers {
|
||||
tt := tt
|
||||
// Expecting a panic here on trying to parse an invalid blockStore
|
||||
_, _, panicErr := doFn(func() (interface{}, error) {
|
||||
db.Set(blockStoreKey, tt.data)
|
||||
@ -253,6 +254,7 @@ func TestBlockStoreSaveLoadBlock(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tuple := range tuples {
|
||||
tuple := tuple
|
||||
bs, db := freshBlockStore()
|
||||
// SaveBlock
|
||||
res, err, panicErr := doFn(func() (interface{}, error) {
|
||||
|
@ -83,6 +83,8 @@ func TestBlockValidateBasic(t *testing.T) {
|
||||
}, true},
|
||||
}
|
||||
for i, tc := range testCases {
|
||||
tc := tc
|
||||
i := i
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
block := MakeBlock(h, txs, commit, evList)
|
||||
block.ProposerAddress = valSet.GetProposer().Address
|
||||
@ -228,6 +230,7 @@ func TestCommitValidateBasic(t *testing.T) {
|
||||
{"Incorrect round", func(com *Commit) { com.Precommits[0].Round = 100 }, true},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
com := randCommit()
|
||||
tc.malleateCommit(com)
|
||||
@ -302,6 +305,7 @@ func TestBlockMaxDataBytes(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
tc := tc
|
||||
if tc.panics {
|
||||
assert.Panics(t, func() {
|
||||
MaxDataBytes(tc.maxBytes, tc.valsCount, tc.evidenceCount)
|
||||
@ -330,6 +334,7 @@ func TestBlockMaxDataBytesUnknownEvidence(t *testing.T) {
|
||||
}
|
||||
|
||||
for i, tc := range testCases {
|
||||
tc := tc
|
||||
if tc.panics {
|
||||
assert.Panics(t, func() {
|
||||
MaxDataBytesUnknownEvidence(tc.maxBytes, tc.valsCount)
|
||||
@ -406,6 +411,7 @@ func TestSignedHeaderValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
sh := SignedHeader{
|
||||
Header: tc.shHeader,
|
||||
@ -445,6 +451,7 @@ func TestBlockIDValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
blockID := BlockID{
|
||||
Hash: tc.blockIDHash,
|
||||
|
@ -338,6 +338,7 @@ func BenchmarkEventBus(b *testing.B) {
|
||||
}
|
||||
|
||||
for _, bm := range benchmarks {
|
||||
bm := bm
|
||||
b.Run(bm.name, func(b *testing.B) {
|
||||
benchmarkEventBus(bm.numClients, bm.randQueries, bm.randEvents, b)
|
||||
})
|
||||
|
@ -146,6 +146,7 @@ func TestDuplicateVoteEvidenceValidation(t *testing.T) {
|
||||
}, true},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
ev := &DuplicateVoteEvidence{
|
||||
PubKey: secp256k1.GenPrivKey().PubKey(),
|
||||
|
@ -95,6 +95,7 @@ func TestPartSetHeaderValidateBasic(t *testing.T) {
|
||||
{"Invalid Hash", func(psHeader *PartSetHeader) { psHeader.Hash = make([]byte, 1) }, true},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
data := cmn.RandBytes(testPartSize * 100)
|
||||
ps := NewPartSetFromData(data, testPartSize)
|
||||
@ -117,6 +118,7 @@ func TestPartValidateBasic(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
data := cmn.RandBytes(testPartSize * 100)
|
||||
ps := NewPartSetFromData(data, testPartSize)
|
||||
|
@ -127,6 +127,7 @@ func TestProposalValidateBasic(t *testing.T) {
|
||||
blockID := makeBlockID(tmhash.Sum([]byte("blockhash")), math.MaxInt64, tmhash.Sum([]byte("partshash")))
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
prop := NewProposal(
|
||||
4, 2, 2,
|
||||
|
@ -285,6 +285,7 @@ func TestVoteValidateBasic(t *testing.T) {
|
||||
{"Too big Signature", func(v *Vote) { v.Signature = make([]byte, MaxSignatureSize+1) }, true},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.testName, func(t *testing.T) {
|
||||
vote := examplePrecommit()
|
||||
err := privVal.SignVote("test_chain_id", vote)
|
||||
|
Loading…
x
Reference in New Issue
Block a user