Merge pull request #2369 from nspcc-dev/goshechka

*: go 1.18 support 🎉😍🎊🍰🥂
This commit is contained in:
Roman Khimov 2022-03-18 15:07:20 +03:00 committed by GitHub
commit 906d99571b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
66 changed files with 303 additions and 268 deletions

View file

@ -1,19 +1,17 @@
version: 2.1 version: 2.1
executors: executors:
go1_15:
docker:
- image: circleci/golang:1.15
environment:
GO111MODULE: "on"
go1_16: go1_16:
docker: docker:
- image: circleci/golang:1.16 - image: cimg/go:1.16
environment: environment:
GO111MODULE: "on" GO111MODULE: "on"
go1_17: go1_17:
docker: docker:
- image: circleci/golang:1.17 - image: cimg/go:1.17
go1_18:
docker:
- image: cimg/go:1.18
commands: commands:
gomod: gomod:
@ -25,11 +23,12 @@ commands:
command: go mod download command: go mod download
- save_cache: - save_cache:
key: deps-{{ checksum "go.sum" }}-{{ checksum "go.sum" }} key: deps-{{ checksum "go.sum" }}-{{ checksum "go.sum" }}
paths: [/go/pkg/mod] paths: [/home/circleci/go/pkg/mod]
jobs: jobs:
lint: lint:
working_directory: /go/src/github.com/nspcc-dev/neo-go working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
# TODO: temp workaround, need to upgrade to go1_18 after https://github.com/golangci/golangci-lint/issues/2649 is resolved.
executor: go1_17 executor: go1_17
steps: steps:
- checkout - checkout
@ -37,21 +36,11 @@ jobs:
- run: - run:
name: go-lint name: go-lint
command: | command: |
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.42.1 curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.44.2
make lint make lint
test_1_15:
working_directory: /go/src/github.com/nspcc-dev/neo-go
executor: go1_15
steps:
- checkout
- run: git submodule sync
- run: git submodule update --init
- gomod
- run: go test -v -race ./...
test_1_16: test_1_16:
working_directory: /go/src/github.com/nspcc-dev/neo-go working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
executor: go1_16 executor: go1_16
steps: steps:
- checkout - checkout
@ -60,9 +49,29 @@ jobs:
- gomod - gomod
- run: go test -v -race ./... - run: go test -v -race ./...
build_cli: test_1_17:
working_directory: /go/src/github.com/nspcc-dev/neo-go working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
executor: go1_17 executor: go1_17
steps:
- checkout
- run: git submodule sync
- run: git submodule update --init
- gomod
- run: go test -v -race ./...
test_1_18:
working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
executor: go1_18
steps:
- checkout
- run: git submodule sync
- run: git submodule update --init
- gomod
- run: go test -v -race ./...
build_cli:
working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
executor: go1_18
steps: steps:
- checkout - checkout
- gomod - gomod
@ -72,8 +81,8 @@ jobs:
destination: / destination: /
build_image: build_image:
working_directory: /go/src/github.com/nspcc-dev/neo-go working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
executor: go1_17 executor: go1_18
docker: docker:
- image: golang:1-alpine - image: golang:1-alpine
steps: steps:
@ -101,11 +110,15 @@ workflows:
filters: filters:
tags: tags:
only: v/[0-9]+\.[0-9]+\.[0-9]+/ only: v/[0-9]+\.[0-9]+\.[0-9]+/
- test_1_15: - test_1_16:
filters: filters:
tags: tags:
only: v/[0-9]+\.[0-9]+\.[0-9]+/ only: v/[0-9]+\.[0-9]+\.[0-9]+/
- test_1_16: - test_1_17:
filters:
tags:
only: v/[0-9]+\.[0-9]+\.[0-9]+/
- test_1_18:
filters: filters:
tags: tags:
only: v/[0-9]+\.[0-9]+\.[0-9]+/ only: v/[0-9]+\.[0-9]+\.[0-9]+/

View file

@ -33,7 +33,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.17 go-version: 1.18
- name: Restore Go modules from cache - name: Restore Go modules from cache
uses: actions/cache@v2 uses: actions/cache@v2
@ -67,7 +67,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.17 go-version: 1.18
- name: Restore Go modules from cache - name: Restore Go modules from cache
uses: actions/cache@v2 uses: actions/cache@v2
@ -99,6 +99,12 @@ jobs:
ref: ${{ github.event.inputs.ref }} ref: ${{ github.event.inputs.ref }}
fetch-depth: 0 fetch-depth: 0
# For proper `deps` make target execution.
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Build Docker image - name: Build Docker image
run: make image run: make image
@ -113,5 +119,11 @@ jobs:
ref: ${{ github.event.inputs.ref }} ref: ${{ github.event.inputs.ref }}
fetch-depth: 0 fetch-depth: 0
# For proper `deps` make target execution.
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.18
- name: Build Docker image - name: Build Docker image
run: make image-wsc run: make image-wsc

View file

@ -48,7 +48,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.17 go-version: 1.18
- name: Restore go modules from cache - name: Restore go modules from cache
uses: actions/cache@v2 uses: actions/cache@v2
@ -113,7 +113,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.17 go-version: 1.18
- name: Restore go modules from cache - name: Restore go modules from cache
uses: actions/cache@v2 uses: actions/cache@v2

View file

@ -56,7 +56,7 @@ jobs:
- name: Set up Go - name: Set up Go
uses: actions/setup-go@v2 uses: actions/setup-go@v2
with: with:
go-version: 1.17 go-version: 1.18
- name: Restore Go modules from cache - name: Restore Go modules from cache
uses: actions/cache@v2 uses: actions/cache@v2
@ -83,14 +83,16 @@ jobs:
strategy: strategy:
matrix: matrix:
os: [ubuntu-20.04, windows-2022] os: [ubuntu-20.04, windows-2022]
go_versions: [ '1.15', '1.16', '1.17' ] go_versions: [ '1.16', '1.17', '1.18' ]
exclude: exclude:
- os: windows-2022 # Only latest Go version for Windows.
go_versions: '1.15'
- os: windows-2022 - os: windows-2022
go_versions: '1.16' go_versions: '1.16'
- os: ubuntu-20.04 - os: windows-2022
go_versions: '1.17' go_versions: '1.17'
# Exclude latest Go version for Ubuntu as Coverage uses it.
- os: ubuntu-20.04
go_versions: '1.18'
fail-fast: false fail-fast: false
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2

View file

@ -1,5 +1,9 @@
# Builder image # Builder image
FROM golang:1-alpine as builder # Keep go version in sync with Build GA job.
FROM golang:1.18-alpine as builder
# Display go version for information purposes.
RUN go version
RUN set -x \ RUN set -x \
&& apk add --no-cache git make \ && apk add --no-cache git make \

View file

@ -11,15 +11,65 @@ ENV GIT_DOWNLOAD_URL=https://github.com/git-for-windows/git/releases/download/v2
ENV GIT_DOWNLOAD_SHA256=8f65208f92c0b4c3ae4c0cf02d4b5f6791d539cd1a07b2df62b7116467724735 ENV GIT_DOWNLOAD_SHA256=8f65208f92c0b4c3ae4c0cf02d4b5f6791d539cd1a07b2df62b7116467724735
RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri $env:GIT_DOWNLOAD_URL -OutFile 'git.zip'; Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); if ((Get-FileHash git.zip -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { Write-Host 'FAILED!'; exit 1; }; Write-Host 'Expanding ...'; Expand-Archive -Path git.zip -DestinationPath C:\git\.; Write-Host 'Removing ...'; Remove-Item git.zip -Force; Write-Host 'Updating PATH ...'; $env:PATH = 'C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin;' + $env:PATH; [Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); Write-Host 'Verifying install ("git version") ...'; git version; Write-Host 'Complete.'; RUN Write-Host ('Downloading {0} ...' -f $env:GIT_DOWNLOAD_URL); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $env:GIT_DOWNLOAD_URL -OutFile 'git.zip'; \
\
Write-Host ('Verifying sha256 ({0}) ...' -f $env:GIT_DOWNLOAD_SHA256); \
if ((Get-FileHash git.zip -Algorithm sha256).Hash -ne $env:GIT_DOWNLOAD_SHA256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
\
Write-Host 'Expanding ...'; \
Expand-Archive -Path git.zip -DestinationPath C:\git\.; \
\
Write-Host 'Removing ...'; \
Remove-Item git.zip -Force; \
\
Write-Host 'Updating PATH ...'; \
$env:PATH = 'C:\git\cmd;C:\git\mingw64\bin;C:\git\usr\bin;' + $env:PATH; \
[Environment]::SetEnvironmentVariable('PATH', $env:PATH, [EnvironmentVariableTarget]::Machine); \
\
Write-Host 'Verifying install ("git version") ...'; \
git version; \
\
Write-Host 'Complete.';
ENV GOPATH=C:\\go ENV GOPATH=C:\\go
RUN $newPath = ('{0}\bin;C:\Program Files\Go\bin;{1}' -f $env:GOPATH, $env:PATH); Write-Host ('Updating PATH: {0}' -f $newPath); [Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine); RUN $newPath = ('{0}\bin;C:\Program Files\Go\bin;{1}' -f $env:GOPATH, $env:PATH); \
Write-Host ('Updating PATH: {0}' -f $newPath); \
[Environment]::SetEnvironmentVariable('PATH', $newPath, [EnvironmentVariableTarget]::Machine);
ENV GOLANG_VERSION=1.17.6 # Keep go version in sync with Build GA job.
ENV GOLANG_VERSION=1.18
RUN $url = 'https://dl.google.com/go/go1.17.6.windows-amd64.zip'; Write-Host ('Downloading {0} ...' -f $url); [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; Invoke-WebRequest -Uri $url -OutFile 'go.zip'; $sha256 = '5bf8f87aec7edfc08e6bc845f1c30dba6de32b863f89ae46553ff4bbcc1d4954'; Write-Host ('Verifying sha256 ({0}) ...' -f $sha256); if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $sha256) { Write-Host 'FAILED!'; exit 1; }; Write-Host 'Expanding ...'; Expand-Archive go.zip -DestinationPath C:\; Write-Host 'Moving ...'; Move-Item -Path C:\go -Destination 'C:\Program Files\Go'; Write-Host 'Removing ...'; Remove-Item go.zip -Force; Write-Host 'Verifying install ("go version") ...'; go version; Write-Host 'Complete.'; RUN $url = 'https://dl.google.com/go/go1.18.windows-amd64.zip'; \
Write-Host ('Downloading {0} ...' -f $url); \
[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12; \
Invoke-WebRequest -Uri $url -OutFile 'go.zip'; \
\
$sha256 = '65c5c0c709a7ca1b357091b10b795b439d8b50e579d3893edab4c7e9b384f435'; \
Write-Host ('Verifying sha256 ({0}) ...' -f $sha256); \
if ((Get-FileHash go.zip -Algorithm sha256).Hash -ne $sha256) { \
Write-Host 'FAILED!'; \
exit 1; \
}; \
\
Write-Host 'Expanding ...'; \
Expand-Archive go.zip -DestinationPath C:\; \
\
Write-Host 'Moving ...'; \
Move-Item -Path C:\go -Destination 'C:\Program Files\Go'; \
\
Write-Host 'Removing ...'; \
Remove-Item go.zip -Force; \
\
Write-Host 'Verifying install ("go version") ...'; \
go version; \
\
Write-Host 'Complete.';
COPY . /neo-go COPY . /neo-go

View file

@ -48,7 +48,7 @@ NeoGo, `:latest` points to the latest release) or build yourself.
### Building ### Building
To build NeoGo you need Go 1.15+ and `make`: To build NeoGo you need Go 1.16+ and `make`:
``` ```
make build make build

View file

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -35,12 +34,12 @@ func TestCalcHash(t *testing.T) {
e := newExecutor(t, false) e := newExecutor(t, false)
nefPath := "./testdata/verify.nef" nefPath := "./testdata/verify.nef"
src, err := ioutil.ReadFile(nefPath) src, err := os.ReadFile(nefPath)
require.NoError(t, err) require.NoError(t, err)
nefF, err := nef.FileFromBytes(src) nefF, err := nef.FileFromBytes(src)
require.NoError(t, err) require.NoError(t, err)
manifestPath := "./testdata/verify.manifest.json" manifestPath := "./testdata/verify.manifest.json"
manifestBytes, err := ioutil.ReadFile(manifestPath) manifestBytes, err := os.ReadFile(manifestPath)
require.NoError(t, err) require.NoError(t, err)
manif := &manifest.Manifest{} manif := &manifest.Manifest{}
err = json.Unmarshal(manifestBytes, manif) err = json.Unmarshal(manifestBytes, manif)
@ -67,12 +66,12 @@ func TestCalcHash(t *testing.T) {
}) })
t.Run("invalid nef file", func(t *testing.T) { t.Run("invalid nef file", func(t *testing.T) {
p := filepath.Join(tmpDir, "neogo.calchash.verify.nef") p := filepath.Join(tmpDir, "neogo.calchash.verify.nef")
require.NoError(t, ioutil.WriteFile(p, src[:4], os.ModePerm)) require.NoError(t, os.WriteFile(p, src[:4], os.ModePerm))
e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", p, "--manifest", manifestPath)...) e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", p, "--manifest", manifestPath)...)
}) })
t.Run("invalid manifest file", func(t *testing.T) { t.Run("invalid manifest file", func(t *testing.T) {
p := filepath.Join(tmpDir, "neogo.calchash.verify.manifest.json") p := filepath.Join(tmpDir, "neogo.calchash.verify.manifest.json")
require.NoError(t, ioutil.WriteFile(p, manifestBytes[:4], os.ModePerm)) require.NoError(t, os.WriteFile(p, manifestBytes[:4], os.ModePerm))
e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", nefPath, "--manifest", p)...) e.RunWithError(t, append(cmd, "--sender", sender.StringLE(), "--in", nefPath, "--manifest", p)...)
}) })
@ -106,7 +105,7 @@ func TestContractBindings(t *testing.T) {
e.Run(t, "neo-go", "contract", "init", "--name", ctrPath) e.Run(t, "neo-go", "contract", "init", "--name", ctrPath)
srcPath := filepath.Join(ctrPath, "main.go") srcPath := filepath.Join(ctrPath, "main.go")
require.NoError(t, ioutil.WriteFile(srcPath, []byte(`package testcontract require.NoError(t, os.WriteFile(srcPath, []byte(`package testcontract
import( import(
alias "github.com/nspcc-dev/neo-go/pkg/interop/native/ledger" alias "github.com/nspcc-dev/neo-go/pkg/interop/native/ledger"
) )
@ -140,7 +139,7 @@ func Blocks() []*alias.Block {
// Replace `pkg/interop` in go.mod to avoid getting an actual module version. // Replace `pkg/interop` in go.mod to avoid getting an actual module version.
goMod := filepath.Join(ctrPath, "go.mod") goMod := filepath.Join(ctrPath, "go.mod")
data, err := ioutil.ReadFile(goMod) data, err := os.ReadFile(goMod)
require.NoError(t, err) require.NoError(t, err)
i := bytes.IndexByte(data, '\n') i := bytes.IndexByte(data, '\n')
@ -150,7 +149,7 @@ func Blocks() []*alias.Block {
require.NoError(t, err) require.NoError(t, err)
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...) data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...)
data = append(data, filepath.Join(wd, "../pkg/interop")...) data = append(data, filepath.Join(wd, "../pkg/interop")...)
require.NoError(t, ioutil.WriteFile(goMod, data, os.ModePerm)) require.NoError(t, os.WriteFile(goMod, data, os.ModePerm))
cmd = append(cmd, "--config", cfgPath, cmd = append(cmd, "--config", cfgPath,
"--out", filepath.Join(tmpDir, "out.nef"), "--out", filepath.Join(tmpDir, "out.nef"),
@ -165,7 +164,7 @@ func Blocks() []*alias.Block {
"--config", bindingsPath, "--manifest", manifestPath, "--config", bindingsPath, "--manifest", manifestPath,
"--out", outPath, "--hash", "0x0123456789987654321001234567899876543210") "--out", outPath, "--hash", "0x0123456789987654321001234567899876543210")
bs, err := ioutil.ReadFile(outPath) bs, err := os.ReadFile(outPath)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, `// Package testcontract contains wrappers for testcontract contract. require.Equal(t, `// Package testcontract contains wrappers for testcontract contract.
package testcontract package testcontract
@ -244,23 +243,23 @@ func TestContractInitAndCompile(t *testing.T) {
e.RunWithError(t, append(cmd, "--config", cfgName)...) e.RunWithError(t, append(cmd, "--config", cfgName)...)
}) })
t.Run("provided corrupted config", func(t *testing.T) { t.Run("provided corrupted config", func(t *testing.T) {
data, err := ioutil.ReadFile(cfgPath) data, err := os.ReadFile(cfgPath)
require.NoError(t, err) require.NoError(t, err)
badCfg := filepath.Join(tmpDir, "bad.yml") badCfg := filepath.Join(tmpDir, "bad.yml")
require.NoError(t, ioutil.WriteFile(badCfg, data[:len(data)-5], os.ModePerm)) require.NoError(t, os.WriteFile(badCfg, data[:len(data)-5], os.ModePerm))
e.RunWithError(t, append(cmd, "--config", badCfg)...) e.RunWithError(t, append(cmd, "--config", badCfg)...)
}) })
// Replace `pkg/interop` in go.mod to avoid getting an actual module version. // Replace `pkg/interop` in go.mod to avoid getting an actual module version.
goMod := filepath.Join(ctrPath, "go.mod") goMod := filepath.Join(ctrPath, "go.mod")
data, err := ioutil.ReadFile(goMod) data, err := os.ReadFile(goMod)
require.NoError(t, err) require.NoError(t, err)
wd, err := os.Getwd() wd, err := os.Getwd()
require.NoError(t, err) require.NoError(t, err)
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...) data = append(data, "\nreplace github.com/nspcc-dev/neo-go/pkg/interop => "...)
data = append(data, filepath.Join(wd, "../pkg/interop")...) data = append(data, filepath.Join(wd, "../pkg/interop")...)
require.NoError(t, ioutil.WriteFile(goMod, data, os.ModePerm)) require.NoError(t, os.WriteFile(goMod, data, os.ModePerm))
cmd = append(cmd, "--config", cfgPath) cmd = append(cmd, "--config", cfgPath)
e.Run(t, cmd...) e.Run(t, cmd...)
@ -481,7 +480,7 @@ func TestContractManifestGroups(t *testing.T) {
}) })
t.Run("corrupted NEF file", func(t *testing.T) { t.Run("corrupted NEF file", func(t *testing.T) {
f := filepath.Join(tmpDir, "invalid.nef") f := filepath.Join(tmpDir, "invalid.nef")
require.NoError(t, ioutil.WriteFile(f, []byte{1, 2, 3}, os.ModePerm)) require.NoError(t, os.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group", e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
"--wallet", testWalletPath, "--account", testWalletAccount, "--wallet", testWalletPath, "--account", testWalletAccount,
"--sender", testWalletAccount, "--nef", f) "--sender", testWalletAccount, "--nef", f)
@ -494,7 +493,7 @@ func TestContractManifestGroups(t *testing.T) {
}) })
t.Run("corrupted manifest file", func(t *testing.T) { t.Run("corrupted manifest file", func(t *testing.T) {
f := filepath.Join(tmpDir, "invalid.manifest.json") f := filepath.Join(tmpDir, "invalid.manifest.json")
require.NoError(t, ioutil.WriteFile(f, []byte{1, 2, 3}, os.ModePerm)) require.NoError(t, os.WriteFile(f, []byte{1, 2, 3}, os.ModePerm))
e.RunWithError(t, "neo-go", "contract", "manifest", "add-group", e.RunWithError(t, "neo-go", "contract", "manifest", "add-group",
"--wallet", testWalletPath, "--account", testWalletAccount, "--wallet", testWalletPath, "--account", testWalletAccount,
"--sender", testWalletAccount, "--nef", nefName, "--sender", testWalletAccount, "--nef", nefName,
@ -573,7 +572,7 @@ func TestContract_TestInvokeScript(t *testing.T) {
"--in", badNef) "--in", badNef)
}) })
t.Run("invalid nef", func(t *testing.T) { t.Run("invalid nef", func(t *testing.T) {
require.NoError(t, ioutil.WriteFile(badNef, []byte("qwer"), os.ModePerm)) require.NoError(t, os.WriteFile(badNef, []byte("qwer"), os.ModePerm))
e.RunWithError(t, "neo-go", "contract", "testinvokescript", e.RunWithError(t, "neo-go", "contract", "testinvokescript",
"--rpc-endpoint", "http://"+e.RPC.Addr, "--rpc-endpoint", "http://"+e.RPC.Addr,
"--in", badNef) "--in", badNef)
@ -689,10 +688,9 @@ func TestComlileAndInvokeFunction(t *testing.T) {
e.RunWithError(t, cmd...) e.RunWithError(t, cmd...)
}) })
t.Run("corrupted wallet", func(t *testing.T) { t.Run("corrupted wallet", func(t *testing.T) {
tmp, err := ioutil.TempDir("", "tmp") tmp := t.TempDir()
require.NoError(t, err)
tmpPath := filepath.Join(tmp, "wallet.json") tmpPath := filepath.Join(tmp, "wallet.json")
require.NoError(t, ioutil.WriteFile(tmpPath, []byte("{"), os.ModePerm)) require.NoError(t, os.WriteFile(tmpPath, []byte("{"), os.ModePerm))
cmd := append(cmd, "--wallet", tmpPath, cmd := append(cmd, "--wallet", tmpPath,
h.StringLE(), "getValue") h.StringLE(), "getValue")
@ -854,9 +852,9 @@ func TestComlileAndInvokeFunction(t *testing.T) {
os.Remove(manifestName) os.Remove(manifestName)
}) })
rawNef, err := ioutil.ReadFile(nefName) rawNef, err := os.ReadFile(nefName)
require.NoError(t, err) require.NoError(t, err)
rawManifest, err := ioutil.ReadFile(manifestName) rawManifest, err := os.ReadFile(manifestName)
require.NoError(t, err) require.NoError(t, err)
e.In.WriteString("one\r") e.In.WriteString("one\r")
@ -918,7 +916,7 @@ func TestContractInspect(t *testing.T) {
func TestCompileExamples(t *testing.T) { func TestCompileExamples(t *testing.T) {
tmpDir := t.TempDir() tmpDir := t.TempDir()
const examplePath = "../examples" const examplePath = "../examples"
infos, err := ioutil.ReadDir(examplePath) infos, err := os.ReadDir(examplePath)
require.NoError(t, err) require.NoError(t, err)
// For proper nef generation. // For proper nef generation.
@ -933,7 +931,7 @@ func TestCompileExamples(t *testing.T) {
continue continue
} }
t.Run(info.Name(), func(t *testing.T) { t.Run(info.Name(), func(t *testing.T) {
infos, err := ioutil.ReadDir(filepath.Join(examplePath, info.Name())) infos, err := os.ReadDir(filepath.Join(examplePath, info.Name()))
require.NoError(t, err) require.NoError(t, err)
require.False(t, len(infos) == 0, "detected smart contract folder with no contract in it") require.False(t, len(infos) == 0, "detected smart contract folder with no contract in it")
@ -951,7 +949,7 @@ func TestCompileExamples(t *testing.T) {
e.Run(t, opts...) e.Run(t, opts...)
if info.Name() == "storage" { if info.Name() == "storage" {
rawM, err := ioutil.ReadFile(manifestF) rawM, err := os.ReadFile(manifestF)
require.NoError(t, err) require.NoError(t, err)
m := new(manifest.Manifest) m := new(manifest.Manifest)
@ -983,7 +981,7 @@ func TestCompileExamples(t *testing.T) {
}) })
} }
func filterFilename(infos []os.FileInfo, ext string) string { func filterFilename(infos []os.DirEntry, ext string) string {
for _, info := range infos { for _, info := range infos {
if !info.IsDir() { if !info.IsDir() {
name := info.Name() name := info.Name()

View file

@ -1,7 +1,6 @@
package main package main
import ( import (
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strconv" "strconv"
@ -29,7 +28,7 @@ func TestDBRestoreDump(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml") cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml")
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm)) require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
// generated via `go run ./scripts/gendump/main.go --out ./cli/testdata/chain50x2.acc --blocks 50 --txs 2` // generated via `go run ./scripts/gendump/main.go --out ./cli/testdata/chain50x2.acc --blocks 50 --txs 2`
const inDump = "./testdata/chain50x2.acc" const inDump = "./testdata/chain50x2.acc"
@ -61,14 +60,14 @@ func TestDBRestoreDump(t *testing.T) {
t.Run("bad logger config", func(t *testing.T) { t.Run("bad logger config", func(t *testing.T) {
badConfigDir := t.TempDir() badConfigDir := t.TempDir()
logfile := filepath.Join(badConfigDir, "logdir") logfile := filepath.Join(badConfigDir, "logdir")
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm)) require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
cfg = loadConfig(t) cfg = loadConfig(t)
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log") cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
out, err = yaml.Marshal(cfg) out, err = yaml.Marshal(cfg)
require.NoError(t, err) require.NoError(t, err)
cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml") cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml")
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm)) require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
e.RunWithError(t, "neo-go", "db", "dump", "--unittest", e.RunWithError(t, "neo-go", "db", "dump", "--unittest",
"--config-path", badConfigDir, "--out", dumpPath) "--config-path", badConfigDir, "--out", dumpPath)
@ -76,14 +75,14 @@ func TestDBRestoreDump(t *testing.T) {
t.Run("bad storage config", func(t *testing.T) { t.Run("bad storage config", func(t *testing.T) {
badConfigDir := t.TempDir() badConfigDir := t.TempDir()
logfile := filepath.Join(badConfigDir, "logdir") logfile := filepath.Join(badConfigDir, "logdir")
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm)) require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
cfg = loadConfig(t) cfg = loadConfig(t)
cfg.ApplicationConfiguration.DBConfiguration.Type = "" cfg.ApplicationConfiguration.DBConfiguration.Type = ""
out, err = yaml.Marshal(cfg) out, err = yaml.Marshal(cfg)
require.NoError(t, err) require.NoError(t, err)
cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml") cfgPath = filepath.Join(badConfigDir, "protocol.unit_testnet.yml")
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm)) require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
e.RunWithError(t, "neo-go", "db", "dump", "--unittest", e.RunWithError(t, "neo-go", "db", "dump", "--unittest",
"--config-path", badConfigDir, "--out", dumpPath) "--config-path", badConfigDir, "--out", dumpPath)
@ -98,9 +97,9 @@ func TestDBRestoreDump(t *testing.T) {
e.Run(t, baseCmd...) e.Run(t, baseCmd...)
d1, err := ioutil.ReadFile(inDump) d1, err := os.ReadFile(inDump)
require.NoError(t, err) require.NoError(t, err)
d2, err := ioutil.ReadFile(dumpPath) d2, err := os.ReadFile(dumpPath)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, d1, d2, "dumps differ") require.Equal(t, d1, d2, "dumps differ")
} }

View file

@ -4,7 +4,6 @@ import (
"bytes" "bytes"
"errors" "errors"
"io" "io"
"io/ioutil"
"math" "math"
"strings" "strings"
"sync" "sync"
@ -269,7 +268,7 @@ func (e *executor) run(args ...string) error {
e.Err.Reset() e.Err.Reset()
input.Terminal = term.NewTerminal(input.ReadWriter{ input.Terminal = term.NewTerminal(input.ReadWriter{
Reader: e.In, Reader: e.In,
Writer: ioutil.Discard, Writer: io.Discard,
}, "") }, "")
err := e.CLI.Run(args) err := e.CLI.Run(args)
input.Terminal = nil input.Terminal = nil

View file

@ -2,7 +2,7 @@ package flags
import ( import (
"flag" "flag"
"io/ioutil" "io"
"testing" "testing"
"github.com/nspcc-dev/neo-go/internal/random" "github.com/nspcc-dev/neo-go/internal/random"
@ -119,7 +119,7 @@ func TestAddressFlag_GetName(t *testing.T) {
func TestAddress(t *testing.T) { func TestAddress(t *testing.T) {
f := flag.NewFlagSet("", flag.ContinueOnError) f := flag.NewFlagSet("", flag.ContinueOnError)
f.SetOutput(ioutil.Discard) // don't pollute test output f.SetOutput(io.Discard) // don't pollute test output
addr := AddressFlag{Name: "addr, a"} addr := AddressFlag{Name: "addr, a"}
addr.Apply(f) addr.Apply(f)
require.NoError(t, f.Parse([]string{"--addr", "NRHkiY2hLy5ypD32CKZtL6pNwhbFMqDEhR"})) require.NoError(t, f.Parse([]string{"--addr", "NRHkiY2hLy5ypD32CKZtL6pNwhbFMqDEhR"}))

View file

@ -2,7 +2,7 @@ package flags
import ( import (
"flag" "flag"
"io/ioutil" "io"
"testing" "testing"
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn" "github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
@ -55,7 +55,7 @@ func TestFixed8Flag_GetName(t *testing.T) {
func TestFixed8(t *testing.T) { func TestFixed8(t *testing.T) {
f := flag.NewFlagSet("", flag.ContinueOnError) f := flag.NewFlagSet("", flag.ContinueOnError)
f.SetOutput(ioutil.Discard) // don't pollute test output f.SetOutput(io.Discard) // don't pollute test output
gas := Fixed8Flag{Name: "gas, g"} gas := Fixed8Flag{Name: "gas, g"}
gas.Apply(f) gas.Apply(f)
require.NoError(t, f.Parse([]string{"--gas", "0.123"})) require.NoError(t, f.Parse([]string{"--gas", "0.123"}))

View file

@ -7,8 +7,8 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/big" "math/big"
"os"
"path/filepath" "path/filepath"
"strconv" "strconv"
"testing" "testing"
@ -104,10 +104,10 @@ func TestNEP11_ND_OwnerOf_BalanceOf_Transfer(t *testing.T) {
tmpDir := t.TempDir() tmpDir := t.TempDir()
// copy wallet to temp dir in order not to overwrite the original file // copy wallet to temp dir in order not to overwrite the original file
bytesRead, err := ioutil.ReadFile(nftOwnerWallet) bytesRead, err := os.ReadFile(nftOwnerWallet)
require.NoError(t, err) require.NoError(t, err)
wall := filepath.Join(tmpDir, "my_wallet.json") wall := filepath.Join(tmpDir, "my_wallet.json")
err = ioutil.WriteFile(wall, bytesRead, 0755) err = os.WriteFile(wall, bytesRead, 0755)
require.NoError(t, err) require.NoError(t, err)
// transfer funds to contract owner // transfer funds to contract owner
@ -336,10 +336,10 @@ func TestNEP11_D_OwnerOf_BalanceOf_Transfer(t *testing.T) {
tmpDir := t.TempDir() tmpDir := t.TempDir()
// copy wallet to temp dir in order not to overwrite the original file // copy wallet to temp dir in order not to overwrite the original file
bytesRead, err := ioutil.ReadFile(validatorWallet) bytesRead, err := os.ReadFile(validatorWallet)
require.NoError(t, err) require.NoError(t, err)
wall := filepath.Join(tmpDir, "my_wallet.json") wall := filepath.Join(tmpDir, "my_wallet.json")
err = ioutil.WriteFile(wall, bytesRead, 0755) err = os.WriteFile(wall, bytesRead, 0755)
require.NoError(t, err) require.NoError(t, err)
// deploy NeoFS Object contract // deploy NeoFS Object contract

View file

@ -3,7 +3,7 @@ package paramcontext
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "os"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
"github.com/nspcc-dev/neo-go/pkg/core/transaction" "github.com/nspcc-dev/neo-go/pkg/core/transaction"
@ -36,7 +36,7 @@ func InitAndSave(net netmode.Magic, tx *transaction.Transaction, acc *wallet.Acc
// Read reads parameter context from file. // Read reads parameter context from file.
func Read(filename string) (*context.ParameterContext, error) { func Read(filename string) (*context.ParameterContext, error) {
data, err := ioutil.ReadFile(filename) data, err := os.ReadFile(filename)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't read input file: %w", err) return nil, fmt.Errorf("can't read input file: %w", err)
} }
@ -52,7 +52,7 @@ func Read(filename string) (*context.ParameterContext, error) {
func Save(c *context.ParameterContext, filename string) error { func Save(c *context.ParameterContext, filename string) error {
if data, err := json.Marshal(c); err != nil { if data, err := json.Marshal(c); err != nil {
return fmt.Errorf("can't marshal transaction: %w", err) return fmt.Errorf("can't marshal transaction: %w", err)
} else if err := ioutil.WriteFile(filename, data, 0644); err != nil { } else if err := os.WriteFile(filename, data, 0644); err != nil {
return fmt.Errorf("can't write transaction to file: %w", err) return fmt.Errorf("can't write transaction to file: %w", err)
} }
return nil return nil

View file

@ -3,7 +3,6 @@ package server
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
@ -63,7 +62,7 @@ func (d *dump) tryPersist(prefix string, index uint32) error {
} }
func readFile(path string) (*dump, error) { func readFile(path string) (*dump, error) {
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -3,7 +3,6 @@ package server
import ( import (
"encoding/binary" "encoding/binary"
"flag" "flag"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -46,7 +45,7 @@ func TestHandleLoggingParams(t *testing.T) {
t.Run("logdir is a file", func(t *testing.T) { t.Run("logdir is a file", func(t *testing.T) {
logfile := filepath.Join(d, "logdir") logfile := filepath.Join(d, "logdir")
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm)) require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
set := flag.NewFlagSet("flagSet", flag.ExitOnError) set := flag.NewFlagSet("flagSet", flag.ExitOnError)
ctx := cli.NewContext(cli.NewApp(), set, nil) ctx := cli.NewContext(cli.NewApp(), set, nil)
cfg := config.ApplicationConfiguration{ cfg := config.ApplicationConfiguration{
@ -196,7 +195,7 @@ func TestRestoreDB(t *testing.T) {
t.Run("invalid logger path", func(t *testing.T) { t.Run("invalid logger path", func(t *testing.T) {
badCfgDir := t.TempDir() badCfgDir := t.TempDir()
logfile := filepath.Join(badCfgDir, "logdir") logfile := filepath.Join(badCfgDir, "logdir")
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm)) require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
cfg, err := config.LoadFile(filepath.Join(goodCfg, "protocol.privnet.yml")) cfg, err := config.LoadFile(filepath.Join(goodCfg, "protocol.privnet.yml"))
require.NoError(t, err, "could not load config") require.NoError(t, err, "could not load config")
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log") cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
@ -204,7 +203,7 @@ func TestRestoreDB(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml") badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml")
require.NoError(t, ioutil.WriteFile(badCfgPath, out, os.ModePerm)) require.NoError(t, os.WriteFile(badCfgPath, out, os.ModePerm))
*cfgPath = badCfgDir *cfgPath = badCfgDir
require.Error(t, restoreDB(ctx)) require.Error(t, restoreDB(ctx))
@ -220,7 +219,7 @@ func TestRestoreDB(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml") badCfgPath := filepath.Join(badCfgDir, "protocol.privnet.yml")
require.NoError(t, ioutil.WriteFile(badCfgPath, out, os.ModePerm)) require.NoError(t, os.WriteFile(badCfgPath, out, os.ModePerm))
*cfgPath = badCfgDir *cfgPath = badCfgDir
require.Error(t, restoreDB(ctx)) require.Error(t, restoreDB(ctx))
@ -238,7 +237,7 @@ func TestRestoreDB(t *testing.T) {
}) })
t.Run("corrupted in: invalid block count", func(t *testing.T) { t.Run("corrupted in: invalid block count", func(t *testing.T) {
inPath := filepath.Join(t.TempDir(), "file3.acc") inPath := filepath.Join(t.TempDir(), "file3.acc")
require.NoError(t, ioutil.WriteFile(inPath, []byte{1, 2, 3}, // file is expected to start from uint32 require.NoError(t, os.WriteFile(inPath, []byte{1, 2, 3}, // file is expected to start from uint32
os.ModePerm)) os.ModePerm))
*in = inPath *in = inPath
require.Error(t, restoreDB(ctx)) require.Error(t, restoreDB(ctx))
@ -247,10 +246,10 @@ func TestRestoreDB(t *testing.T) {
}) })
t.Run("corrupted in: corrupted block", func(t *testing.T) { t.Run("corrupted in: corrupted block", func(t *testing.T) {
inPath := filepath.Join(t.TempDir(), "file3.acc") inPath := filepath.Join(t.TempDir(), "file3.acc")
b, err := ioutil.ReadFile(testDump) b, err := os.ReadFile(testDump)
require.NoError(t, err) require.NoError(t, err)
b[5] = 0xff // file is expected to start from uint32 (4 bytes) followed by the first block, so corrupt the first block bytes b[5] = 0xff // file is expected to start from uint32 (4 bytes) followed by the first block, so corrupt the first block bytes
require.NoError(t, ioutil.WriteFile(inPath, b, os.ModePerm)) require.NoError(t, os.WriteFile(inPath, b, os.ModePerm))
*in = inPath *in = inPath
require.Error(t, restoreDB(ctx)) require.Error(t, restoreDB(ctx))
@ -258,12 +257,12 @@ func TestRestoreDB(t *testing.T) {
}) })
t.Run("incremental dump", func(t *testing.T) { t.Run("incremental dump", func(t *testing.T) {
inPath := filepath.Join(t.TempDir(), "file1_incremental.acc") inPath := filepath.Join(t.TempDir(), "file1_incremental.acc")
b, err := ioutil.ReadFile(testDump) b, err := os.ReadFile(testDump)
require.NoError(t, err) require.NoError(t, err)
start := make([]byte, 4) start := make([]byte, 4)
t.Run("good", func(t *testing.T) { t.Run("good", func(t *testing.T) {
binary.LittleEndian.PutUint32(start, 1) // start from the first block binary.LittleEndian.PutUint32(start, 1) // start from the first block
require.NoError(t, ioutil.WriteFile(inPath, append(start, b...), require.NoError(t, os.WriteFile(inPath, append(start, b...),
os.ModePerm)) os.ModePerm))
*in = inPath *in = inPath
*incremental = true *incremental = true
@ -272,7 +271,7 @@ func TestRestoreDB(t *testing.T) {
}) })
t.Run("dump is too high", func(t *testing.T) { t.Run("dump is too high", func(t *testing.T) {
binary.LittleEndian.PutUint32(start, 2) // start from the second block binary.LittleEndian.PutUint32(start, 2) // start from the second block
require.NoError(t, ioutil.WriteFile(inPath, append(start, b...), require.NoError(t, os.WriteFile(inPath, append(start, b...),
os.ModePerm)) os.ModePerm))
*in = inPath *in = inPath
*incremental = true *incremental = true

View file

@ -2,7 +2,6 @@ package main
import ( import (
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime" "runtime"
@ -31,7 +30,7 @@ func TestServerStart(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml") cfgPath := filepath.Join(tmpDir, "protocol.unit_testnet.yml")
require.NoError(t, ioutil.WriteFile(cfgPath, out, os.ModePerm)) require.NoError(t, os.WriteFile(cfgPath, out, os.ModePerm))
t.Cleanup(func() { t.Cleanup(func() {
require.NoError(t, os.Remove(cfgPath)) require.NoError(t, os.Remove(cfgPath))
}) })
@ -47,7 +46,7 @@ func TestServerStart(t *testing.T) {
t.Run("bad logger config", func(t *testing.T) { t.Run("bad logger config", func(t *testing.T) {
badConfigDir := t.TempDir() badConfigDir := t.TempDir()
logfile := filepath.Join(badConfigDir, "logdir") logfile := filepath.Join(badConfigDir, "logdir")
require.NoError(t, ioutil.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm)) require.NoError(t, os.WriteFile(logfile, []byte{1, 2, 3}, os.ModePerm))
saveCfg(t, func(cfg *config.Config) { saveCfg(t, func(cfg *config.Config) {
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log") cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
}) })

View file

@ -2,7 +2,6 @@ package smartcontract
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"strings" "strings"
@ -47,7 +46,7 @@ func contractGenerateWrapper(ctx *cli.Context) error {
cfg := binding.NewConfig() cfg := binding.NewConfig()
if cfgPath := ctx.String("config"); cfgPath != "" { if cfgPath := ctx.String("config"); cfgPath != "" {
bs, err := ioutil.ReadFile(cfgPath) bs, err := os.ReadFile(cfgPath)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("can't read config file: %w", err), 1) return cli.NewExitError(fmt.Errorf("can't read config file: %w", err), 1)
} }

View file

@ -2,7 +2,6 @@ package smartcontract
import ( import (
"encoding/json" "encoding/json"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -115,7 +114,7 @@ func TestGenerate(t *testing.T) {
rawManifest, err := json.Marshal(m) rawManifest, err := json.Marshal(m)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm)) require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
h := util.Uint160{ h := util.Uint160{
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01, 0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
@ -139,7 +138,7 @@ callflags:
doSomething: ReadStates doSomething: ReadStates
` `
cfgPath := filepath.Join(t.TempDir(), "binding.yml") cfgPath := filepath.Join(t.TempDir(), "binding.yml")
require.NoError(t, ioutil.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm)) require.NoError(t, os.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm))
require.NoError(t, app.Run([]string{"", "generate-wrapper", require.NoError(t, app.Run([]string{"", "generate-wrapper",
"--manifest", manifestFile, "--manifest", manifestFile,
@ -225,7 +224,7 @@ func MyFunc(in map[int]mycontract.Input) []mycontract.Output {
} }
` `
data, err := ioutil.ReadFile(outFile) data, err := os.ReadFile(outFile)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, expected, string(data)) require.Equal(t, expected, string(data))
} }
@ -245,7 +244,7 @@ func TestGenerateValidPackageName(t *testing.T) {
rawManifest, err := json.Marshal(m) rawManifest, err := json.Marshal(m)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm)) require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
h := util.Uint160{ h := util.Uint160{
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01, 0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
@ -259,7 +258,7 @@ func TestGenerateValidPackageName(t *testing.T) {
"--hash", "0x" + h.StringLE(), "--hash", "0x" + h.StringLE(),
})) }))
data, err := ioutil.ReadFile(outFile) data, err := os.ReadFile(outFile)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, `// Package myspacecontract contains wrappers for My space contract contract. require.Equal(t, `// Package myspacecontract contains wrappers for My space contract contract.
package myspacecontract package myspacecontract
@ -297,7 +296,7 @@ func TestGenerate_Errors(t *testing.T) {
}) })
t.Run("invalid manifest", func(t *testing.T) { t.Run("invalid manifest", func(t *testing.T) {
manifestFile := filepath.Join(t.TempDir(), "invalid.json") manifestFile := filepath.Join(t.TempDir(), "invalid.json")
require.NoError(t, ioutil.WriteFile(manifestFile, []byte("[]"), os.ModePerm)) require.NoError(t, os.WriteFile(manifestFile, []byte("[]"), os.ModePerm))
checkError(t, "", "--manifest", manifestFile) checkError(t, "", "--manifest", manifestFile)
}) })
@ -305,7 +304,7 @@ func TestGenerate_Errors(t *testing.T) {
m := manifest.NewManifest("MyContract") m := manifest.NewManifest("MyContract")
rawManifest, err := json.Marshal(m) rawManifest, err := json.Marshal(m)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm)) require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
t.Run("invalid hash", func(t *testing.T) { t.Run("invalid hash", func(t *testing.T) {
checkError(t, "invalid contract hash", "--manifest", manifestFile, "--hash", "xxx") checkError(t, "invalid contract hash", "--manifest", manifestFile, "--hash", "xxx")
@ -321,7 +320,7 @@ callflags:
someFunc: ReadSometimes someFunc: ReadSometimes
` `
cfgPath := filepath.Join(t.TempDir(), "binding.yml") cfgPath := filepath.Join(t.TempDir(), "binding.yml")
require.NoError(t, ioutil.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm)) require.NoError(t, os.WriteFile(cfgPath, []byte(rawCfg), os.ModePerm))
checkError(t, "can't parse config file", checkError(t, "can't parse config file",
"--manifest", manifestFile, "--hash", util.Uint160{}.StringLE(), "--manifest", manifestFile, "--hash", util.Uint160{}.StringLE(),

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"github.com/nspcc-dev/neo-go/cli/flags" "github.com/nspcc-dev/neo-go/cli/flags"
@ -78,7 +77,7 @@ func manifestAddGroup(ctx *cli.Context) error {
return cli.NewExitError(fmt.Errorf("can't marshal manifest: %w", err), 1) return cli.NewExitError(fmt.Errorf("can't marshal manifest: %w", err), 1)
} }
err = ioutil.WriteFile(mPath, rawM, os.ModePerm) err = os.WriteFile(mPath, rawM, os.ModePerm)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("can't write manifest file: %w", err), 1) return cli.NewExitError(fmt.Errorf("can't write manifest file: %w", err), 1)
} }
@ -90,7 +89,7 @@ func readNEFFile(filename string) (*nef.File, []byte, error) {
return nil, nil, errors.New("no nef file was provided") return nil, nil, errors.New("no nef file was provided")
} }
f, err := ioutil.ReadFile(filename) f, err := os.ReadFile(filename)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }
@ -108,7 +107,7 @@ func readManifest(filename string) (*manifest.Manifest, []byte, error) {
return nil, nil, errNoManifestFile return nil, nil, errNoManifestFile
} }
manifestBytes, err := ioutil.ReadFile(filename) manifestBytes, err := os.ReadFile(filename)
if err != nil { if err != nil {
return nil, nil, err return nil, nil, err
} }

View file

@ -5,7 +5,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -455,7 +454,7 @@ func initSmartContract(ctx *cli.Context) error {
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
if err := ioutil.WriteFile(filepath.Join(basePath, "neo-go.yml"), b, 0644); err != nil { if err := os.WriteFile(filepath.Join(basePath, "neo-go.yml"), b, 0644); err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
@ -468,12 +467,12 @@ func initSmartContract(ctx *cli.Context) error {
require ( require (
github.com/nspcc-dev/neo-go/pkg/interop ` + ver + ` github.com/nspcc-dev/neo-go/pkg/interop ` + ver + `
)`) )`)
if err := ioutil.WriteFile(filepath.Join(basePath, "go.mod"), gm, 0644); err != nil { if err := os.WriteFile(filepath.Join(basePath, "go.mod"), gm, 0644); err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
data := []byte(fmt.Sprintf(smartContractTmpl, contractName)) data := []byte(fmt.Sprintf(smartContractTmpl, contractName))
if err := ioutil.WriteFile(filepath.Join(basePath, fileName), data, 0644); err != nil { if err := os.WriteFile(filepath.Join(basePath, fileName), data, 0644); err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
@ -548,7 +547,7 @@ func calcHash(ctx *cli.Context) error {
if mpath == "" { if mpath == "" {
return cli.NewExitError(errors.New("no manifest file provided"), 1) return cli.NewExitError(errors.New("no manifest file provided"), 1)
} }
f, err := ioutil.ReadFile(p) f, err := os.ReadFile(p)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("can't read .nef file: %w", err), 1) return cli.NewExitError(fmt.Errorf("can't read .nef file: %w", err), 1)
} }
@ -556,7 +555,7 @@ func calcHash(ctx *cli.Context) error {
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("can't unmarshal .nef file: %w", err), 1) return cli.NewExitError(fmt.Errorf("can't unmarshal .nef file: %w", err), 1)
} }
manifestBytes, err := ioutil.ReadFile(mpath) manifestBytes, err := os.ReadFile(mpath)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1) return cli.NewExitError(fmt.Errorf("failed to read manifest file: %w", err), 1)
} }
@ -734,7 +733,7 @@ func testInvokeScript(ctx *cli.Context) error {
return cli.NewExitError(errNoInput, 1) return cli.NewExitError(errNoInput, 1)
} }
b, err := ioutil.ReadFile(src) b, err := os.ReadFile(src)
if err != nil { if err != nil {
return cli.NewExitError(err, 1) return cli.NewExitError(err, 1)
} }
@ -798,7 +797,7 @@ func inspect(ctx *cli.Context) error {
return cli.NewExitError(fmt.Errorf("failed to compile: %w", err), 1) return cli.NewExitError(fmt.Errorf("failed to compile: %w", err), 1)
} }
} else { } else {
f, err := ioutil.ReadFile(in) f, err := os.ReadFile(in)
if err != nil { if err != nil {
return cli.NewExitError(fmt.Errorf("failed to read .nef file: %w", err), 1) return cli.NewExitError(fmt.Errorf("failed to read .nef file: %w", err), 1)
} }
@ -935,7 +934,7 @@ func contractDeploy(ctx *cli.Context) error {
// ParseContractConfig reads contract configuration file (.yaml) and returns unmarshalled ProjectConfig. // ParseContractConfig reads contract configuration file (.yaml) and returns unmarshalled ProjectConfig.
func ParseContractConfig(confFile string) (ProjectConfig, error) { func ParseContractConfig(confFile string) (ProjectConfig, error) {
conf := ProjectConfig{} conf := ProjectConfig{}
confBytes, err := ioutil.ReadFile(confFile) confBytes, err := os.ReadFile(confFile)
if err != nil { if err != nil {
return conf, cli.NewExitError(err, 1) return conf, cli.NewExitError(err, 1)
} }

View file

@ -3,7 +3,6 @@ package smartcontract
import ( import (
"encoding/hex" "encoding/hex"
"flag" "flag"
"io/ioutil"
"os" "os"
"testing" "testing"
@ -31,13 +30,13 @@ func TestInitSmartContract(t *testing.T) {
dirInfo, err := os.Stat(contractName) dirInfo, err := os.Stat(contractName)
require.NoError(t, err) require.NoError(t, err)
require.True(t, dirInfo.IsDir()) require.True(t, dirInfo.IsDir())
files, err := ioutil.ReadDir(contractName) files, err := os.ReadDir(contractName)
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, 3, len(files)) require.Equal(t, 3, len(files))
require.Equal(t, "go.mod", files[0].Name()) require.Equal(t, "go.mod", files[0].Name())
require.Equal(t, "main.go", files[1].Name()) require.Equal(t, "main.go", files[1].Name())
require.Equal(t, "neo-go.yml", files[2].Name()) require.Equal(t, "neo-go.yml", files[2].Name())
main, err := ioutil.ReadFile(contractName + "/" + files[1].Name()) main, err := os.ReadFile(contractName + "/" + files[1].Name())
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, require.Equal(t,
`package `+contractName+` `package `+contractName+`
@ -56,7 +55,7 @@ func RuntimeNotify(args []interface{}) {
runtime.Notify(notificationName, args) runtime.Notify(notificationName, args)
}`, string(main)) }`, string(main))
manifest, err := ioutil.ReadFile(contractName + "/" + files[2].Name()) manifest, err := os.ReadFile(contractName + "/" + files[2].Name())
require.NoError(t, err) require.NoError(t, err)
require.Equal(t, require.Equal(t,
`name: testContract `name: testContract

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/engine
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/events
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/iterator
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -1,5 +1,5 @@
module github.com/nspcc-dev/neo-go/examples/nft module github.com/nspcc-dev/neo-go/examples/nft
go 1.15 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -3,7 +3,7 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd-nns
go 1.16 go 1.16
require ( require (
github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220310092710-5379ef75bbb9 github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220318104433-7a8dc1179138
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b
github.com/stretchr/testify v1.7.0 github.com/stretchr/testify v1.7.0
) )

View file

@ -176,11 +176,10 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg=
github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM=
github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220310092710-5379ef75bbb9 h1:L6cY5S/1ZsH2zDax8sMidue2YpYIjrH5s773DBn+sgs= github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220318104433-7a8dc1179138 h1:r1oOvpba+RM+rAi02tSQhpa1Olhxv7XDJi/p1GyHTmI=
github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220310092710-5379ef75bbb9/go.mod h1:ahEhaTYsPP78ODCXc9J6g364zEsGRlJ3Lg//REhWxaQ= github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220318104433-7a8dc1179138/go.mod h1:/O1Ih5Wmxg+RZgXiM/QRUkeip0Ynf1o5QuWehSIVKgc=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220301152507-4c415683e74e/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/oracle
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/runtime
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/storage
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/timer
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token-sale
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

View file

@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token
go 1.16 go 1.16
require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 require github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b

View file

@ -1,2 +1,2 @@
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=

4
go.mod
View file

@ -11,7 +11,7 @@ require (
github.com/mr-tron/base58 v1.2.0 github.com/mr-tron/base58 v1.2.0
github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac github.com/nspcc-dev/dbft v0.0.0-20210721160347-1b03241391ac
github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22 github.com/nspcc-dev/go-ordered-json v0.0.0-20220111165707-25110be27d22
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b
github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659 github.com/nspcc-dev/neofs-sdk-go v0.0.0-20220113123743-7f3162110659
github.com/nspcc-dev/rfc6979 v0.2.0 github.com/nspcc-dev/rfc6979 v0.2.0
github.com/pierrec/lz4 v2.6.1+incompatible github.com/pierrec/lz4 v2.6.1+incompatible
@ -31,4 +31,4 @@ require (
gopkg.in/yaml.v2 v2.4.0 gopkg.in/yaml.v2 v2.4.0
) )
go 1.15 go 1.16

4
go.sum
View file

@ -182,8 +182,8 @@ github.com/nspcc-dev/hrw v1.0.9 h1:17VcAuTtrstmFppBjfRiia4K2wA/ukXZhLFS8Y8rz5Y=
github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU= github.com/nspcc-dev/hrw v1.0.9/go.mod h1:l/W2vx83vMQo6aStyx2AuZrJ+07lGv2JQGlVkPG06MU=
github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg= github.com/nspcc-dev/neo-go v0.73.1-pre.0.20200303142215-f5a1b928ce09/go.mod h1:pPYwPZ2ks+uMnlRLUyXOpLieaDQSEaf4NM3zHVbRjmg=
github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM= github.com/nspcc-dev/neo-go v0.98.0/go.mod h1:E3cc1x6RXSXrJb2nDWXTXjnXk3rIqVN8YdFyWv+FrqM=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y= github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.0-pre.0.20211201134523-3604d96f3fe1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ=
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs= github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=

View file

@ -9,10 +9,8 @@ import (
"go/token" "go/token"
"go/types" "go/types"
"io" "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"runtime"
"strings" "strings"
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding" "github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
@ -156,24 +154,14 @@ func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
case string: case string:
buf = []byte(s) buf = []byte(s)
case io.Reader: case io.Reader:
buf, err = ioutil.ReadAll(s) buf, err = io.ReadAll(s)
if err != nil { if err != nil {
return nil, err return nil, err
} }
default: default:
panic(fmt.Sprintf("unsupported src type: %T", s)) panic(fmt.Sprintf("unsupported src type: %T", s))
} }
if strings.HasPrefix(runtime.Version(), "go1.15") {
dir, err = ioutil.TempDir("", "*")
if err != nil {
return nil, err
}
name = filepath.Join(dir, filepath.Base(name))
absName = name
names = append(names, "file="+name)
} else {
names = append(names, name) names = append(names, name)
}
conf.Overlay[absName] = buf conf.Overlay[absName] = buf
} else { } else {
if strings.HasSuffix(name, ".go") { if strings.HasSuffix(name, ".go") {
@ -259,7 +247,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
return nil, fmt.Errorf("error while serializing .nef file: %w", err) return nil, fmt.Errorf("error while serializing .nef file: %w", err)
} }
out := fmt.Sprintf("%s.%s", o.Outfile, o.Ext) out := fmt.Sprintf("%s.%s", o.Outfile, o.Ext)
err = ioutil.WriteFile(out, bytes, os.ModePerm) err = os.WriteFile(out, bytes, os.ModePerm)
if err != nil { if err != nil {
return f.Script, err return f.Script, err
} }
@ -289,7 +277,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
if err != nil { if err != nil {
return f.Script, err return f.Script, err
} }
if err := ioutil.WriteFile(o.DebugInfo, data, os.ModePerm); err != nil { if err := os.WriteFile(o.DebugInfo, data, os.ModePerm); err != nil {
return f.Script, err return f.Script, err
} }
} }
@ -311,7 +299,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
if err != nil { if err != nil {
return nil, fmt.Errorf("can't marshal bindings configuration: %w", err) return nil, fmt.Errorf("can't marshal bindings configuration: %w", err)
} }
err = ioutil.WriteFile(o.BindingsFile, data, os.ModePerm) err = os.WriteFile(o.BindingsFile, data, os.ModePerm)
if err != nil { if err != nil {
return nil, fmt.Errorf("can't write bindings configuration: %w", err) return nil, fmt.Errorf("can't write bindings configuration: %w", err)
} }
@ -326,7 +314,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
if err != nil { if err != nil {
return f.Script, fmt.Errorf("failed to marshal manifest to JSON: %w", err) return f.Script, fmt.Errorf("failed to marshal manifest to JSON: %w", err)
} }
return f.Script, ioutil.WriteFile(o.ManifestFile, mData, os.ModePerm) return f.Script, os.WriteFile(o.ManifestFile, mData, os.ModePerm)
} }
return f.Script, nil return f.Script, nil

View file

@ -2,7 +2,6 @@ package compiler_test
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -49,7 +48,7 @@ func TestCompiler(t *testing.T) {
{ {
name: "TestCompile", name: "TestCompile",
function: func(t *testing.T) { function: func(t *testing.T) {
infos, err := ioutil.ReadDir(examplePath) infos, err := os.ReadDir(examplePath)
require.NoError(t, err) require.NoError(t, err)
for _, info := range infos { for _, info := range infos {
if !info.IsDir() { if !info.IsDir() {
@ -66,7 +65,7 @@ func TestCompiler(t *testing.T) {
{ {
name: "TestCompileAndSave", name: "TestCompileAndSave",
function: func(t *testing.T) { function: func(t *testing.T) {
infos, err := ioutil.ReadDir(exampleCompilePath) infos, err := os.ReadDir(exampleCompilePath)
require.NoError(t, err) require.NoError(t, err)
err = os.MkdirAll(exampleSavePath, os.ModePerm) err = os.MkdirAll(exampleSavePath, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)

View file

@ -2,7 +2,6 @@ package config
import ( import (
"fmt" "fmt"
"io/ioutil"
"os" "os"
"github.com/nspcc-dev/neo-go/pkg/config/netmode" "github.com/nspcc-dev/neo-go/pkg/config/netmode"
@ -40,7 +39,7 @@ func LoadFile(configPath string) (Config, error) {
return Config{}, fmt.Errorf("config '%s' doesn't exist", configPath) return Config{}, fmt.Errorf("config '%s' doesn't exist", configPath)
} }
configData, err := ioutil.ReadFile(configPath) configData, err := os.ReadFile(configPath)
if err != nil { if err != nil {
return Config{}, fmt.Errorf("unable to read config: %w", err) return Config{}, fmt.Errorf("unable to read config: %w", err)
} }

View file

@ -4,7 +4,7 @@ import (
"encoding/hex" "encoding/hex"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "os"
"testing" "testing"
"github.com/nspcc-dev/neo-go/internal/testserdes" "github.com/nspcc-dev/neo-go/internal/testserdes"
@ -25,7 +25,7 @@ func getDecodedBlock(t *testing.T, i int) *Block {
} }
func getBlockData(i int) (map[string]interface{}, error) { func getBlockData(i int) (map[string]interface{}, error) {
b, err := ioutil.ReadFile(fmt.Sprintf("../test_data/block_%d.json", i)) b, err := os.ReadFile(fmt.Sprintf("../test_data/block_%d.json", i))
if err != nil { if err != nil {
return nil, err return nil, err
} }

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"math" "math"
"math/big" "math/big"
"os" "os"
@ -988,7 +987,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
bytes, err := ne.Bytes() bytes, err := ne.Bytes()
require.NoError(t, err) require.NoError(t, err)
if saveState { if saveState {
err = ioutil.WriteFile(helper1ContractNEFPath, bytes, os.ModePerm) err = os.WriteFile(helper1ContractNEFPath, bytes, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)
} }
@ -996,7 +995,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
mData, err := json.Marshal(m) mData, err := json.Marshal(m)
require.NoError(t, err) require.NoError(t, err)
if saveState { if saveState {
err = ioutil.WriteFile(helper1ContractManifestPath, mData, os.ModePerm) err = os.WriteFile(helper1ContractManifestPath, mData, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)
} }
@ -1022,7 +1021,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
bytes, err = ne.Bytes() bytes, err = ne.Bytes()
require.NoError(t, err) require.NoError(t, err)
if saveState { if saveState {
err = ioutil.WriteFile(helper2ContractNEFPath, bytes, os.ModePerm) err = os.WriteFile(helper2ContractNEFPath, bytes, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)
} }
@ -1030,7 +1029,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
mData, err = json.Marshal(m) mData, err = json.Marshal(m)
require.NoError(t, err) require.NoError(t, err)
if saveState { if saveState {
err = ioutil.WriteFile(helper2ContractManifestPath, mData, os.ModePerm) err = os.WriteFile(helper2ContractManifestPath, mData, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)
} }
@ -1041,12 +1040,12 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) { func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) {
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate") errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
neBytes, err := ioutil.ReadFile(helper1ContractNEFPath) neBytes, err := os.ReadFile(helper1ContractNEFPath)
require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound))
ne, err := nef.FileFromBytes(neBytes) ne, err := nef.FileFromBytes(neBytes)
require.NoError(t, err) require.NoError(t, err)
mBytes, err := ioutil.ReadFile(helper1ContractManifestPath) mBytes, err := os.ReadFile(helper1ContractManifestPath)
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
m := &manifest.Manifest{} m := &manifest.Manifest{}
err = json.Unmarshal(mBytes, m) err = json.Unmarshal(mBytes, m)
@ -1060,12 +1059,12 @@ func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*
}, },
} }
neBytes, err = ioutil.ReadFile(helper2ContractNEFPath) neBytes, err = os.ReadFile(helper2ContractNEFPath)
require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound))
ne, err = nef.FileFromBytes(neBytes) ne, err = nef.FileFromBytes(neBytes)
require.NoError(t, err) require.NoError(t, err)
mBytes, err = ioutil.ReadFile(helper2ContractManifestPath) mBytes, err = os.ReadFile(helper2ContractManifestPath)
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
m = &manifest.Manifest{} m = &manifest.Manifest{}
err = json.Unmarshal(mBytes, m) err = json.Unmarshal(mBytes, m)

View file

@ -5,7 +5,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -49,12 +49,12 @@ func TestManagement_MinimumDeploymentFee(t *testing.T) {
func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) { func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*state.Contract, *state.Contract) {
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate") errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
neBytes, err := ioutil.ReadFile(helper1ContractNEFPath) neBytes, err := os.ReadFile(helper1ContractNEFPath)
require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("nef1: %w", errNotFound))
ne, err := nef.FileFromBytes(neBytes) ne, err := nef.FileFromBytes(neBytes)
require.NoError(t, err) require.NoError(t, err)
mBytes, err := ioutil.ReadFile(helper1ContractManifestPath) mBytes, err := os.ReadFile(helper1ContractManifestPath)
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
m := &manifest.Manifest{} m := &manifest.Manifest{}
err = json.Unmarshal(mBytes, m) err = json.Unmarshal(mBytes, m)
@ -68,12 +68,12 @@ func getTestContractState(t *testing.T, id1, id2 int32, sender2 util.Uint160) (*
}, },
} }
neBytes, err = ioutil.ReadFile(helper2ContractNEFPath) neBytes, err = os.ReadFile(helper2ContractNEFPath)
require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("nef2: %w", errNotFound))
ne, err = nef.FileFromBytes(neBytes) ne, err = nef.FileFromBytes(neBytes)
require.NoError(t, err) require.NoError(t, err)
mBytes, err = ioutil.ReadFile(helper2ContractManifestPath) mBytes, err = os.ReadFile(helper2ContractManifestPath)
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
m = &manifest.Manifest{} m = &manifest.Manifest{}
err = json.Unmarshal(mBytes, m) err = json.Unmarshal(mBytes, m)

View file

@ -4,9 +4,9 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"math" "math"
"math/big" "math/big"
"os"
"path/filepath" "path/filepath"
"strings" "strings"
"testing" "testing"
@ -45,12 +45,12 @@ func getOracleContractState(t *testing.T, sender util.Uint160, id int32) *state.
) )
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate") errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
neBytes, err := ioutil.ReadFile(oracleContractNEFPath) neBytes, err := os.ReadFile(oracleContractNEFPath)
require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound))
ne, err := nef.FileFromBytes(neBytes) ne, err := nef.FileFromBytes(neBytes)
require.NoError(t, err) require.NoError(t, err)
mBytes, err := ioutil.ReadFile(oracleContractManifestPath) mBytes, err := os.ReadFile(oracleContractManifestPath)
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
m := &manifest.Manifest{} m := &manifest.Manifest{}
err = json.Unmarshal(mBytes, m) err = json.Unmarshal(mBytes, m)

View file

@ -6,7 +6,6 @@ import (
"errors" "errors"
"fmt" "fmt"
gio "io" gio "io"
"io/ioutil"
"net/http" "net/http"
"os" "os"
"path" "path"
@ -124,7 +123,7 @@ func TestGenerateOracleContract(t *testing.T) {
bytes, err := ne.Bytes() bytes, err := ne.Bytes()
require.NoError(t, err) require.NoError(t, err)
if saveState { if saveState {
err = ioutil.WriteFile(oracleContractNEFPath, bytes, os.ModePerm) err = os.WriteFile(oracleContractNEFPath, bytes, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)
} }
@ -132,7 +131,7 @@ func TestGenerateOracleContract(t *testing.T) {
mData, err := json.Marshal(m) mData, err := json.Marshal(m)
require.NoError(t, err) require.NoError(t, err)
if saveState { if saveState {
err = ioutil.WriteFile(oracleContractManifestPath, mData, os.ModePerm) err = os.WriteFile(oracleContractManifestPath, mData, os.ModePerm)
require.NoError(t, err) require.NoError(t, err)
} }
@ -144,12 +143,12 @@ func TestGenerateOracleContract(t *testing.T) {
func getOracleContractState(t *testing.T, sender util.Uint160, id int32) *state.Contract { func getOracleContractState(t *testing.T, sender util.Uint160, id int32) *state.Contract {
errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate") errNotFound := errors.New("auto-generated oracle contract is not found, use TestGenerateOracleContract to regenerate")
neBytes, err := ioutil.ReadFile(oracleContractNEFPath) neBytes, err := os.ReadFile(oracleContractNEFPath)
require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound))
ne, err := nef.FileFromBytes(neBytes) ne, err := nef.FileFromBytes(neBytes)
require.NoError(t, err) require.NoError(t, err)
mBytes, err := ioutil.ReadFile(oracleContractManifestPath) mBytes, err := os.ReadFile(oracleContractManifestPath)
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound)) require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
m := &manifest.Manifest{} m := &manifest.Manifest{}
err = json.Unmarshal(mBytes, m) err = json.Unmarshal(mBytes, m)
@ -639,5 +638,5 @@ func newDefaultHTTPClient(returnOracleRedirectionErrOn func(address string) bool
} }
func newResponseBody(resp []byte) gio.ReadCloser { func newResponseBody(resp []byte) gio.ReadCloser {
return ioutil.NopCloser(bytes.NewReader(resp)) return gio.NopCloser(bytes.NewReader(resp))
} }

View file

@ -1,8 +1,8 @@
package network package network
import ( import (
"errors"
"net" "net"
"regexp"
"sync" "sync"
"time" "time"
@ -19,8 +19,6 @@ type TCPTransport struct {
quit bool quit bool
} }
var reClosedNetwork = regexp.MustCompile(".* use of closed network connection")
// NewTCPTransport returns a new TCPTransport that will listen for // NewTCPTransport returns a new TCPTransport that will listen for
// new incoming peer connections. // new incoming peer connections.
func NewTCPTransport(s *Server, bindAddr string, log *zap.Logger) *TCPTransport { func NewTCPTransport(s *Server, bindAddr string, log *zap.Logger) *TCPTransport {
@ -65,7 +63,7 @@ func (t *TCPTransport) Accept() {
t.lock.Lock() t.lock.Lock()
quit := t.quit quit := t.quit
t.lock.Unlock() t.lock.Unlock()
if t.isCloseError(err) && quit { if errors.Is(err, net.ErrClosed) && quit {
break break
} }
t.log.Warn("TCP accept error", zap.Error(err)) t.log.Warn("TCP accept error", zap.Error(err))
@ -76,16 +74,6 @@ func (t *TCPTransport) Accept() {
} }
} }
func (t *TCPTransport) isCloseError(err error) bool {
if opErr, ok := err.(*net.OpError); ok {
if reClosedNetwork.Match([]byte(opErr.Error())) {
return true
}
}
return false
}
// Close implements the Transporter interface. // Close implements the Transporter interface.
func (t *TCPTransport) Close() { func (t *TCPTransport) Close() {
t.lock.Lock() t.lock.Lock()

View file

@ -5,7 +5,7 @@ import (
"encoding/base64" "encoding/base64"
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" gio "io"
"math/big" "math/big"
"net/http" "net/http"
"net/http/httptest" "net/http/httptest"
@ -2029,7 +2029,7 @@ func doRPCCallOverHTTP(rpcCall string, url string, t *testing.T) []byte {
cl := http.Client{Timeout: time.Second} cl := http.Client{Timeout: time.Second}
resp, err := cl.Post(url, "application/json", strings.NewReader(rpcCall)) resp, err := cl.Post(url, "application/json", strings.NewReader(rpcCall))
require.NoErrorf(t, err, "could not make a POST request") require.NoErrorf(t, err, "could not make a POST request")
body, err := ioutil.ReadAll(resp.Body) body, err := gio.ReadAll(resp.Body)
assert.NoErrorf(t, err, "could not read response from the request: %s", rpcCall) assert.NoErrorf(t, err, "could not read response from the request: %s", rpcCall)
return bytes.TrimSpace(body) return bytes.TrimSpace(body)
} }

View file

@ -8,9 +8,9 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"math" "math"
"math/bits" "math/bits"
"os"
"strconv" "strconv"
"strings" "strings"
"unicode/utf8" "unicode/utf8"
@ -436,7 +436,7 @@ func NewParameterFromString(in string) (*Parameter, error) {
res.Type = inferParamType(val) res.Type = inferParamType(val)
} }
if res.Type == ByteArrayType && typStr == fileBytesParamType { if res.Type == ByteArrayType && typStr == fileBytesParamType {
res.Value, err = ioutil.ReadFile(val) res.Value, err = os.ReadFile(val)
if err != nil { if err != nil {
return nil, fmt.Errorf("failed to read '%s' parameter from file '%s': %w", fileBytesParamType, val, err) return nil, fmt.Errorf("failed to read '%s' parameter from file '%s': %w", fileBytesParamType, val, err)
} }

View file

@ -9,7 +9,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math/big" "math/big"
"os" "os"
"strconv" "strconv"
@ -503,7 +502,7 @@ func handleReset(c *cli.Context) error {
} }
func getManifestFromFile(name string) (*manifest.Manifest, error) { func getManifestFromFile(name string) (*manifest.Manifest, error) {
bs, err := ioutil.ReadFile(name) bs, err := os.ReadFile(name)
if err != nil { if err != nil {
return nil, fmt.Errorf("%w: can't read manifest", ErrInvalidParameter) return nil, fmt.Errorf("%w: can't read manifest", ErrInvalidParameter)
} }

View file

@ -7,7 +7,6 @@ import (
"encoding/json" "encoding/json"
"fmt" "fmt"
gio "io" gio "io"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"strings" "strings"
@ -209,14 +208,14 @@ func TestLoad(t *testing.T) {
checkLoadgo := func(t *testing.T, tName, cName, cErrName string) { checkLoadgo := func(t *testing.T, tName, cName, cErrName string) {
t.Run("loadgo "+tName, func(t *testing.T) { t.Run("loadgo "+tName, func(t *testing.T) {
filename := filepath.Join(tmpDir, cName) filename := filepath.Join(tmpDir, cName)
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm)) require.NoError(t, os.WriteFile(filename, []byte(src), os.ModePerm))
filename = "'" + filename + "'" filename = "'" + filename + "'"
filenameErr := filepath.Join(tmpDir, cErrName) filenameErr := filepath.Join(tmpDir, cErrName)
require.NoError(t, ioutil.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm)) require.NoError(t, os.WriteFile(filenameErr, []byte(src+"invalid_token"), os.ModePerm))
filenameErr = "'" + filenameErr + "'" filenameErr = "'" + filenameErr + "'"
goMod := []byte(`module test.example/vmcli goMod := []byte(`module test.example/vmcli
go 1.16`) go 1.16`)
require.NoError(t, ioutil.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm)) require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
e := newTestVMCLI(t) e := newTestVMCLI(t)
e.runProgWithTimeout(t, 10*time.Second, e.runProgWithTimeout(t, 10*time.Second,
@ -244,7 +243,7 @@ go 1.16`)
} }
` `
filename := filepath.Join(tmpDir, "vmtestcontract.go") filename := filepath.Join(tmpDir, "vmtestcontract.go")
require.NoError(t, ioutil.WriteFile(filename, []byte(srcAllowNotify), os.ModePerm)) require.NoError(t, os.WriteFile(filename, []byte(srcAllowNotify), os.ModePerm))
filename = "'" + filename + "'" filename = "'" + filename + "'"
wd, err := os.Getwd() wd, err := os.Getwd()
require.NoError(t, err) require.NoError(t, err)
@ -254,7 +253,7 @@ require (
) )
replace github.com/nspcc-dev/neo-go/pkg/interop => ` + filepath.Join(wd, "../../interop") + ` replace github.com/nspcc-dev/neo-go/pkg/interop => ` + filepath.Join(wd, "../../interop") + `
go 1.16`) go 1.16`)
require.NoError(t, ioutil.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm)) require.NoError(t, os.WriteFile(filepath.Join(tmpDir, "go.mod"), goMod, os.ModePerm))
e := newTestVMCLI(t) e := newTestVMCLI(t)
e.runProg(t, e.runProg(t,
@ -271,15 +270,15 @@ go 1.16`)
filename := filepath.Join(tmpDir, "vmtestcontract.nef") filename := filepath.Join(tmpDir, "vmtestcontract.nef")
rawNef, err := nefFile.Bytes() rawNef, err := nefFile.Bytes()
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, ioutil.WriteFile(filename, rawNef, os.ModePerm)) require.NoError(t, os.WriteFile(filename, rawNef, os.ModePerm))
m, err := di.ConvertToManifest(&compiler.Options{}) m, err := di.ConvertToManifest(&compiler.Options{})
require.NoError(t, err) require.NoError(t, err)
manifestFile := filepath.Join(tmpDir, "vmtestcontract.manifest.json") manifestFile := filepath.Join(tmpDir, "vmtestcontract.manifest.json")
rawManifest, err := json.Marshal(m) rawManifest, err := json.Marshal(m)
require.NoError(t, err) require.NoError(t, err)
require.NoError(t, ioutil.WriteFile(manifestFile, rawManifest, os.ModePerm)) require.NoError(t, os.WriteFile(manifestFile, rawManifest, os.ModePerm))
filenameErr := filepath.Join(tmpDir, "vmtestcontract_err.nef") filenameErr := filepath.Join(tmpDir, "vmtestcontract_err.nef")
require.NoError(t, ioutil.WriteFile(filenameErr, append([]byte{1, 2, 3, 4}, rawNef...), os.ModePerm)) require.NoError(t, os.WriteFile(filenameErr, append([]byte{1, 2, 3, 4}, rawNef...), os.ModePerm))
notExists := filepath.Join(tmpDir, "notexists.json") notExists := filepath.Join(tmpDir, "notexists.json")
manifestFile = "'" + manifestFile + "'" manifestFile = "'" + manifestFile + "'"
@ -325,7 +324,7 @@ func TestRunWithDifferentArguments(t *testing.T) {
tmpDir := t.TempDir() tmpDir := t.TempDir()
filename := filepath.Join(tmpDir, "run_vmtestcontract.go") filename := filepath.Join(tmpDir, "run_vmtestcontract.go")
require.NoError(t, ioutil.WriteFile(filename, []byte(src), os.ModePerm)) require.NoError(t, os.WriteFile(filename, []byte(src), os.ModePerm))
filename = "'" + filename + "'" filename = "'" + filename + "'"
e := newTestVMCLI(t) e := newTestVMCLI(t)

View file

@ -7,7 +7,7 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil" "io"
"math/big" "math/big"
"os" "os"
"path/filepath" "path/filepath"
@ -129,7 +129,7 @@ func testSyscallHandler(v *VM, id uint32) error {
} }
func testFile(t *testing.T, filename string) { func testFile(t *testing.T, filename string) {
data, err := ioutil.ReadFile(filename) data, err := os.ReadFile(filename)
require.NoError(t, err) require.NoError(t, err)
// get rid of possible BOM // get rid of possible BOM
@ -472,7 +472,7 @@ func decodeBytes(data []byte) ([]byte, error) {
} }
r := base64.NewDecoder(base64.StdEncoding, bytes.NewReader(data)) r := base64.NewDecoder(base64.StdEncoding, bytes.NewReader(data))
return ioutil.ReadAll(r) return io.ReadAll(r)
} }
func decodeHex(s string) ([]byte, error) { func decodeHex(s string) ([]byte, error) {

View file

@ -7,7 +7,6 @@ import (
"errors" "errors"
"fmt" "fmt"
"io" "io"
"io/ioutil"
"math" "math"
"math/big" "math/big"
"os" "os"
@ -234,7 +233,7 @@ func (v *VM) AddBreakPointRel(n int) {
// LoadFileWithFlags loads a program in NEF format from the given path, ready to execute it. // LoadFileWithFlags loads a program in NEF format from the given path, ready to execute it.
func (v *VM) LoadFileWithFlags(path string, f callflag.CallFlag) error { func (v *VM) LoadFileWithFlags(path string, f callflag.CallFlag) error {
b, err := ioutil.ReadFile(path) b, err := os.ReadFile(path)
if err != nil { if err != nil {
return err return err
} }

View file

@ -3,7 +3,7 @@ package wallet
import ( import (
"encoding/json" "encoding/json"
"fmt" "fmt"
"io/ioutil" "os"
"path/filepath" "path/filepath"
"testing" "testing"
@ -227,11 +227,11 @@ func TestRegenerateCLIWallet1_solo(t *testing.T) {
require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]})) require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]}))
acc4 := getAccountWithScrypt(t, verifyWIF, "pass", scrypt) // deployed verify.go contract acc4 := getAccountWithScrypt(t, verifyWIF, "pass", scrypt) // deployed verify.go contract
f, err := ioutil.ReadFile(verifyNEFPath) f, err := os.ReadFile(verifyNEFPath)
require.NoError(t, err) require.NoError(t, err)
nefFile, err := nef.FileFromBytes(f) nefFile, err := nef.FileFromBytes(f)
require.NoError(t, err) require.NoError(t, err)
manifestBytes, err := ioutil.ReadFile(verifyManifestPath) manifestBytes, err := os.ReadFile(verifyManifestPath)
require.NoError(t, err) require.NoError(t, err)
m := &manifest.Manifest{} m := &manifest.Manifest{}
require.NoError(t, json.Unmarshal(manifestBytes, m)) require.NoError(t, json.Unmarshal(manifestBytes, m))

View file

@ -4,7 +4,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"io" "io"
"io/ioutil"
"os" "os"
"github.com/nspcc-dev/neo-go/pkg/crypto/keys" "github.com/nspcc-dev/neo-go/pkg/crypto/keys"
@ -161,7 +160,7 @@ func (w *Wallet) savePretty() error {
} }
func (w *Wallet) writeRaw(data []byte) error { func (w *Wallet) writeRaw(data []byte) error {
return ioutil.WriteFile(w.path, data, 0644) return os.WriteFile(w.path, data, 0644)
} }
// JSON outputs a pretty JSON representation of the wallet. // JSON outputs a pretty JSON representation of the wallet.

View file

@ -7,7 +7,6 @@ import (
"encoding/json" "encoding/json"
"errors" "errors"
"fmt" "fmt"
"io/ioutil"
"os" "os"
"path/filepath" "path/filepath"
"sort" "sort"
@ -32,7 +31,7 @@ type storageOp struct {
} }
func readFile(path string) (dump, error) { func readFile(path string) (dump, error) {
data, err := ioutil.ReadFile(path) data, err := os.ReadFile(path)
if err != nil { if err != nil {
return nil, err return nil, err
} }