]> Cypherpunks repositories - gostls13.git/commitdiff
crypto,hash: add t.Helper calls to test helpers
authorapocelipes <seve3r@outlook.com>
Wed, 14 Aug 2024 03:49:33 +0000 (03:49 +0000)
committerGopher Robot <gobot@golang.org>
Thu, 15 Aug 2024 20:19:52 +0000 (20:19 +0000)
Use t.Helper to make the reported failure lines more helpful.

Change-Id: I6593924b3892b2441a197aee4e05f71ea236d426
GitHub-Last-Rev: 2e020ea85cf44c6cc0e90cb919eb0d7bb5a1c315
GitHub-Pull-Request: golang/go#68843
Reviewed-on: https://go-review.googlesource.com/c/go/+/604755
Auto-Submit: Ian Lance Taylor <iant@google.com>
Reviewed-by: Ian Lance Taylor <iant@google.com>
Reviewed-by: Carlos Amedee <carlos@golang.org>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>

src/crypto/dsa/dsa_test.go
src/crypto/internal/hpke/hpke_test.go
src/crypto/tls/tls_test.go
src/crypto/x509/boring_test.go
src/crypto/x509/oid_test.go
src/crypto/x509/x509_test.go
src/hash/maphash/smhasher_test.go

index 28ac00e6ce69340d756680af624ec0544466d8f4..ad85eac0a7f0b1182bc5c0077c091523464e34fa 100644 (file)
@@ -24,6 +24,7 @@ func testSignAndVerify(t *testing.T, i int, priv *PrivateKey) {
 }
 
 func testParameterGeneration(t *testing.T, sizes ParameterSizes, L, N int) {
+       t.Helper()
        var priv PrivateKey
        params := &priv.Parameters
 
index 69db53bc92ad22bde4ae81fdbaad8f84c8a7b4a0..dbdfd7a80a327fa64660d3eff0d8dea4fb06de40 100644 (file)
@@ -19,6 +19,7 @@ import (
 )
 
 func mustDecodeHex(t *testing.T, in string) []byte {
+       t.Helper()
        b, err := hex.DecodeString(in)
        if err != nil {
                t.Fatal(err)
index fc5040635fbbf7b9b8151f36559cbfe13d1afccb..a6c03361e92f7e0e4de6356c12ca6b6055661aa0 100644 (file)
@@ -163,6 +163,7 @@ func TestX509MixedKeyPair(t *testing.T) {
 }
 
 func newLocalListener(t testing.TB) net.Listener {
+       t.Helper()
        ln, err := net.Listen("tcp", "127.0.0.1:0")
        if err != nil {
                ln, err = net.Listen("tcp6", "[::1]:0")
index 33fd0ed52b1ff62b800b2ab5be8ca28627c75085..319ac61f49c994af2dba49b1d8639c2ba9378246 100644 (file)
@@ -27,6 +27,7 @@ const (
 )
 
 func boringRSAKey(t *testing.T, size int) *rsa.PrivateKey {
+       t.Helper()
        k, err := rsa.GenerateKey(rand.Reader, size)
        if err != nil {
                t.Fatal(err)
@@ -35,6 +36,7 @@ func boringRSAKey(t *testing.T, size int) *rsa.PrivateKey {
 }
 
 func boringECDSAKey(t *testing.T, curve elliptic.Curve) *ecdsa.PrivateKey {
+       t.Helper()
        k, err := ecdsa.GenerateKey(curve, rand.Reader)
        if err != nil {
                t.Fatal(err)
index 270dca0bb5866363e2babac0b47f1d9751e4fbfd..4d5803d4273b84b0a584e7f4bbf0cc3e9e1295fa 100644 (file)
@@ -320,6 +320,7 @@ func BenchmarkOIDMarshalUnmarshalText(b *testing.B) {
 }
 
 func mustNewOIDFromInts(t testing.TB, ints []uint64) OID {
+       t.Helper()
        oid, err := OIDFromInts(ints)
        if err != nil {
                t.Fatalf("OIDFromInts(%v) unexpected error: %v", ints, err)
index 351fe6ad186b14c3409cae7462732697676cbab2..37553c5127b83749df4bdedd10390c0fb8f6110e 100644 (file)
@@ -1472,6 +1472,7 @@ func TestCreateCertificateRequest(t *testing.T) {
 }
 
 func marshalAndParseCSR(t *testing.T, template *CertificateRequest) *CertificateRequest {
+       t.Helper()
        derBytes, err := CreateCertificateRequest(rand.Reader, template, testPrivateKey)
        if err != nil {
                t.Fatal(err)
@@ -1636,6 +1637,7 @@ func TestCriticalFlagInCSRRequestedExtensions(t *testing.T) {
 // serialiseAndParse generates a self-signed certificate from template and
 // returns a parsed version of it.
 func serialiseAndParse(t *testing.T, template *Certificate) *Certificate {
+       t.Helper()
        derBytes, err := CreateCertificate(rand.Reader, template, template, &testPrivateKey.PublicKey, testPrivateKey)
        if err != nil {
                t.Fatalf("failed to create certificate: %s", err)
index b17ef794f7a7bd9c42d5f0dabe65ea799a23e5a1..b9621b4c4f32d8d42cc705ae099758d0f61e34ae 100644 (file)
@@ -96,6 +96,7 @@ func (s *hashSet) addS_seed(x string, seed Seed) {
        s.add(h.Sum64())
 }
 func (s *hashSet) check(t *testing.T) {
+       t.Helper()
        list := s.list
        slices.Sort(list)
 
@@ -259,6 +260,7 @@ func TestSmhasherSparse(t *testing.T) {
        sparse(t, h, 2048, 2)
 }
 func sparse(t *testing.T, h *hashSet, n int, k int) {
+       t.Helper()
        b := make([]byte, n/8)
        setbits(h, b, 0, k)
        h.check(t)
@@ -295,6 +297,7 @@ func TestSmhasherPermutation(t *testing.T) {
        permutation(t, h, []uint32{0, 1, 2, 3, 4, 5, 6, 7, 1 << 29, 2 << 29, 3 << 29, 4 << 29, 5 << 29, 6 << 29, 7 << 29}, 6)
 }
 func permutation(t *testing.T, h *hashSet, s []uint32, n int) {
+       t.Helper()
        b := make([]byte, n*4)
        genPerm(h, b, s, 0)
        h.check(t)
@@ -362,6 +365,7 @@ func TestSmhasherAvalanche(t *testing.T) {
        avalancheTest1(t, &bytesKey{make([]byte, 200)})
 }
 func avalancheTest1(t *testing.T, k key) {
+       t.Helper()
        const REP = 100000
        r := rand.New(rand.NewSource(1234))
        n := k.bits()
@@ -456,6 +460,7 @@ func TestSmhasherText(t *testing.T) {
        text(t, h, "", "FooBar")
 }
 func text(t *testing.T, h *hashSet, prefix, suffix string) {
+       t.Helper()
        const N = 4
        const S = "ABCDEFGHIJKLMNOPQRSTabcdefghijklmnopqrst0123456789"
        const L = len(S)