mirror of
https://github.com/libp2p/go-libp2p-core.git
synced 2025-02-04 05:40:10 +08:00
stop using the deprecated io/ioutil package
This commit is contained in:
parent
35ab42caf0
commit
7a84a95eea
@ -5,7 +5,7 @@ import (
|
|||||||
"crypto/rand"
|
"crypto/rand"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"io/ioutil"
|
"os"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
"github.com/libp2p/go-libp2p-core/crypto"
|
"github.com/libp2p/go-libp2p-core/crypto"
|
||||||
@ -46,15 +46,15 @@ func fname(kt crypto_pb.KeyType, ext string) string {
|
|||||||
func TestFixtures(t *testing.T) {
|
func TestFixtures(t *testing.T) {
|
||||||
for _, tc := range keyTypes {
|
for _, tc := range keyTypes {
|
||||||
t.Run(tc.keyType.String(), func(t *testing.T) {
|
t.Run(tc.keyType.String(), func(t *testing.T) {
|
||||||
pubBytes, err := ioutil.ReadFile(fname(tc.keyType, "pub"))
|
pubBytes, err := os.ReadFile(fname(tc.keyType, "pub"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
privBytes, err := ioutil.ReadFile(fname(tc.keyType, "priv"))
|
privBytes, err := os.ReadFile(fname(tc.keyType, "priv"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
sigBytes, err := ioutil.ReadFile(fname(tc.keyType, "sig"))
|
sigBytes, err := os.ReadFile(fname(tc.keyType, "sig"))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
@ -125,8 +125,8 @@ func generate() {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
ioutil.WriteFile(fname(tc.keyType, "pub"), pubb, 0666)
|
os.WriteFile(fname(tc.keyType, "pub"), pubb, 0666)
|
||||||
ioutil.WriteFile(fname(tc.keyType, "priv"), privb, 0666)
|
os.WriteFile(fname(tc.keyType, "priv"), privb, 0666)
|
||||||
ioutil.WriteFile(fname(tc.keyType, "sig"), sig, 0666)
|
os.WriteFile(fname(tc.keyType, "sig"), sig, 0666)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user