diff --git a/.travis.yml b/.travis.yml index 8a97bcd35e..a2cec08157 100644 --- a/.travis.yml +++ b/.travis.yml @@ -13,8 +13,7 @@ matrix: - sudo chown root:$USER /etc/fuse.conf - go run build/ci.go install - go run build/ci.go test -coverage - - make install-linters - - make lint + - go run build/ci.go lint # These are the latest Go versions. - os: linux diff --git a/Makefile b/Makefile index a13fe497ba..325f7241c4 100644 --- a/Makefile +++ b/Makefile @@ -38,15 +38,9 @@ test: all build/env.sh go run build/ci.go test lint: ## Run linters. Use make install-linters first. - vendorcheck ./... - 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 ./... + build/env.sh go run build/ci.go lint -install-linters: ## Install linters - 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). +format: # Formats the code. Must have goimports installed goimports -w -local github.com/ethereum/go-ethereum ./ clean: diff --git a/build/ci.go b/build/ci.go index 1881a596e9..f74f0a902a 100644 --- a/build/ci.go +++ b/build/ci.go @@ -324,12 +324,17 @@ func doLint(cmdline []string) { } // Get metalinter and install all supported linters 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") // Run fast linters batched together configs := []string{ "--vendor", "--disable-all", + "--enable=goimports", + "--enable=varcheck", "--enable=vet", "--enable=gofmt", "--enable=misspell", @@ -340,7 +345,7 @@ func doLint(cmdline []string) { // Run slow linters one by one 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...)...) } } diff --git a/crypto/bn256/cloudflare/constants.go b/crypto/bn256/cloudflare/constants.go index 97874bb760..5122aae64f 100644 --- a/crypto/bn256/cloudflare/constants.go +++ b/crypto/bn256/cloudflare/constants.go @@ -26,7 +26,7 @@ var P = bigFromBase10("218882428718392752222464057452572750886963111572978236626 var p2 = [4]uint64{0x3c208c16d87cfd47, 0x97816a916871ca8d, 0xb85045b68181585d, 0x30644e72e131a029} // 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. var rN1 = &gfP{0xed84884a014afa37, 0xeb2022850278edf8, 0xcf63e9cfb74492d9, 0x2e67157159e5c639} diff --git a/crypto/bn256/cloudflare/example_test.go b/crypto/bn256/cloudflare/example_test.go index b2d19807a2..6c285995cb 100644 --- a/crypto/bn256/cloudflare/example_test.go +++ b/crypto/bn256/cloudflare/example_test.go @@ -6,9 +6,12 @@ package bn256 import ( "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 // Round Protocol for Tripartite Diffie-Hellman", A. Joux. // http://www.springerlink.com/content/cddc57yyva0hburb/fulltext.pdf @@ -40,4 +43,9 @@ func ExamplePair() { k3.ScalarMult(k3, c) // 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 }