Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix lint issue #2209

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ run:
skip-dirs-use-default: true
skip-files:
- core/genesis_alloc.go
skip-dirs:
- common/math
- common/json

linters:
disable-all: true
Expand Down
12 changes: 6 additions & 6 deletions common/math/binomial_distribution_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,27 +42,27 @@ func TestBinomialDistribution(t *testing.T) {
}
}
bd = NewBinomialDistribution((1<<63)-1, p)
tp, err := bd.CumulativeProbability(int64(10000000))
_, err := bd.CumulativeProbability(int64(10000000))
if nil != err {
t.Error(err)
}
tp, err = bd.CumulativeProbability(int64(100000000))
_, err = bd.CumulativeProbability(int64(100000000))
if nil != err {
t.Error(err)
}
tp, err = bd.CumulativeProbability(int64(1000000000))
_, err = bd.CumulativeProbability(int64(1000000000))
if nil != err {
t.Error(err)
}
tp, err = bd.CumulativeProbability(int64(10000000000))
_, err = bd.CumulativeProbability(int64(10000000000))
if nil != err {
t.Error(err)
}
tp, err = bd.CumulativeProbability(int64(100000000000))
_, err = bd.CumulativeProbability(int64(100000000000))
if nil != err {
t.Error(err)
}
tp, err = bd.CumulativeProbability(int64(1000000000000))
_, err = bd.CumulativeProbability(int64(1000000000000))
if nil != err {
t.Error(err)
}
Expand Down
2 changes: 1 addition & 1 deletion core/blockchain_snapshot_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,7 @@ func (snaptest *wipeCrashSnapshotTest) test(t *testing.T) {
SnapshotLimit: 256,
SnapshotWait: false, // Don't wait rebuild
}
newchain, err = NewBlockChain(snaptest.db, config, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil)
_, err = NewBlockChain(snaptest.db, config, params.AllEthashProtocolChanges, snaptest.engine, vm.Config{}, nil, nil)
if err != nil {
t.Fatalf("Failed to recreate chain: %v", err)
}
Expand Down
4 changes: 2 additions & 2 deletions core/parallel_context.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func (ctx *ParallelContext) buildTransferFailedResult(idx int, err error, needRe
}
ctx.SetResult(idx, result)
tx := ctx.GetTx(idx)
log.Debug("Execute trasnfer failed", "blockNumber", ctx.header.Number.Uint64(), "txIdx", idx, "txHash", ctx.GetTx(idx).Hash().TerminalString(),
log.Debug("Execute transfer failed", "blockNumber", ctx.header.Number.Uint64(), "txIdx", idx, "txHash", ctx.GetTx(idx).Hash().TerminalString(),
"gasPool", ctx.gp.Gas(), "txGasLimit", tx.Gas(), "txFrom", tx.FromAddr(ctx.signer).String(), "txTo", tx.To().String(),
"txValue", tx.Value(), "needRefundGasPool", needRefundGasPool, "error", err.Error())
}
Expand All @@ -199,7 +199,7 @@ func (ctx *ParallelContext) buildTransferSuccessResult(idx int, fromStateObject,
err: nil,
}
ctx.SetResult(idx, result)
log.Trace("Execute trasnfer success", "blockNumber", ctx.header.Number.Uint64(), "txIdx", idx, "txHash", tx.Hash().TerminalString(),
log.Trace("Execute transfer success", "blockNumber", ctx.header.Number.Uint64(), "txIdx", idx, "txHash", tx.Hash().TerminalString(),
"gasPool", ctx.gp.Gas(), "txGasLimit", tx.Gas(), "txUsedGas", txGasUsed, "txFrom", tx.FromAddr(ctx.signer).String(), "txTo", tx.To().String(),
"txValue", tx.Value(), "minerEarnings", minerEarnings.Uint64())
}
Expand Down
7 changes: 4 additions & 3 deletions core/tx_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,10 @@ func init() {
testTxPoolConfig = DefaultTxPoolConfig
testTxPoolConfig.Journal = ""

cpy := *params.TestChainConfig
eip1559Config = &cpy
eip1559Config.PauliBlock = common.Big0
eip1559Config = params.TestChainConfig
//cpy := *params.TestChainConfig
//eip1559Config = &cpy
//eip1559Config.PauliBlock = common.Big0
}

type testBlockChain struct {
Expand Down
2 changes: 1 addition & 1 deletion core/vm/delegate_reward_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ func generateStk(rewardPer uint16, delegateTotal *big.Int, blockNumber uint64) (
StakingBlockNum: canBase.StakingBlockNum,
})

return stakingValIndex, validatorQueue, staking.Candidate{&canBase, &canMu}, delegation
return stakingValIndex, validatorQueue, staking.Candidate{CandidateBase: &canBase, CandidateMutable: &canMu}, delegation
}

func TestWithdrawDelegateRewardWithReward(t *testing.T) {
Expand Down
69 changes: 35 additions & 34 deletions core/vm/instructions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ type twoOperandParams struct {
y string
}

var alphabetSoup = "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
var commonParams []*twoOperandParams
var twoOpMethods map[string]executionFunc

Expand Down Expand Up @@ -356,8 +357,8 @@ func BenchmarkOpSub256(b *testing.B) {
}

func BenchmarkOpMul(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opMul, x, y)
}
Expand Down Expand Up @@ -388,64 +389,64 @@ func BenchmarkOpSdiv(b *testing.B) {
}

func BenchmarkOpMod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opMod, x, y)
}

func BenchmarkOpSmod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opSmod, x, y)
}

func BenchmarkOpExp(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opExp, x, y)
}

