mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-18 09:53:48 +00:00
add varcheck
add vendorcheck add goimports add lint coverage on tests example_test turned into actual test add small check on np const to avoid lint varcheck err update travis task to use lint remove lint task contents from makefile
This commit is contained in:
parent
c41a7cc5fa
commit
9671bfcaa0
5 changed files with 19 additions and 13 deletions
|
|
@ -13,8 +13,7 @@ matrix:
|
||||||
- sudo chown root:$USER /etc/fuse.conf
|
- sudo chown root:$USER /etc/fuse.conf
|
||||||
- go run build/ci.go install
|
- go run build/ci.go install
|
||||||
- go run build/ci.go test -coverage
|
- go run build/ci.go test -coverage
|
||||||
- make install-linters
|
- go run build/ci.go lint
|
||||||
- make lint
|
|
||||||
|
|
||||||
# These are the latest Go versions.
|
# These are the latest Go versions.
|
||||||
- os: linux
|
- os: linux
|
||||||
|
|
|
||||||
10
Makefile
10
Makefile
|
|
@ -38,15 +38,9 @@ test: all
|
||||||
build/env.sh go run build/ci.go test
|
build/env.sh go run build/ci.go test
|
||||||
|
|
||||||
lint: ## Run linters. Use make install-linters first.
|
lint: ## Run linters. Use make install-linters first.
|
||||||
vendorcheck ./...
|
build/env.sh go run build/ci.go lint
|
||||||
gometalinter --disable-all -E vet -E goimports -E varcheck -E gofmt -E misspell -E goconst -E unconvert -E gosimple --deadline=10m --min-occurrences=6 --tests --vendor ./...
|
|
||||||
|
|
||||||
install-linters: ## Install linters
|
format: # Formats the code. Must have goimports installed
|
||||||
go get -u github.com/FiloSottile/vendorcheck
|
|
||||||
go get -u github.com/alecthomas/gometalinter
|
|
||||||
gometalinter --vendored-linters --install
|
|
||||||
|
|
||||||
format: # Formats the code. Must have goimports installed (use make install-linters).
|
|
||||||
goimports -w -local github.com/ethereum/go-ethereum ./
|
goimports -w -local github.com/ethereum/go-ethereum ./
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
||||||
|
|
@ -324,12 +324,17 @@ func doLint(cmdline []string) {
|
||||||
}
|
}
|
||||||
// Get metalinter and install all supported linters
|
// Get metalinter and install all supported linters
|
||||||
build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v2"))
|
build.MustRun(goTool("get", "gopkg.in/alecthomas/gometalinter.v2"))
|
||||||
|
build.MustRun(goTool("get", "github.com/FiloSottile/vendorcheck"))
|
||||||
|
|
||||||
|
build.MustRunCommand(filepath.Join(GOBIN, "vendorcheck"), "./...")
|
||||||
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), "--install")
|
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), "--install")
|
||||||
|
|
||||||
// Run fast linters batched together
|
// Run fast linters batched together
|
||||||
configs := []string{
|
configs := []string{
|
||||||
"--vendor",
|
"--vendor",
|
||||||
"--disable-all",
|
"--disable-all",
|
||||||
|
"--enable=goimports",
|
||||||
|
"--enable=varcheck",
|
||||||
"--enable=vet",
|
"--enable=vet",
|
||||||
"--enable=gofmt",
|
"--enable=gofmt",
|
||||||
"--enable=misspell",
|
"--enable=misspell",
|
||||||
|
|
@ -340,7 +345,7 @@ func doLint(cmdline []string) {
|
||||||
|
|
||||||
// Run slow linters one by one
|
// Run slow linters one by one
|
||||||
for _, linter := range []string{"unconvert", "gosimple"} {
|
for _, linter := range []string{"unconvert", "gosimple"} {
|
||||||
configs = []string{"--vendor", "--deadline=10m", "--disable-all", "--enable=" + linter}
|
configs = []string{"--vendor", "--tests", "--deadline=10m", "--disable-all", "--enable=" + linter}
|
||||||
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...)
|
build.MustRunCommand(filepath.Join(GOBIN, "gometalinter.v2"), append(configs, packages...)...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ var P = bigFromBase10("218882428718392752222464057452572750886963111572978236626
|
||||||
var p2 = [4]uint64{0x3c208c16d87cfd47, 0x97816a916871ca8d, 0xb85045b68181585d, 0x30644e72e131a029}
|
var p2 = [4]uint64{0x3c208c16d87cfd47, 0x97816a916871ca8d, 0xb85045b68181585d, 0x30644e72e131a029}
|
||||||
|
|
||||||
// np is the negative inverse of p, mod 2^256.
|
// np is the negative inverse of p, mod 2^256.
|
||||||
//var np = [4]uint64{0x87d20782e4866389, 0x9ede7d651eca6ac9, 0xd8afcbd01833da80, 0xf57a22b791888c6b}
|
var np = [4]uint64{0x87d20782e4866389, 0x9ede7d651eca6ac9, 0xd8afcbd01833da80, 0xf57a22b791888c6b}
|
||||||
|
|
||||||
// rN1 is R^-1 where R = 2^256 mod p.
|
// rN1 is R^-1 where R = 2^256 mod p.
|
||||||
var rN1 = &gfP{0xed84884a014afa37, 0xeb2022850278edf8, 0xcf63e9cfb74492d9, 0x2e67157159e5c639}
|
var rN1 = &gfP{0xed84884a014afa37, 0xeb2022850278edf8, 0xcf63e9cfb74492d9, 0x2e67157159e5c639}
|
||||||
|
|
|
||||||
|
|
@ -6,9 +6,12 @@ package bn256
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/require"
|
||||||
)
|
)
|
||||||
|
|
||||||
func ExamplePair() {
|
func TestExamplePair(t *testing.T) {
|
||||||
// This implements the tripartite Diffie-Hellman algorithm from "A One
|
// This implements the tripartite Diffie-Hellman algorithm from "A One
|
||||||
// Round Protocol for Tripartite Diffie-Hellman", A. Joux.
|
// Round Protocol for Tripartite Diffie-Hellman", A. Joux.
|
||||||
// http://www.springerlink.com/content/cddc57yyva0hburb/fulltext.pdf
|
// http://www.springerlink.com/content/cddc57yyva0hburb/fulltext.pdf
|
||||||
|
|
@ -40,4 +43,9 @@ func ExamplePair() {
|
||||||
k3.ScalarMult(k3, c)
|
k3.ScalarMult(k3, c)
|
||||||
|
|
||||||
// k1, k2 and k3 will all be equal.
|
// k1, k2 and k3 will all be equal.
|
||||||
|
|
||||||
|
require.Equal(t, k1, k2)
|
||||||
|
require.Equal(t, k1, k3)
|
||||||
|
|
||||||
|
require.Equal(t, len(np), 4) //Avoid gometalinter varcheck err on np
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue