Skip to content

Commit

Permalink
Support go-lint with PR (#398)
Browse files Browse the repository at this point in the history
* Support go-lint with PR

* Test bcs/consensus/single

* Test kernel/engines/xuperos/xtoken

* Remind task by TODO
  • Loading branch information
zhugelianglongming authored Jan 9, 2023
1 parent a2ac387 commit 71a80d4
Show file tree
Hide file tree
Showing 4 changed files with 38 additions and 5 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/golangci-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# see: https://github.com/golangci/golangci-lint-action
name: golangci-lint
on:
push:
tags:
- v*
branches:
- master
- main
pull_request:
permissions:
contents: read
jobs:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v3
with:
go-version: 1.17
- uses: actions/checkout@v3
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
# TODO: 扩大 go-lint 检查范围
working-directory: kernel/engines/xuperos/xtoken
2 changes: 1 addition & 1 deletion bcs/consensus/single/single.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ func (s *SingleConsensus) CheckMinerMatch(ctx xcontext.XContext, block cctx.Bloc
return false, err
}
chkResult, _ := s.ctx.Crypto.VerifyAddressUsingPublicKey(string(block.GetProposer()), k)
if chkResult == false {
if !chkResult {
ctx.GetLog().Warn("Single::CheckMinerMatch::address is not match publickey")
return false, err
}
Expand Down
12 changes: 9 additions & 3 deletions bcs/consensus/single/single_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,15 @@ func TestNewSingleConsensus(t *testing.T) {
if i := NewSingleConsensus(*cCtx, getWrongConsensusConf()); i != nil {
t.Error("NewSingleConsensus check name error")
}
i.Stop()
i.Start()
i.ProcessBeforeMiner(0, time.Now().UnixNano())
if err := i.Stop(); err != nil {
t.Fatal(err)
}
if err := i.Start(); err != nil {
t.Fatal(err)
}
if _, _, err := i.ProcessBeforeMiner(0, time.Now().UnixNano()); err != nil {
t.Fatal(err)
}
cCtx.XLog = nil
i = NewSingleConsensus(*cCtx, conf)
if i != nil {
Expand Down
2 changes: 1 addition & 1 deletion kernel/engines/xuperos/xtoken/README.md
Original file line number Diff line number Diff line change
@@ -1 +1 @@
XToken 系统合约主要功能分为两部分:创建ERC20标准的代币,和支持提案投票功能。
XToken 系统合约主要功能分为两部分:创建ERC20标准的代币,和支持提案投票功能。

0 comments on commit 71a80d4

Please sign in to comment.