diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 4858c43d98..213dff7922 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -35,10 +35,9 @@ jobs: id: unittest shell: bash run: | - go install golang.org/x/lint/golint@master go install github.com/dave/courtney@latest go mod tidy - golint -set_exit_status $(go list ./... | grep -v /vendor/ | grep -v /explorer/idl/ | grep -v /api/idl/) + go vet $(go list ./... | grep -v /vendor/ | grep -v /explorer/idl/ | grep -v /api/idl/) #go get -u github.com/dave/courtney@038390a12707e2d91979d2ca77a71597f4afe400 ./go.test.sh #make test diff --git a/.golangci.yml b/.golangci.yml index 2744d47c56..d49a456b35 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -11,8 +11,6 @@ run: linters-settings: govet: check-shadowing: true - golint: - min-confidence: 0 gocyclo: min-complexity: 15 maligned: @@ -64,7 +62,6 @@ linters: - gocyclo - gofmt - goimports - - golint - gosec - gosimple - govet diff --git a/Makefile b/Makefile index 1f58c1c0a8..abeca2077a 100644 --- a/Makefile +++ b/Makefile @@ -7,7 +7,7 @@ # Go parameters GOCMD=go -GOLINT=golint +GOVET=$(GOCMD) vet GOBUILD=$(GOCMD) build GOINSTALL=$(GOCMD) install GOCLEAN=$(GOCMD) clean @@ -113,7 +113,7 @@ fmt: .PHONY: lint lint: - go list ./... | xargs $(GOLINT) + go list ./... | xargs $(GOVET) .PHONY: lint-rich lint-rich: diff --git a/action/execution_test.go b/action/execution_test.go index 01fa866ba2..c381bb2974 100644 --- a/action/execution_test.go +++ b/action/execution_test.go @@ -102,19 +102,19 @@ func TestExecutionAccessList(t *testing.T) { {nil, 10400}, { types.AccessList{ - {common.Address{}, nil}, + {Address: common.Address{}, StorageKeys: nil}, }, 12800, }, { types.AccessList{ - {_c2, []common.Hash{{}, _k1}}, + {Address: _c2, StorageKeys: []common.Hash{{}, _k1}}, }, 16600, }, { types.AccessList{ - {common.Address{}, nil}, - {_c1, []common.Hash{_k1, {}, _k3}}, - {_c2, []common.Hash{_k2, _k3, _k4, _k1}}, + {Address: common.Address{}, StorageKeys: nil}, + {Address: _c1, StorageKeys: []common.Hash{_k1, {}, _k3}}, + {Address: _c2, StorageKeys: []common.Hash{_k2, _k3, _k4, _k1}}, }, 30900, }, } { diff --git a/action/protocol/execution/evm/evmstatedbadapter.go b/action/protocol/execution/evm/evmstatedbadapter.go index 46dff0dbab..a898d5986d 100644 --- a/action/protocol/execution/evm/evmstatedbadapter.go +++ b/action/protocol/execution/evm/evmstatedbadapter.go @@ -779,7 +779,6 @@ func (stateDB *StateDBAdapter) ForEachStorage(addr common.Address, cb func(commo return nil } } - return nil } // accountState returns an account state diff --git a/action/protocol/poll/governance_protocol_test.go b/action/protocol/poll/governance_protocol_test.go index cb10abf247..b39f4e16ab 100644 --- a/action/protocol/poll/governance_protocol_test.go +++ b/action/protocol/poll/governance_protocol_test.go @@ -473,8 +473,8 @@ func TestHandle(t *testing.T) { var sc3 state.CandidateList _, err = sm3.State(&sc3, protocol.KeyOption(candKey[:]), protocol.NamespaceOption(protocol.SystemNamespace)) require.NoError(err) - sc3 = append(sc3, &state.Candidate{"1", big.NewInt(10), "2", nil}) - sc3 = append(sc3, &state.Candidate{"1", big.NewInt(10), "2", nil}) + sc3 = append(sc3, &state.Candidate{Address: "1", Votes: big.NewInt(10), RewardAddress: "2", CanName: nil}) + sc3 = append(sc3, &state.Candidate{Address: "1", Votes: big.NewInt(10), RewardAddress: "2", CanName: nil}) act3 := action.NewPutPollResult(1, 1, sc3) bd := &action.EnvelopeBuilder{} elp := bd.SetGasLimit(uint64(100000)). @@ -508,7 +508,7 @@ func TestHandle(t *testing.T) { var sc4 state.CandidateList _, err = sm4.State(&sc4, protocol.KeyOption(candKey[:]), protocol.NamespaceOption(protocol.SystemNamespace)) require.NoError(err) - sc4 = append(sc4, &state.Candidate{"1", big.NewInt(10), "2", nil}) + sc4 = append(sc4, &state.Candidate{Address: "1", Votes: big.NewInt(10), RewardAddress: "2", CanName: nil}) act4 := action.NewPutPollResult(1, 1, sc4) bd4 := &action.EnvelopeBuilder{} elp4 := bd4.SetGasLimit(uint64(100000)). diff --git a/action/protocol/poll/staking_committee_test.go b/action/protocol/poll/staking_committee_test.go index 5dc94c6d15..05daa4386b 100644 --- a/action/protocol/poll/staking_committee_test.go +++ b/action/protocol/poll/staking_committee_test.go @@ -294,8 +294,8 @@ func TestHandle_StakingCommittee(t *testing.T) { var sc3 state.CandidateList _, err = sm3.State(&sc3, protocol.LegacyKeyOption(candidatesutil.ConstructLegacyKey(1))) require.NoError(err) - sc3 = append(sc3, &state.Candidate{"1", big.NewInt(10), "2", nil}) - sc3 = append(sc3, &state.Candidate{"1", big.NewInt(10), "2", nil}) + sc3 = append(sc3, &state.Candidate{Address: "1", Votes: big.NewInt(10), RewardAddress: "2", CanName: nil}) + sc3 = append(sc3, &state.Candidate{Address: "1", Votes: big.NewInt(10), RewardAddress: "2", CanName: nil}) act3 := action.NewPutPollResult(1, 1, sc3) bd := &action.EnvelopeBuilder{} elp := bd.SetGasLimit(uint64(100000)). @@ -331,7 +331,7 @@ func TestHandle_StakingCommittee(t *testing.T) { var sc4 state.CandidateList _, err = sm4.State(&sc4, protocol.LegacyKeyOption(candidatesutil.ConstructLegacyKey(1))) require.NoError(err) - sc4 = append(sc4, &state.Candidate{"1", big.NewInt(10), "2", nil}) + sc4 = append(sc4, &state.Candidate{Address: "1", Votes: big.NewInt(10), RewardAddress: "2", CanName: nil}) act4 := action.NewPutPollResult(1, 1, sc4) bd4 := &action.EnvelopeBuilder{} elp4 := bd4.SetGasLimit(uint64(100000)). diff --git a/action/protocol/staking/ethabi/stake_base.go b/action/protocol/staking/ethabi/stake_base.go index 1f23bbe8be..cc7b3a2adc 100644 --- a/action/protocol/staking/ethabi/stake_base.go +++ b/action/protocol/staking/ethabi/stake_base.go @@ -57,7 +57,7 @@ type ( } ) -func encodeVoteBucketListToEth(outputs abi.Arguments, buckets iotextypes.VoteBucketList) (string, error) { +func encodeVoteBucketListToEth(outputs abi.Arguments, buckets *iotextypes.VoteBucketList) (string, error) { args := make([]BucketEth, len(buckets.Buckets)) for i, bucket := range buckets.Buckets { args[i] = BucketEth{} @@ -139,7 +139,7 @@ func encodeCandidateToEth(candidate *iotextypes.CandidateV2) (*CandidateEth, err return result, nil } -func encodeBucketTypeListToEth(outputs abi.Arguments, bucketTypes iotextypes.ContractStakingBucketTypeList) (string, error) { +func encodeBucketTypeListToEth(outputs abi.Arguments, bucketTypes *iotextypes.ContractStakingBucketTypeList) (string, error) { args := make([]BucketTypeEth, len(bucketTypes.BucketTypes)) for i, bt := range bucketTypes.BucketTypes { args[i] = BucketTypeEth{} diff --git a/action/protocol/staking/ethabi/stake_buckets.go b/action/protocol/staking/ethabi/stake_buckets.go index 8fe8715093..e5de6111b6 100644 --- a/action/protocol/staking/ethabi/stake_buckets.go +++ b/action/protocol/staking/ethabi/stake_buckets.go @@ -147,5 +147,5 @@ func (r *BucketsStateContext) EncodeToEth(resp *iotexapi.ReadStateResponse) (str return "", err } - return encodeVoteBucketListToEth(_bucketsMethod.Outputs, result) + return encodeVoteBucketListToEth(_bucketsMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_bucketsbycandidate.go b/action/protocol/staking/ethabi/stake_bucketsbycandidate.go index 013ddf4f0b..c0e00d7e61 100644 --- a/action/protocol/staking/ethabi/stake_bucketsbycandidate.go +++ b/action/protocol/staking/ethabi/stake_bucketsbycandidate.go @@ -157,5 +157,5 @@ func (r *BucketsByCandidateStateContext) EncodeToEth(resp *iotexapi.ReadStateRes return "", err } - return encodeVoteBucketListToEth(_bucketsByCandidateMethod.Outputs, result) + return encodeVoteBucketListToEth(_bucketsByCandidateMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_bucketsbyindexes.go b/action/protocol/staking/ethabi/stake_bucketsbyindexes.go index 699904582f..fd8381cbd5 100644 --- a/action/protocol/staking/ethabi/stake_bucketsbyindexes.go +++ b/action/protocol/staking/ethabi/stake_bucketsbyindexes.go @@ -136,5 +136,5 @@ func (r *BucketsByIndexesStateContext) EncodeToEth(resp *iotexapi.ReadStateRespo return "", err } - return encodeVoteBucketListToEth(_bucketsByIndexesMethod.Outputs, result) + return encodeVoteBucketListToEth(_bucketsByIndexesMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_bucketsbyvoter.go b/action/protocol/staking/ethabi/stake_bucketsbyvoter.go index 772090424b..2561e4bfea 100644 --- a/action/protocol/staking/ethabi/stake_bucketsbyvoter.go +++ b/action/protocol/staking/ethabi/stake_bucketsbyvoter.go @@ -163,5 +163,5 @@ func (r *BucketsByVoterStateContext) EncodeToEth(resp *iotexapi.ReadStateRespons return "", err } - return encodeVoteBucketListToEth(_bucketsByVoterMethod.Outputs, result) + return encodeVoteBucketListToEth(_bucketsByVoterMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_composite_buckets.go b/action/protocol/staking/ethabi/stake_composite_buckets.go index 649f5b7108..7011bc1a55 100644 --- a/action/protocol/staking/ethabi/stake_composite_buckets.go +++ b/action/protocol/staking/ethabi/stake_composite_buckets.go @@ -173,5 +173,5 @@ func (r *CompositeBucketsStateContext) EncodeToEth(resp *iotexapi.ReadStateRespo return "", err } - return encodeVoteBucketListToEth(_compositeBucketsMethod.Outputs, result) + return encodeVoteBucketListToEth(_compositeBucketsMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_composite_buckets_test.go b/action/protocol/staking/ethabi/stake_composite_buckets_test.go index 1d07fb8d6e..5ed698998e 100644 --- a/action/protocol/staking/ethabi/stake_composite_buckets_test.go +++ b/action/protocol/staking/ethabi/stake_composite_buckets_test.go @@ -76,7 +76,7 @@ func TestEncodeCompositeVoteBucketListToEth(t *testing.T) { UnstakeStartBlockHeight: 1_000_000_002, } - data, err := encodeVoteBucketListToEth(_compositeBucketsMethod.Outputs, iotextypes.VoteBucketList{ + data, err := encodeVoteBucketListToEth(_compositeBucketsMethod.Outputs, &iotextypes.VoteBucketList{ Buckets: buckets, }) t.Logf("data: %s\n", data) diff --git a/action/protocol/staking/ethabi/stake_composite_bucketsbycandidate.go b/action/protocol/staking/ethabi/stake_composite_bucketsbycandidate.go index 83a2181278..f4cfe01fac 100644 --- a/action/protocol/staking/ethabi/stake_composite_bucketsbycandidate.go +++ b/action/protocol/staking/ethabi/stake_composite_bucketsbycandidate.go @@ -183,5 +183,5 @@ func (r *CompositeBucketsByCandidateStateContext) EncodeToEth(resp *iotexapi.Rea return "", err } - return encodeVoteBucketListToEth(_compositeBucketsByCandidateMethod.Outputs, result) + return encodeVoteBucketListToEth(_compositeBucketsByCandidateMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_composite_bucketsbyindices.go b/action/protocol/staking/ethabi/stake_composite_bucketsbyindices.go index e3b8869fe3..1e3c6bf221 100644 --- a/action/protocol/staking/ethabi/stake_composite_bucketsbyindices.go +++ b/action/protocol/staking/ethabi/stake_composite_bucketsbyindices.go @@ -162,5 +162,5 @@ func (r *CompositeBucketsByIndexesStateContext) EncodeToEth(resp *iotexapi.ReadS return "", err } - return encodeVoteBucketListToEth(_compositeBucketsByIndexesMethod.Outputs, result) + return encodeVoteBucketListToEth(_compositeBucketsByIndexesMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_composite_bucketsbyvoter.go b/action/protocol/staking/ethabi/stake_composite_bucketsbyvoter.go index a34e995850..f29ff8122a 100644 --- a/action/protocol/staking/ethabi/stake_composite_bucketsbyvoter.go +++ b/action/protocol/staking/ethabi/stake_composite_bucketsbyvoter.go @@ -189,5 +189,5 @@ func (r *CompositeBucketsByVoterStateContext) EncodeToEth(resp *iotexapi.ReadSta return "", err } - return encodeVoteBucketListToEth(_compositeBucketsByVoterMethod.Outputs, result) + return encodeVoteBucketListToEth(_compositeBucketsByVoterMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_contract_buckettypes.go b/action/protocol/staking/ethabi/stake_contract_buckettypes.go index 7a093f0a5e..237160b860 100644 --- a/action/protocol/staking/ethabi/stake_contract_buckettypes.go +++ b/action/protocol/staking/ethabi/stake_contract_buckettypes.go @@ -108,5 +108,5 @@ func (r *ContractBucketTypesStateContext) EncodeToEth(resp *iotexapi.ReadStateRe return "", err } - return encodeBucketTypeListToEth(_contractBucketTypesMethod.Outputs, result) + return encodeBucketTypeListToEth(_contractBucketTypesMethod.Outputs, &result) } diff --git a/action/protocol/staking/ethabi/stake_contract_buckettypes_test.go b/action/protocol/staking/ethabi/stake_contract_buckettypes_test.go index 63965850fd..3c2482e06d 100644 --- a/action/protocol/staking/ethabi/stake_contract_buckettypes_test.go +++ b/action/protocol/staking/ethabi/stake_contract_buckettypes_test.go @@ -60,7 +60,7 @@ func TestEncodeBucketTypeListToEth(t *testing.T) { StakedDuration: 2_000_000, } - data, err := encodeBucketTypeListToEth(_contractBucketTypesMethod.Outputs, iotextypes.ContractStakingBucketTypeList{ + data, err := encodeBucketTypeListToEth(_contractBucketTypesMethod.Outputs, &iotextypes.ContractStakingBucketTypeList{ BucketTypes: bts, }) diff --git a/action/protocol/staking/ethabi/stakebuckets_test.go b/action/protocol/staking/ethabi/stakebuckets_test.go index 84fa062d5d..7fc8eaa000 100644 --- a/action/protocol/staking/ethabi/stakebuckets_test.go +++ b/action/protocol/staking/ethabi/stakebuckets_test.go @@ -69,7 +69,7 @@ func TestEncodeVoteBucketListToEth(t *testing.T) { Owner: "io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqxf907nt9", } - data, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, iotextypes.VoteBucketList{ + data, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, &iotextypes.VoteBucketList{ Buckets: buckets, }) @@ -82,7 +82,7 @@ func TestEncodeVoteBucketListToEthEmptyBuckets(t *testing.T) { buckets := make([]*iotextypes.VoteBucket, 0) - data, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, iotextypes.VoteBucketList{ + data, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, &iotextypes.VoteBucketList{ Buckets: buckets, }) @@ -107,7 +107,7 @@ func TestEncodeVoteBucketListToEthErrorCandidateAddress(t *testing.T) { Owner: "io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqxgce2xkh", } - _, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, iotextypes.VoteBucketList{ + _, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, &iotextypes.VoteBucketList{ Buckets: buckets, }) @@ -131,7 +131,7 @@ func TestEncodeVoteBucketListToEthErrorStakedAmount(t *testing.T) { Owner: "io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqxgce2xkh", } - _, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, iotextypes.VoteBucketList{ + _, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, &iotextypes.VoteBucketList{ Buckets: buckets, }) @@ -155,7 +155,7 @@ func TestEncodeVoteBucketListToEthErrorOwner(t *testing.T) { Owner: "io1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqxgce2xk", } - _, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, iotextypes.VoteBucketList{ + _, err := encodeVoteBucketListToEth(_bucketsMethod.Outputs, &iotextypes.VoteBucketList{ Buckets: buckets, }) diff --git a/api/coreservice_test.go b/api/coreservice_test.go index d43e010a4d..5c05c7e6dd 100644 --- a/api/coreservice_test.go +++ b/api/coreservice_test.go @@ -45,7 +45,7 @@ func TestLogsInRange(t *testing.T) { to, err := strconv.ParseUint(testData.ToBlock, 10, 64) require.NoError(err) - logs, hashes, err := svr.LogsInRange(logfilter.NewLogFilter(&filter), from, to, uint64(0)) + logs, hashes, err := svr.LogsInRange(logfilter.NewLogFilter(filter), from, to, uint64(0)) require.NoError(err) require.Equal(4, len(logs)) require.Equal(4, len(hashes)) @@ -59,7 +59,7 @@ func TestLogsInRange(t *testing.T) { to, err := strconv.ParseUint(testData.ToBlock, 10, 64) require.NoError(err) - logs, hashes, err := svr.LogsInRange(logfilter.NewLogFilter(&filter), from, to, uint64(0)) + logs, hashes, err := svr.LogsInRange(logfilter.NewLogFilter(filter), from, to, uint64(0)) require.NoError(err) require.Equal(0, len(logs)) require.Equal(0, len(hashes)) @@ -73,7 +73,7 @@ func TestLogsInRange(t *testing.T) { to, err := strconv.ParseUint(testData.ToBlock, 10, 64) require.NoError(err) - logs, hashes, err := svr.LogsInRange(logfilter.NewLogFilter(&filter), from, to, uint64(5001)) + logs, hashes, err := svr.LogsInRange(logfilter.NewLogFilter(filter), from, to, uint64(5001)) require.NoError(err) require.Equal(4, len(logs)) require.Equal(4, len(hashes)) @@ -87,7 +87,7 @@ func TestLogsInRange(t *testing.T) { to, err := strconv.ParseUint(testData.ToBlock, 10, 64) require.NoError(err) - _, _, err = svr.LogsInRange(logfilter.NewLogFilter(&filter), from, to, uint64(0)) + _, _, err = svr.LogsInRange(logfilter.NewLogFilter(filter), from, to, uint64(0)) expectedErr := errors.New("invalid start or end height") require.Error(err) require.Equal(expectedErr.Error(), err.Error()) @@ -101,7 +101,7 @@ func TestLogsInRange(t *testing.T) { to, err := strconv.ParseUint(testData.ToBlock, 10, 64) require.NoError(err) - _, _, err = svr.LogsInRange(logfilter.NewLogFilter(&filter), from, to, uint64(0)) + _, _, err = svr.LogsInRange(logfilter.NewLogFilter(filter), from, to, uint64(0)) expectedErr := errors.New("start block > tip height") require.Error(err) require.Equal(expectedErr.Error(), err.Error()) @@ -122,19 +122,19 @@ func BenchmarkLogsInRange(b *testing.B) { to, _ := strconv.ParseInt(testData.ToBlock, 10, 64) b.Run("five workers to extract logs", func(b *testing.B) { - blk.EXPECT().FilterBlocksInRange(logfilter.NewLogFilter(&filter), uint64(from), uint64(to), 0).Return([]uint64{1, 2, 3, 4}, nil).AnyTimes() + blk.EXPECT().FilterBlocksInRange(logfilter.NewLogFilter(filter), uint64(from), uint64(to), 0).Return([]uint64{1, 2, 3, 4}, nil).AnyTimes() for i := 0; i < b.N; i++ { - svr.LogsInRange(logfilter.NewLogFilter(&filter), uint64(from), uint64(to), uint64(0)) + svr.LogsInRange(logfilter.NewLogFilter(filter), uint64(from), uint64(to), uint64(0)) } }) } -func getTopicsAddress(addr []string, topics [][]string) (iotexapi.LogsFilter, error) { +func getTopicsAddress(addr []string, topics [][]string) (*iotexapi.LogsFilter, error) { var filter iotexapi.LogsFilter for _, ethAddr := range addr { ioAddr, err := ethAddrToIoAddr(ethAddr) if err != nil { - return iotexapi.LogsFilter{}, err + return nil, err } filter.Address = append(filter.Address, ioAddr.String()) } @@ -143,14 +143,14 @@ func getTopicsAddress(addr []string, topics [][]string) (iotexapi.LogsFilter, er for _, str := range tp { b, err := hexToBytes(str) if err != nil { - return iotexapi.LogsFilter{}, err + return nil, err } topic = append(topic, b) } filter.Topics = append(filter.Topics, &iotexapi.Topics{Topic: topic}) } - return filter, nil + return &filter, nil } func setupTestCoreService() (CoreService, blockchain.Blockchain, blockdao.BlockDAO, actpool.ActPool, func()) { diff --git a/api/grpcserver_integrity_test.go b/api/grpcserver_integrity_test.go index 3e199bc550..ae19fb3c51 100644 --- a/api/grpcserver_integrity_test.go +++ b/api/grpcserver_integrity_test.go @@ -358,7 +358,7 @@ var ( numActions int64 tps int64 tpsFloat float32 - epoch iotextypes.EpochData + epoch *iotextypes.EpochData }{ { emptyChain: true, @@ -372,7 +372,7 @@ var ( 15, 1, 5 / 10.0, - iotextypes.EpochData{ + &iotextypes.EpochData{ Num: 1, Height: 1, GravityChainStartHeight: 1, @@ -386,7 +386,7 @@ var ( 15, 2, 15 / 13.0, - iotextypes.EpochData{ + &iotextypes.EpochData{ Num: 1, Height: 1, GravityChainStartHeight: 100, @@ -680,7 +680,7 @@ var ( EpochNumber uint64 pollProtocolType string // Expected Values - epochData iotextypes.EpochData + epochData *iotextypes.EpochData numBlksInEpoch int numConsenusBlockProducers int numActiveCensusBlockProducers int @@ -688,7 +688,7 @@ var ( { 1, lld, - iotextypes.EpochData{ + &iotextypes.EpochData{ Num: 1, Height: 1, GravityChainStartHeight: 1, @@ -700,7 +700,7 @@ var ( { 1, "governanceChainCommittee", - iotextypes.EpochData{ + &iotextypes.EpochData{ Num: 1, Height: 1, GravityChainStartHeight: 100, @@ -1279,9 +1279,11 @@ func TestGrpcServer_GetChainMetaIntegrity(t *testing.T) { require.Equal(test.height, chainMetaPb.Height) require.Equal(test.numActions, chainMetaPb.NumActions) require.Equal(test.tps, chainMetaPb.Tps) - require.Equal(test.epoch.Num, chainMetaPb.Epoch.Num) - require.Equal(test.epoch.Height, chainMetaPb.Epoch.Height) - require.Equal(test.epoch.GravityChainStartHeight, chainMetaPb.Epoch.GravityChainStartHeight) + if test.epoch != nil { + require.Equal(test.epoch.Num, chainMetaPb.Epoch.Num) + require.Equal(test.epoch.Height, chainMetaPb.Epoch.Height) + require.Equal(test.epoch.GravityChainStartHeight, chainMetaPb.Epoch.GravityChainStartHeight) + } } } diff --git a/blockchain/genesis/genesis.go b/blockchain/genesis/genesis.go index e79b6ec701..21bcbcd574 100644 --- a/blockchain/genesis/genesis.go +++ b/blockchain/genesis/genesis.go @@ -294,7 +294,7 @@ type ( // ProbationIntensityRate is a intensity rate of probation range from [0, 100], where 100 is hard-probation ProbationIntensityRate uint32 `yaml:"probationIntensityRate"` // UnproductiveDelegateMaxCacheSize is a max cache size of upd which is stored into state DB (probationEpochPeriod <= UnproductiveDelegateMaxCacheSize) - UnproductiveDelegateMaxCacheSize uint64 `yaml:unproductiveDelegateMaxCacheSize` + UnproductiveDelegateMaxCacheSize uint64 `yaml:"unproductiveDelegateMaxCacheSize"` // SystemStakingContractAddress is the address of system staking contract SystemStakingContractAddress string `yaml:"systemStakingContractAddress"` // SystemStakingContractHeight is the height of system staking contract diff --git a/e2etest/native_staking_test.go b/e2etest/native_staking_test.go index fdb359c6b8..40c183b3b3 100644 --- a/e2etest/native_staking_test.go +++ b/e2etest/native_staking_test.go @@ -59,18 +59,18 @@ func TestNativeStaking(t *testing.T) { testInitCands := []genesis.BootstrapCandidate{ { - identityset.Address(22).String(), - identityset.Address(23).String(), - identityset.Address(23).String(), - "test1", - selfStake.String(), + OwnerAddress: identityset.Address(22).String(), + OperatorAddress: identityset.Address(23).String(), + RewardAddress: identityset.Address(23).String(), + Name: "test1", + SelfStakingTokens: selfStake.String(), }, { - identityset.Address(24).String(), - identityset.Address(25).String(), - identityset.Address(25).String(), - "test2", - selfStake.String(), + OwnerAddress: identityset.Address(24).String(), + OperatorAddress: identityset.Address(25).String(), + RewardAddress: identityset.Address(25).String(), + Name: "test2", + SelfStakingTokens: selfStake.String(), }, } diff --git a/nodeinfo/manager_test.go b/nodeinfo/manager_test.go index 28ce2265eb..458c1c870b 100644 --- a/nodeinfo/manager_test.go +++ b/nodeinfo/manager_test.go @@ -193,7 +193,7 @@ func TestDelegateManager_HandleNodeInfoRequest(t *testing.T) { message := &iotextypes.NodeInfo{} hMock.EXPECT().TipHeight().Return(height).Times(1) tMock.EXPECT().UnicastOutbound(gomock.Any(), gomock.Any(), gomock.Any()).DoAndReturn(func(_ context.Context, peerInfo peer.AddrInfo, msg proto.Message) error { - *message = *msg.(*iotextypes.NodeInfo) + message = msg.(*iotextypes.NodeInfo) hash := hashNodeInfo(message.Info) sig, _ = dm.privKey.Sign(hash[:]) return nil @@ -219,17 +219,18 @@ func TestDelegateManager_RequestSingleNodeInfoAsync(t *testing.T) { tMock := mock_nodeinfo.NewMocktransmitter(ctrl) dm := NewInfoManager(&DefaultConfig, tMock, hMock, privKey, getEmptyWhiteList) var paramPeer peer.AddrInfo - var paramMsg iotextypes.NodeInfoRequest + var paramMsg *iotextypes.NodeInfoRequest peerID, err := peer.IDFromString("12D3KooWF2fns5ZWKbPfx2U1wQDdxoTK2D6HC3ortbSAQYR4BQp4") require.NoError(err) targetPeer := peer.AddrInfo{ID: peerID} tMock.EXPECT().UnicastOutbound(gomock.Any(), gomock.Any(), gomock.Any()).Do(func(_ context.Context, p peer.AddrInfo, msg proto.Message) { paramPeer = p - paramMsg = *msg.(*iotextypes.NodeInfoRequest) + paramMsg = msg.(*iotextypes.NodeInfoRequest) }).Times(1) dm.RequestSingleNodeInfoAsync(context.Background(), targetPeer) require.Equal(targetPeer, paramPeer) - require.Equal(iotextypes.NodeInfoRequest{}, paramMsg) + request := iotextypes.NodeInfoRequest{} + require.Equal(request.String(), paramMsg.String()) }) } diff --git a/pkg/util/httputil/httputil_test.go b/pkg/util/httputil/httputil_test.go index 2c98dc9b78..a566b8064f 100644 --- a/pkg/util/httputil/httputil_test.go +++ b/pkg/util/httputil/httputil_test.go @@ -14,16 +14,13 @@ func TestServer(t *testing.T) { var handler http.Handler addr := "myAddress" - expectValue := http.Server{ - ReadHeaderTimeout: 2 * time.Second, - ReadTimeout: DefaultServerConfig.ReadTimeout, - WriteTimeout: DefaultServerConfig.WriteTimeout, - IdleTimeout: DefaultServerConfig.IdleTimeout, - Addr: addr, - Handler: handler, - } result := NewServer(addr, handler, ReadHeaderTimeout(2*time.Second)) - require.Equal(t, expectValue, result) + require.Equal(t, 2*time.Second, result.ReadHeaderTimeout) + require.Equal(t, DefaultServerConfig.ReadTimeout, result.ReadTimeout) + require.Equal(t, DefaultServerConfig.WriteTimeout, result.WriteTimeout) + require.Equal(t, DefaultServerConfig.IdleTimeout, result.IdleTimeout) + require.Equal(t, addr, result.Addr) + require.Equal(t, handler, result.Handler) }) } diff --git a/tools/actioninjector.v2/internal/cmd/inject.go b/tools/actioninjector.v2/internal/cmd/inject.go index 304677b03f..e7f5eca3f2 100644 --- a/tools/actioninjector.v2/internal/cmd/inject.go +++ b/tools/actioninjector.v2/internal/cmd/inject.go @@ -65,7 +65,8 @@ type injectProcessor struct { func newInjectionProcessor() (*injectProcessor, error) { var conn *grpc.ClientConn var err error - grpcctx, _ := context.WithTimeout(context.Background(), 10*time.Second) + grpcctx, cancel := context.WithTimeout(context.Background(), 10*time.Second) + defer cancel() log.L().Info("Server Addr", zap.String("endpoint", injectCfg.serverAddr)) if injectCfg.insecure { log.L().Info("insecure connection") diff --git a/tools/bot/Makefile b/tools/bot/Makefile index a90cc57799..652b3cf695 100644 --- a/tools/bot/Makefile +++ b/tools/bot/Makefile @@ -7,7 +7,7 @@ # Go parameters GOCMD=go -GOLINT=golint +GOVET=$(GOCMD) vet GOBUILD=$(GOCMD) build GOINSTALL=$(GOCMD) install GOCLEAN=$(GOCMD) clean