From be5432620a20717086401bae5b7b5052c2e1ee45 Mon Sep 17 00:00:00 2001 From: Rod Vagg Date: Mon, 29 Jul 2024 14:17:58 +1000 Subject: [PATCH] chore!: bump go version to 1.21, fix staticcheck errors --- bls_test.go | 4 +--- go.mod | 2 +- proofs_test.go | 4 ++-- sector_update.go | 18 ------------------ workflows.go | 11 +++++------ 5 files changed, 9 insertions(+), 30 deletions(-) diff --git a/bls_test.go b/bls_test.go index 13634258..50c2cedf 100644 --- a/bls_test.go +++ b/bls_test.go @@ -1,8 +1,8 @@ package ffi import ( + "crypto/rand" "fmt" - "math/rand" "testing" "time" @@ -11,8 +11,6 @@ import ( ) func TestDeterministicPrivateKeyGeneration(t *testing.T) { - rand.Seed(time.Now().UnixNano()) - for i := 0; i < 10000; i++ { var xs [32]byte n, err := rand.Read(xs[:]) diff --git a/go.mod b/go.mod index c5649679..b6bdf0f8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/filecoin-project/filecoin-ffi -go 1.18 +go 1.21 require ( github.com/filecoin-project/go-address v1.1.0 diff --git a/proofs_test.go b/proofs_test.go index da396c5b..7bf7702f 100644 --- a/proofs_test.go +++ b/proofs_test.go @@ -4,8 +4,8 @@ import ( "bytes" "crypto/rand" "io" - "io/ioutil" "math/big" + "os" "testing" commcid "github.com/filecoin-project/go-fil-commcid" @@ -76,7 +76,7 @@ func TestDoesNotExhaustFileDescriptors(t *testing.T) { for i := 0; i < m; i++ { // create a temporary file over which we'll compute CommP - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") if err != nil { panic(err) } diff --git a/sector_update.go b/sector_update.go index c4926728..3913b3e8 100644 --- a/sector_update.go +++ b/sector_update.go @@ -30,24 +30,6 @@ func toFilRegisteredUpdateProof(p abi.RegisteredUpdateProof) (cgo.RegisteredUpda } } -//nolint:deadcode,unused -func fromFilRegisteredUpdateProof(p cgo.RegisteredUpdateProof) (abi.RegisteredUpdateProof, error) { - switch p { - case cgo.RegisteredUpdateProofStackedDrg2KiBV1: - return abi.RegisteredUpdateProof_StackedDrg2KiBV1, nil - case cgo.RegisteredUpdateProofStackedDrg8MiBV1: - return abi.RegisteredUpdateProof_StackedDrg8MiBV1, nil - case cgo.RegisteredUpdateProofStackedDrg512MiBV1: - return abi.RegisteredUpdateProof_StackedDrg512MiBV1, nil - case cgo.RegisteredUpdateProofStackedDrg32GiBV1: - return abi.RegisteredUpdateProof_StackedDrg32GiBV1, nil - case cgo.RegisteredUpdateProofStackedDrg64GiBV1: - return abi.RegisteredUpdateProof_StackedDrg64GiBV1, nil - default: - return 0, errors.Errorf("no mapping to abi.RegisteredUpdateProof value available for: %v", p) - } -} - type FunctionsSectorUpdate struct{} var SectorUpdate = FunctionsSectorUpdate{} diff --git a/workflows.go b/workflows.go index fde97ae7..bf0a7b3e 100644 --- a/workflows.go +++ b/workflows.go @@ -9,7 +9,6 @@ import ( "encoding/binary" "fmt" "io" - "io/ioutil" "math" "math/big" "os" @@ -161,7 +160,7 @@ func WorkflowProofsLifecycle(t TestHelper) { t.RequireNoError(Unseal(sealProofType, sectorCacheDirPath, sealedSectorFile, unsealOutputFileA, sectorNum, minerID, ticket, unsealedCID)) _, err = unsealOutputFileA.Seek(0, 0) t.RequireNoError(err) - contents, err := ioutil.ReadFile(unsealOutputFileA.Name()) + contents, err := os.ReadFile(unsealOutputFileA.Name()) t.RequireNoError(err) // unsealed sector includes a bunch of alignment NUL-bytes @@ -179,7 +178,7 @@ func WorkflowProofsLifecycle(t TestHelper) { t.RequireNoError(err) _, err = unsealOutputFileB.Seek(0, 0) t.RequireNoError(err) - contentsB, err := ioutil.ReadFile(unsealOutputFileB.Name()) + contentsB, err := os.ReadFile(unsealOutputFileB.Name()) t.RequireNoError(err) t.AssertEqual(127, len(contentsB)) t.AssertTrue(bytes.Equal(someBytes[0:127], contentsB[0:127]), "bytes aren't equal") @@ -191,7 +190,7 @@ func WorkflowProofsLifecycle(t TestHelper) { t.RequireNoError(err) _, err = unsealOutputFileC.Seek(0, 0) t.RequireNoError(err) - contentsC, err := ioutil.ReadFile(unsealOutputFileC.Name()) + contentsC, err := os.ReadFile(unsealOutputFileC.Name()) t.RequireNoError(err) t.AssertEqual(1016, len(contentsC)) t.AssertTrue(bytes.Equal(someBytes[0:1016], contentsC[0:1016]), "bytes aren't equal") @@ -369,7 +368,7 @@ func randUInt64() uint64 { } func requireTempFile(t TestHelper, fileContentsReader io.Reader, size uint64) *os.File { - file, err := ioutil.TempFile("", "") + file, err := os.CreateTemp("", "") t.RequireNoError(err) written, err := io.Copy(file, fileContentsReader) @@ -387,7 +386,7 @@ func requireTempFile(t TestHelper, fileContentsReader io.Reader, size uint64) *o } func requireTempDirPath(t TestHelper, prefix string) string { - dir, err := ioutil.TempDir("", prefix) + dir, err := os.MkdirTemp("", prefix) t.RequireNoError(err) return dir