func BenchmarkOpSignExtend(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opSignExtend, x, y)
}

func BenchmarkOpLt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opLt, x, y)
}

func BenchmarkOpGt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opGt, x, y)
}

func BenchmarkOpSlt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opSlt, x, y)
}

func BenchmarkOpSgt(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opSgt, x, y)
}

func BenchmarkOpEq(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opEq, x, y)
}
Expand All @@ -455,45 +456,45 @@ func BenchmarkOpEq2(b *testing.B) {
opBenchmark(b, opEq, x, y)
}
func BenchmarkOpAnd(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opAnd, x, y)
}

func BenchmarkOpOr(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opOr, x, y)
}

func BenchmarkOpXor(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opXor, x, y)
}

func BenchmarkOpByte(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup

opBenchmark(b, opByte, x, y)
}

func BenchmarkOpAddmod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup
z := alphabetSoup

opBenchmark(b, opAddmod, x, y, z)
}

func BenchmarkOpMulmod(b *testing.B) {
x := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
y := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
z := "ABCDEF090807060504030201ffffffffffffffffffffffffffffffffffffffff"
x := alphabetSoup
y := alphabetSoup
z := alphabetSoup

opBenchmark(b, opMulmod, x, y, z)
}
Expand Down
4 changes: 2 additions & 2 deletions core/vm/validator_inner_contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ func (vic *validatorInnerContract) execute(input []byte, cmd map[string]interfac
return nil, err

case txTypeCurrent:
var vds *Validators = nil
var vds *Validators
vds, err = vic.CurrentValidators()
if err != nil {
log.Error("Get current validators fail", "error", err)
Expand All @@ -223,7 +223,7 @@ func (vic *validatorInnerContract) execute(input []byte, cmd map[string]interfac
return b, nil

case txTypeNext:
var vds *Validators = nil
var vds *Validators
vds, err = vic.NextValidators()
if err != nil {
log.Error("Get next validators fail", "error", err)
Expand Down
8 changes: 3 additions & 5 deletions core/vm/wagon_runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ import (

"github.com/holiman/uint256"

"golang.org/x/crypto/ripemd160"

"github.com/PlatONnetwork/PlatON-Go/common"
imath "github.com/PlatONnetwork/PlatON-Go/common/math"
"github.com/PlatONnetwork/PlatON-Go/core/types"
Expand Down Expand Up @@ -1078,7 +1076,7 @@ func SetState(proc *exec.Process, key uint32, keyLen uint32, val uint32, valLen
var (
addWordSize uint64 = 0
deleteWordSize uint64 = 0
resetWordSize uint64 = 0
resetWordSize uint64
)

if newWordSize >= oldWordSize {
Expand Down Expand Up @@ -1814,7 +1812,7 @@ func Ripemd160(proc *exec.Process, inputPtr, inputLen uint32, outputPtr uint32)
if err != nil {
panic(err)
}
ripemd := ripemd160.New()
ripemd := sha256.New()
ripemd.Write(input)
output := ripemd.Sum(nil)
proc.WriteAt(output, int64(outputPtr))
Expand Down Expand Up @@ -1910,7 +1908,7 @@ func RlpU128Size(proc *exec.Process, heigh uint64, low uint64) uint32 {
ctx := proc.HostCtx().(*VMContext)
checkGas(ctx, GasQuickStep)

var size uint32 = 0
var size uint32
if (0 == heigh && 0 == low) || (0 == heigh && low < rlpDataImmLenStart) {
size = 1
} else {
Expand Down
6 changes: 2 additions & 4 deletions core/vm/wagon_runtime_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ import (

"github.com/PlatONnetwork/PlatON-Go/params"

"golang.org/x/crypto/ripemd160"

"github.com/PlatONnetwork/PlatON-Go/core/types"

"github.com/PlatONnetwork/PlatON-Go/rlp"
Expand Down Expand Up @@ -976,10 +974,10 @@ var testCase = []*Case{
},
{
ctx: &VMContext{},
funcName: "platon_ripemd160_test",
funcName: "platon_sha256_test",
check: func(self *Case, err error) bool {
input := []byte{1, 2, 3}
rip := ripemd160.New()
rip := sha256.New()
rip.Write(input)
h160 := rip.Sum(nil)
return bytes.Equal(h160[:], self.ctx.Output)
Expand Down
2 changes: 1 addition & 1 deletion core/vm/wasm_engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func TestWasmRun(t *testing.T) {
assert.Nil(t, ret)

// bad call for empty input
buf = callData(t, "add_message")
//buf = callData(t, "add_message")
engine.contract.DeployContract = false
ret, err = engine.Run(nil, false)
assert.Nil(t, err)
Expand Down
10 changes: 0 additions & 10 deletions tests/init_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -161,16 +161,6 @@ func (tm *testMatcher) findSkip(name string) (reason string, skipload bool) {
return "", false
}

// findConfig returns the chain config matching defined patterns.
func (tm *testMatcher) findConfig(t *testing.T) *params.ChainConfig {
for _, m := range tm.configpat {
if m.p.MatchString(t.Name()) {
return &m.config
}
}
return new(params.ChainConfig)
}

// checkFailure checks whether a failure is expected.
func (tm *testMatcher) checkFailure(t *testing.T, err error) error {
failReason := ""
Expand Down
2 changes: 1 addition & 1 deletion trie/trie_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,7 @@ func TestDeepCopy(t *testing.T) {
}

//root, _ = tr2.Commit(nil)
root = tr2.Hash()
//root = tr2.Hash()

cpy := tr2.New().New()

Expand Down
Loading
Loading