ci: use usetesting instead of tenv
This commit is contained in:
parent
24ed0b5066
commit
9cf23e7ea1
|
@ -25,7 +25,7 @@ linters:
|
|||
- gocheckcompilerdirectives
|
||||
- reassign
|
||||
- mirror
|
||||
- tenv
|
||||
- usetesting
|
||||
### linters we tried and will not be using:
|
||||
###
|
||||
# - structcheck # lots of false positives
|
||||
|
|
|
@ -16,7 +16,7 @@ archives are published at https://geth.ethereum.org/downloads/.
|
|||
|
||||
For prerequisites and detailed build instructions please read the [Installation Instructions](https://geth.ethereum.org/docs/getting-started/installing-geth).
|
||||
|
||||
Building `geth` requires both a Go (version 1.22 or later) and a C compiler. You can install
|
||||
Building `geth` requires both a Go (version 1.23 or later) and a C compiler. You can install
|
||||
them using your favourite package manager. Once the dependencies are installed, run
|
||||
|
||||
```shell
|
||||
|
|
|
@ -57,13 +57,7 @@ func TestMain(m *testing.M) {
|
|||
// This method creates a temporary keystore folder which will be removed after
|
||||
// the test exits.
|
||||
func runClef(t *testing.T, args ...string) *testproc {
|
||||
ddir, err := os.MkdirTemp("", "cleftest-*")
|
||||
if err != nil {
|
||||
return nil
|
||||
}
|
||||
t.Cleanup(func() {
|
||||
os.RemoveAll(ddir)
|
||||
})
|
||||
ddir := t.TempDir()
|
||||
return runWithKeystore(t, ddir, args...)
|
||||
}
|
||||
|
||||
|
|
|
@ -87,11 +87,7 @@ func TestHistoryImportAndExport(t *testing.T) {
|
|||
}
|
||||
|
||||
// Make temp directory for era files.
|
||||
dir, err := os.MkdirTemp("", "history-export-test")
|
||||
if err != nil {
|
||||
t.Fatalf("error creating temp test directory: %v", err)
|
||||
}
|
||||
defer os.RemoveAll(dir)
|
||||
dir := t.TempDir()
|
||||
|
||||
// Export history to temp directory.
|
||||
if err := ExportHistory(chain, dir, 0, count, step); err != nil {
|
||||
|
|
|
@ -21,6 +21,7 @@ import (
|
|||
"crypto/ecdsa"
|
||||
"crypto/sha256"
|
||||
"errors"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
|
@ -452,8 +453,7 @@ func TestOpenDrops(t *testing.T) {
|
|||
//log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
|
||||
|
||||
// Create a temporary folder for the persistent backend
|
||||
storage, _ := os.MkdirTemp("", "blobpool-")
|
||||
defer os.RemoveAll(storage)
|
||||
storage := t.TempDir()
|
||||
|
||||
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
|
||||
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(testMaxBlobsPerBlock), nil)
|
||||
|
@ -775,8 +775,7 @@ func TestOpenIndex(t *testing.T) {
|
|||
//log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
|
||||
|
||||
// Create a temporary folder for the persistent backend
|
||||
storage, _ := os.MkdirTemp("", "blobpool-")
|
||||
defer os.RemoveAll(storage)
|
||||
storage := t.TempDir()
|
||||
|
||||
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
|
||||
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(testMaxBlobsPerBlock), nil)
|
||||
|
@ -864,8 +863,7 @@ func TestOpenHeap(t *testing.T) {
|
|||
//log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
|
||||
|
||||
// Create a temporary folder for the persistent backend
|
||||
storage, _ := os.MkdirTemp("", "blobpool-")
|
||||
defer os.RemoveAll(storage)
|
||||
storage := t.TempDir()
|
||||
|
||||
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
|
||||
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(testMaxBlobsPerBlock), nil)
|
||||
|
@ -951,8 +949,7 @@ func TestOpenCap(t *testing.T) {
|
|||
//log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
|
||||
|
||||
// Create a temporary folder for the persistent backend
|
||||
storage, _ := os.MkdirTemp("", "blobpool-")
|
||||
defer os.RemoveAll(storage)
|
||||
storage := t.TempDir()
|
||||
|
||||
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
|
||||
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(testMaxBlobsPerBlock), nil)
|
||||
|
@ -1041,8 +1038,7 @@ func TestChangingSlotterSize(t *testing.T) {
|
|||
//log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, true)))
|
||||
|
||||
// Create a temporary folder for the persistent backend
|
||||
storage, _ := os.MkdirTemp("", "blobpool-")
|
||||
defer os.RemoveAll(storage)
|
||||
storage := t.TempDir()
|
||||
|
||||
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
|
||||
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(6), nil)
|
||||
|
@ -1508,8 +1504,7 @@ func TestAdd(t *testing.T) {
|
|||
}
|
||||
for i, tt := range tests {
|
||||
// Create a temporary folder for the persistent backend
|
||||
storage, _ := os.MkdirTemp("", "blobpool-")
|
||||
defer os.RemoveAll(storage) // late defer, still ok
|
||||
storage := filepath.Join(t.TempDir(), fmt.Sprintf("test-%d", i))
|
||||
|
||||
os.MkdirAll(filepath.Join(storage, pendingTransactionStore), 0700)
|
||||
store, _ := billy.Open(billy.Options{Path: filepath.Join(storage, pendingTransactionStore)}, newSlotter(testMaxBlobsPerBlock), nil)
|
||||
|
|
|
@ -181,7 +181,7 @@ func TestLoadECDSA(t *testing.T) {
|
|||
}
|
||||
|
||||
for _, test := range tests {
|
||||
f, err := os.CreateTemp("", "loadecdsa_test.*.txt")
|
||||
f, err := os.CreateTemp(t.TempDir(), "loadecdsa_test.*.txt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
@ -202,7 +202,7 @@ func TestLoadECDSA(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSaveECDSA(t *testing.T) {
|
||||
f, err := os.CreateTemp("", "saveecdsa_test.*.txt")
|
||||
f, err := os.CreateTemp(t.TempDir(), "saveecdsa_test.*.txt")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
|
|
|
@ -33,11 +33,10 @@ var (
|
|||
)
|
||||
|
||||
func TestSignify(t *testing.T) {
|
||||
tmpFile, err := os.CreateTemp("", "")
|
||||
tmpFile, err := os.CreateTemp(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name())
|
||||
defer tmpFile.Close()
|
||||
|
||||
data := make([]byte, 1024)
|
||||
|
@ -52,7 +51,6 @@ func TestSignify(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name() + ".sig")
|
||||
|
||||
// Verify the signature using a golang library
|
||||
sig, err := minisign.NewSignatureFromFile(tmpFile.Name() + ".sig")
|
||||
|
@ -75,11 +73,10 @@ func TestSignify(t *testing.T) {
|
|||
}
|
||||
|
||||
func TestSignifyTrustedCommentTooManyLines(t *testing.T) {
|
||||
tmpFile, err := os.CreateTemp("", "")
|
||||
tmpFile, err := os.CreateTemp(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name())
|
||||
defer tmpFile.Close()
|
||||
|
||||
data := make([]byte, 1024)
|
||||
|
@ -94,15 +91,13 @@ func TestSignifyTrustedCommentTooManyLines(t *testing.T) {
|
|||
if err == nil || err.Error() == "" {
|
||||
t.Fatalf("should have errored on a multi-line trusted comment, got %v", err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name() + ".sig")
|
||||
}
|
||||
|
||||
func TestSignifyTrustedCommentTooManyLinesLF(t *testing.T) {
|
||||
tmpFile, err := os.CreateTemp("", "")
|
||||
tmpFile, err := os.CreateTemp(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name())
|
||||
defer tmpFile.Close()
|
||||
|
||||
data := make([]byte, 1024)
|
||||
|
@ -117,15 +112,13 @@ func TestSignifyTrustedCommentTooManyLinesLF(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name() + ".sig")
|
||||
}
|
||||
|
||||
func TestSignifyTrustedCommentEmpty(t *testing.T) {
|
||||
tmpFile, err := os.CreateTemp("", "")
|
||||
tmpFile, err := os.CreateTemp(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name())
|
||||
defer tmpFile.Close()
|
||||
|
||||
data := make([]byte, 1024)
|
||||
|
@ -140,5 +133,4 @@ func TestSignifyTrustedCommentEmpty(t *testing.T) {
|
|||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
defer os.Remove(tmpFile.Name() + ".sig")
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ func TestEra1Builder(t *testing.T) {
|
|||
t.Parallel()
|
||||
|
||||
// Get temp directory.
|
||||
f, err := os.CreateTemp("", "era1-test")
|
||||
f, err := os.CreateTemp(t.TempDir(), "era1-test")
|
||||
if err != nil {
|
||||
t.Fatalf("error creating temp file: %v", err)
|
||||
}
|
||||
|
|
|
@ -53,13 +53,12 @@ func TestDatadirCreation(t *testing.T) {
|
|||
t.Fatalf("freshly created datadir not accessible: %v", err)
|
||||
}
|
||||
// Verify that an impossible datadir fails creation
|
||||
file, err := os.CreateTemp("", "")
|
||||
file, err := os.CreateTemp(t.TempDir(), "")
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create temporary file: %v", err)
|
||||
}
|
||||
defer func() {
|
||||
file.Close()
|
||||
os.Remove(file.Name())
|
||||
}()
|
||||
|
||||
dir = filepath.Join(file.Name(), "invalid/path")
|
||||
|
|
Loading…
Reference in New Issue