forked from TrueCloudLab/neoneo-go
Merge pull request #2369 from nspcc-dev/goshechka
*: go 1.18 support 🎉😍🎊🍰🥂
This commit is contained in:
commit
906d99571b
66 changed files with 303 additions and 268 deletions
|
@ -1,19 +1,17 @@
|
|||
version: 2.1
|
||||
|
||||
executors:
|
||||
go1_15:
|
||||
docker:
|
||||
- image: circleci/golang:1.15
|
||||
environment:
|
||||
GO111MODULE: "on"
|
||||
go1_16:
|
||||
docker:
|
||||
- image: circleci/golang:1.16
|
||||
- image: cimg/go:1.16
|
||||
environment:
|
||||
GO111MODULE: "on"
|
||||
go1_17:
|
||||
docker:
|
||||
- image: circleci/golang:1.17
|
||||
- image: cimg/go:1.17
|
||||
go1_18:
|
||||
docker:
|
||||
- image: cimg/go:1.18
|
||||
|
||||
commands:
|
||||
gomod:
|
||||
|
@ -25,11 +23,12 @@ commands:
|
|||
command: go mod download
|
||||
- save_cache:
|
||||
key: deps-{{ checksum "go.sum" }}-{{ checksum "go.sum" }}
|
||||
paths: [/go/pkg/mod]
|
||||
paths: [/home/circleci/go/pkg/mod]
|
||||
|
||||
jobs:
|
||||
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
|
||||
steps:
|
||||
- checkout
|
||||
|
@ -37,21 +36,11 @@ jobs:
|
|||
- run:
|
||||
name: go-lint
|
||||
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
|
||||
|
||||
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:
|
||||
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
|
||||
steps:
|
||||
- checkout
|
||||
|
@ -60,9 +49,29 @@ jobs:
|
|||
- gomod
|
||||
- run: go test -v -race ./...
|
||||
|
||||
build_cli:
|
||||
working_directory: /go/src/github.com/nspcc-dev/neo-go
|
||||
test_1_17:
|
||||
working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
|
||||
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:
|
||||
- checkout
|
||||
- gomod
|
||||
|
@ -72,8 +81,8 @@ jobs:
|
|||
destination: /
|
||||
|
||||
build_image:
|
||||
working_directory: /go/src/github.com/nspcc-dev/neo-go
|
||||
executor: go1_17
|
||||
working_directory: /home/circleci/go/src/github.com/nspcc-dev/neo-go
|
||||
executor: go1_18
|
||||
docker:
|
||||
- image: golang:1-alpine
|
||||
steps:
|
||||
|
@ -101,11 +110,15 @@ workflows:
|
|||
filters:
|
||||
tags:
|
||||
only: v/[0-9]+\.[0-9]+\.[0-9]+/
|
||||
- test_1_15:
|
||||
- test_1_16:
|
||||
filters:
|
||||
tags:
|
||||
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:
|
||||
tags:
|
||||
only: v/[0-9]+\.[0-9]+\.[0-9]+/
|
||||
|
|
16
.github/workflows/build.yml
vendored
16
.github/workflows/build.yml
vendored
|
@ -33,7 +33,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18
|
||||
|
||||
- name: Restore Go modules from cache
|
||||
uses: actions/cache@v2
|
||||
|
@ -67,7 +67,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18
|
||||
|
||||
- name: Restore Go modules from cache
|
||||
uses: actions/cache@v2
|
||||
|
@ -99,6 +99,12 @@ jobs:
|
|||
ref: ${{ github.event.inputs.ref }}
|
||||
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
|
||||
run: make image
|
||||
|
||||
|
@ -113,5 +119,11 @@ jobs:
|
|||
ref: ${{ github.event.inputs.ref }}
|
||||
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
|
||||
run: make image-wsc
|
||||
|
|
4
.github/workflows/publish_to_dockerhub.yml
vendored
4
.github/workflows/publish_to_dockerhub.yml
vendored
|
@ -48,7 +48,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18
|
||||
|
||||
- name: Restore go modules from cache
|
||||
uses: actions/cache@v2
|
||||
|
@ -113,7 +113,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18
|
||||
|
||||
- name: Restore go modules from cache
|
||||
uses: actions/cache@v2
|
||||
|
|
12
.github/workflows/run_tests.yml
vendored
12
.github/workflows/run_tests.yml
vendored
|
@ -56,7 +56,7 @@ jobs:
|
|||
- name: Set up Go
|
||||
uses: actions/setup-go@v2
|
||||
with:
|
||||
go-version: 1.17
|
||||
go-version: 1.18
|
||||
|
||||
- name: Restore Go modules from cache
|
||||
uses: actions/cache@v2
|
||||
|
@ -83,14 +83,16 @@ jobs:
|
|||
strategy:
|
||||
matrix:
|
||||
os: [ubuntu-20.04, windows-2022]
|
||||
go_versions: [ '1.15', '1.16', '1.17' ]
|
||||
go_versions: [ '1.16', '1.17', '1.18' ]
|
||||
exclude:
|
||||
- os: windows-2022
|
||||
go_versions: '1.15'
|
||||
# Only latest Go version for Windows.
|
||||
- os: windows-2022
|
||||
go_versions: '1.16'
|
||||
- os: ubuntu-20.04
|
||||
- os: windows-2022
|
||||
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
|
||||
steps:
|
||||
- uses: actions/checkout@v2
|
||||
|
|
|
@ -1,5 +1,9 @@
|
|||
# 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 \
|
||||
&& apk add --no-cache git make \
|
||||
|
|
|
@ -11,15 +11,65 @@ ENV GIT_DOWNLOAD_URL=https://github.com/git-for-windows/git/releases/download/v2
|
|||
|
||||
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
|
||||
|
||||
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
|
||||
|
||||
|
|
|
@ -48,7 +48,7 @@ NeoGo, `:latest` points to the latest release) or build yourself.
|
|||
|
||||
### Building
|
||||
|
||||
To build NeoGo you need Go 1.15+ and `make`:
|
||||
To build NeoGo you need Go 1.16+ and `make`:
|
||||
|
||||
```
|
||||
make build
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
@ -35,12 +34,12 @@ func TestCalcHash(t *testing.T) {
|
|||
e := newExecutor(t, false)
|
||||
|
||||
nefPath := "./testdata/verify.nef"
|
||||
src, err := ioutil.ReadFile(nefPath)
|
||||
src, err := os.ReadFile(nefPath)
|
||||
require.NoError(t, err)
|
||||
nefF, err := nef.FileFromBytes(src)
|
||||
require.NoError(t, err)
|
||||
manifestPath := "./testdata/verify.manifest.json"
|
||||
manifestBytes, err := ioutil.ReadFile(manifestPath)
|
||||
manifestBytes, err := os.ReadFile(manifestPath)
|
||||
require.NoError(t, err)
|
||||
manif := &manifest.Manifest{}
|
||||
err = json.Unmarshal(manifestBytes, manif)
|
||||
|
@ -67,12 +66,12 @@ func TestCalcHash(t *testing.T) {
|
|||
})
|
||||
t.Run("invalid nef file", func(t *testing.T) {
|
||||
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)...)
|
||||
})
|
||||
t.Run("invalid manifest file", func(t *testing.T) {
|
||||
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)...)
|
||||
})
|
||||
|
||||
|
@ -106,7 +105,7 @@ func TestContractBindings(t *testing.T) {
|
|||
e.Run(t, "neo-go", "contract", "init", "--name", ctrPath)
|
||||
|
||||
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(
|
||||
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.
|
||||
goMod := filepath.Join(ctrPath, "go.mod")
|
||||
data, err := ioutil.ReadFile(goMod)
|
||||
data, err := os.ReadFile(goMod)
|
||||
require.NoError(t, err)
|
||||
|
||||
i := bytes.IndexByte(data, '\n')
|
||||
|
@ -150,7 +149,7 @@ func Blocks() []*alias.Block {
|
|||
require.NoError(t, err)
|
||||
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/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,
|
||||
"--out", filepath.Join(tmpDir, "out.nef"),
|
||||
|
@ -165,7 +164,7 @@ func Blocks() []*alias.Block {
|
|||
"--config", bindingsPath, "--manifest", manifestPath,
|
||||
"--out", outPath, "--hash", "0x0123456789987654321001234567899876543210")
|
||||
|
||||
bs, err := ioutil.ReadFile(outPath)
|
||||
bs, err := os.ReadFile(outPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, `// Package testcontract contains wrappers for testcontract contract.
|
||||
package testcontract
|
||||
|
@ -244,23 +243,23 @@ func TestContractInitAndCompile(t *testing.T) {
|
|||
e.RunWithError(t, append(cmd, "--config", cfgName)...)
|
||||
})
|
||||
t.Run("provided corrupted config", func(t *testing.T) {
|
||||
data, err := ioutil.ReadFile(cfgPath)
|
||||
data, err := os.ReadFile(cfgPath)
|
||||
require.NoError(t, err)
|
||||
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)...)
|
||||
})
|
||||
|
||||
// Replace `pkg/interop` in go.mod to avoid getting an actual module version.
|
||||
goMod := filepath.Join(ctrPath, "go.mod")
|
||||
data, err := ioutil.ReadFile(goMod)
|
||||
data, err := os.ReadFile(goMod)
|
||||
require.NoError(t, err)
|
||||
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
data = append(data, "\nreplace github.com/nspcc-dev/neo-go/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)
|
||||
e.Run(t, cmd...)
|
||||
|
@ -481,7 +480,7 @@ func TestContractManifestGroups(t *testing.T) {
|
|||
})
|
||||
t.Run("corrupted NEF file", func(t *testing.T) {
|
||||
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",
|
||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||
"--sender", testWalletAccount, "--nef", f)
|
||||
|
@ -494,7 +493,7 @@ func TestContractManifestGroups(t *testing.T) {
|
|||
})
|
||||
t.Run("corrupted manifest file", func(t *testing.T) {
|
||||
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",
|
||||
"--wallet", testWalletPath, "--account", testWalletAccount,
|
||||
"--sender", testWalletAccount, "--nef", nefName,
|
||||
|
@ -573,7 +572,7 @@ func TestContract_TestInvokeScript(t *testing.T) {
|
|||
"--in", badNef)
|
||||
})
|
||||
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",
|
||||
"--rpc-endpoint", "http://"+e.RPC.Addr,
|
||||
"--in", badNef)
|
||||
|
@ -689,10 +688,9 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
|||
e.RunWithError(t, cmd...)
|
||||
})
|
||||
t.Run("corrupted wallet", func(t *testing.T) {
|
||||
tmp, err := ioutil.TempDir("", "tmp")
|
||||
require.NoError(t, err)
|
||||
tmp := t.TempDir()
|
||||
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,
|
||||
h.StringLE(), "getValue")
|
||||
|
@ -854,9 +852,9 @@ func TestComlileAndInvokeFunction(t *testing.T) {
|
|||
os.Remove(manifestName)
|
||||
})
|
||||
|
||||
rawNef, err := ioutil.ReadFile(nefName)
|
||||
rawNef, err := os.ReadFile(nefName)
|
||||
require.NoError(t, err)
|
||||
rawManifest, err := ioutil.ReadFile(manifestName)
|
||||
rawManifest, err := os.ReadFile(manifestName)
|
||||
require.NoError(t, err)
|
||||
|
||||
e.In.WriteString("one\r")
|
||||
|
@ -918,7 +916,7 @@ func TestContractInspect(t *testing.T) {
|
|||
func TestCompileExamples(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
const examplePath = "../examples"
|
||||
infos, err := ioutil.ReadDir(examplePath)
|
||||
infos, err := os.ReadDir(examplePath)
|
||||
require.NoError(t, err)
|
||||
|
||||
// For proper nef generation.
|
||||
|
@ -933,7 +931,7 @@ func TestCompileExamples(t *testing.T) {
|
|||
continue
|
||||
}
|
||||
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.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...)
|
||||
|
||||
if info.Name() == "storage" {
|
||||
rawM, err := ioutil.ReadFile(manifestF)
|
||||
rawM, err := os.ReadFile(manifestF)
|
||||
require.NoError(t, err)
|
||||
|
||||
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 {
|
||||
if !info.IsDir() {
|
||||
name := info.Name()
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
@ -29,7 +28,7 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
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`
|
||||
const inDump = "./testdata/chain50x2.acc"
|
||||
|
@ -61,14 +60,14 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
t.Run("bad logger config", func(t *testing.T) {
|
||||
badConfigDir := t.TempDir()
|
||||
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.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
||||
out, err = yaml.Marshal(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
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",
|
||||
"--config-path", badConfigDir, "--out", dumpPath)
|
||||
|
@ -76,14 +75,14 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
t.Run("bad storage config", func(t *testing.T) {
|
||||
badConfigDir := t.TempDir()
|
||||
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.ApplicationConfiguration.DBConfiguration.Type = ""
|
||||
out, err = yaml.Marshal(cfg)
|
||||
require.NoError(t, err)
|
||||
|
||||
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",
|
||||
"--config-path", badConfigDir, "--out", dumpPath)
|
||||
|
@ -98,9 +97,9 @@ func TestDBRestoreDump(t *testing.T) {
|
|||
|
||||
e.Run(t, baseCmd...)
|
||||
|
||||
d1, err := ioutil.ReadFile(inDump)
|
||||
d1, err := os.ReadFile(inDump)
|
||||
require.NoError(t, err)
|
||||
d2, err := ioutil.ReadFile(dumpPath)
|
||||
d2, err := os.ReadFile(dumpPath)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, d1, d2, "dumps differ")
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"bytes"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"strings"
|
||||
"sync"
|
||||
|
@ -269,7 +268,7 @@ func (e *executor) run(args ...string) error {
|
|||
e.Err.Reset()
|
||||
input.Terminal = term.NewTerminal(input.ReadWriter{
|
||||
Reader: e.In,
|
||||
Writer: ioutil.Discard,
|
||||
Writer: io.Discard,
|
||||
}, "")
|
||||
err := e.CLI.Run(args)
|
||||
input.Terminal = nil
|
||||
|
|
|
@ -2,7 +2,7 @@ package flags
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/internal/random"
|
||||
|
@ -119,7 +119,7 @@ func TestAddressFlag_GetName(t *testing.T) {
|
|||
|
||||
func TestAddress(t *testing.T) {
|
||||
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.Apply(f)
|
||||
require.NoError(t, f.Parse([]string{"--addr", "NRHkiY2hLy5ypD32CKZtL6pNwhbFMqDEhR"}))
|
||||
|
|
|
@ -2,7 +2,7 @@ package flags
|
|||
|
||||
import (
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/encoding/fixedn"
|
||||
|
@ -55,7 +55,7 @@ func TestFixed8Flag_GetName(t *testing.T) {
|
|||
|
||||
func TestFixed8(t *testing.T) {
|
||||
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.Apply(f)
|
||||
require.NoError(t, f.Parse([]string{"--gas", "0.123"}))
|
||||
|
|
|
@ -7,8 +7,8 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
"testing"
|
||||
|
@ -104,10 +104,10 @@ func TestNEP11_ND_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
|||
tmpDir := t.TempDir()
|
||||
|
||||
// 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)
|
||||
wall := filepath.Join(tmpDir, "my_wallet.json")
|
||||
err = ioutil.WriteFile(wall, bytesRead, 0755)
|
||||
err = os.WriteFile(wall, bytesRead, 0755)
|
||||
require.NoError(t, err)
|
||||
|
||||
// transfer funds to contract owner
|
||||
|
@ -336,10 +336,10 @@ func TestNEP11_D_OwnerOf_BalanceOf_Transfer(t *testing.T) {
|
|||
tmpDir := t.TempDir()
|
||||
|
||||
// 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)
|
||||
wall := filepath.Join(tmpDir, "my_wallet.json")
|
||||
err = ioutil.WriteFile(wall, bytesRead, 0755)
|
||||
err = os.WriteFile(wall, bytesRead, 0755)
|
||||
require.NoError(t, err)
|
||||
|
||||
// deploy NeoFS Object contract
|
||||
|
|
|
@ -3,7 +3,7 @@ package paramcontext
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||
"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.
|
||||
func Read(filename string) (*context.ParameterContext, error) {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
data, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
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 {
|
||||
if data, err := json.Marshal(c); err != nil {
|
||||
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 nil
|
||||
|
|
|
@ -3,7 +3,6 @@ package server
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
||||
|
@ -63,7 +62,7 @@ func (d *dump) tryPersist(prefix string, index uint32) error {
|
|||
}
|
||||
|
||||
func readFile(path string) (*dump, error) {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package server
|
|||
import (
|
||||
"encoding/binary"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
@ -46,7 +45,7 @@ func TestHandleLoggingParams(t *testing.T) {
|
|||
|
||||
t.Run("logdir is a file", func(t *testing.T) {
|
||||
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)
|
||||
ctx := cli.NewContext(cli.NewApp(), set, nil)
|
||||
cfg := config.ApplicationConfiguration{
|
||||
|
@ -196,7 +195,7 @@ func TestRestoreDB(t *testing.T) {
|
|||
t.Run("invalid logger path", func(t *testing.T) {
|
||||
badCfgDir := t.TempDir()
|
||||
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"))
|
||||
require.NoError(t, err, "could not load config")
|
||||
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
||||
|
@ -204,7 +203,7 @@ func TestRestoreDB(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
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
|
||||
require.Error(t, restoreDB(ctx))
|
||||
|
@ -220,7 +219,7 @@ func TestRestoreDB(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
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
|
||||
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) {
|
||||
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))
|
||||
*in = inPath
|
||||
require.Error(t, restoreDB(ctx))
|
||||
|
@ -247,10 +246,10 @@ func TestRestoreDB(t *testing.T) {
|
|||
})
|
||||
t.Run("corrupted in: corrupted block", func(t *testing.T) {
|
||||
inPath := filepath.Join(t.TempDir(), "file3.acc")
|
||||
b, err := ioutil.ReadFile(testDump)
|
||||
b, err := os.ReadFile(testDump)
|
||||
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
|
||||
require.NoError(t, ioutil.WriteFile(inPath, b, os.ModePerm))
|
||||
require.NoError(t, os.WriteFile(inPath, b, os.ModePerm))
|
||||
*in = inPath
|
||||
require.Error(t, restoreDB(ctx))
|
||||
|
||||
|
@ -258,12 +257,12 @@ func TestRestoreDB(t *testing.T) {
|
|||
})
|
||||
t.Run("incremental dump", func(t *testing.T) {
|
||||
inPath := filepath.Join(t.TempDir(), "file1_incremental.acc")
|
||||
b, err := ioutil.ReadFile(testDump)
|
||||
b, err := os.ReadFile(testDump)
|
||||
require.NoError(t, err)
|
||||
start := make([]byte, 4)
|
||||
t.Run("good", func(t *testing.T) {
|
||||
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))
|
||||
*in = inPath
|
||||
*incremental = true
|
||||
|
@ -272,7 +271,7 @@ func TestRestoreDB(t *testing.T) {
|
|||
})
|
||||
t.Run("dump is too high", func(t *testing.T) {
|
||||
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))
|
||||
*in = inPath
|
||||
*incremental = true
|
||||
|
|
|
@ -2,7 +2,6 @@ package main
|
|||
|
||||
import (
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
|
@ -31,7 +30,7 @@ func TestServerStart(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
|
||||
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() {
|
||||
require.NoError(t, os.Remove(cfgPath))
|
||||
})
|
||||
|
@ -47,7 +46,7 @@ func TestServerStart(t *testing.T) {
|
|||
t.Run("bad logger config", func(t *testing.T) {
|
||||
badConfigDir := t.TempDir()
|
||||
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) {
|
||||
cfg.ApplicationConfiguration.LogPath = filepath.Join(logfile, "file.log")
|
||||
})
|
||||
|
|
|
@ -2,7 +2,6 @@ package smartcontract
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strings"
|
||||
|
||||
|
@ -47,7 +46,7 @@ func contractGenerateWrapper(ctx *cli.Context) error {
|
|||
|
||||
cfg := binding.NewConfig()
|
||||
if cfgPath := ctx.String("config"); cfgPath != "" {
|
||||
bs, err := ioutil.ReadFile(cfgPath)
|
||||
bs, err := os.ReadFile(cfgPath)
|
||||
if err != nil {
|
||||
return cli.NewExitError(fmt.Errorf("can't read config file: %w", err), 1)
|
||||
}
|
||||
|
|
|
@ -2,7 +2,6 @@ package smartcontract
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -115,7 +114,7 @@ func TestGenerate(t *testing.T) {
|
|||
|
||||
rawManifest, err := json.Marshal(m)
|
||||
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{
|
||||
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
|
||||
|
@ -139,7 +138,7 @@ callflags:
|
|||
doSomething: ReadStates
|
||||
`
|
||||
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",
|
||||
"--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.Equal(t, expected, string(data))
|
||||
}
|
||||
|
@ -245,7 +244,7 @@ func TestGenerateValidPackageName(t *testing.T) {
|
|||
|
||||
rawManifest, err := json.Marshal(m)
|
||||
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{
|
||||
0x04, 0x08, 0x15, 0x16, 0x23, 0x42, 0x43, 0x44, 0x00, 0x01,
|
||||
|
@ -259,7 +258,7 @@ func TestGenerateValidPackageName(t *testing.T) {
|
|||
"--hash", "0x" + h.StringLE(),
|
||||
}))
|
||||
|
||||
data, err := ioutil.ReadFile(outFile)
|
||||
data, err := os.ReadFile(outFile)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, `// Package myspacecontract contains wrappers for My space contract contract.
|
||||
package myspacecontract
|
||||
|
@ -297,7 +296,7 @@ func TestGenerate_Errors(t *testing.T) {
|
|||
})
|
||||
t.Run("invalid manifest", func(t *testing.T) {
|
||||
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)
|
||||
})
|
||||
|
||||
|
@ -305,7 +304,7 @@ func TestGenerate_Errors(t *testing.T) {
|
|||
m := manifest.NewManifest("MyContract")
|
||||
rawManifest, err := json.Marshal(m)
|
||||
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) {
|
||||
checkError(t, "invalid contract hash", "--manifest", manifestFile, "--hash", "xxx")
|
||||
|
@ -321,7 +320,7 @@ callflags:
|
|||
someFunc: ReadSometimes
|
||||
`
|
||||
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",
|
||||
"--manifest", manifestFile, "--hash", util.Uint160{}.StringLE(),
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"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)
|
||||
}
|
||||
|
||||
err = ioutil.WriteFile(mPath, rawM, os.ModePerm)
|
||||
err = os.WriteFile(mPath, rawM, os.ModePerm)
|
||||
if err != nil {
|
||||
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")
|
||||
}
|
||||
|
||||
f, err := ioutil.ReadFile(filename)
|
||||
f, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
@ -108,7 +107,7 @@ func readManifest(filename string) (*manifest.Manifest, []byte, error) {
|
|||
return nil, nil, errNoManifestFile
|
||||
}
|
||||
|
||||
manifestBytes, err := ioutil.ReadFile(filename)
|
||||
manifestBytes, err := os.ReadFile(filename)
|
||||
if err != nil {
|
||||
return nil, nil, err
|
||||
}
|
||||
|
|
|
@ -5,7 +5,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -455,7 +454,7 @@ func initSmartContract(ctx *cli.Context) error {
|
|||
if err != nil {
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -468,12 +467,12 @@ func initSmartContract(ctx *cli.Context) error {
|
|||
require (
|
||||
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)
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
|
||||
|
@ -548,7 +547,7 @@ func calcHash(ctx *cli.Context) error {
|
|||
if mpath == "" {
|
||||
return cli.NewExitError(errors.New("no manifest file provided"), 1)
|
||||
}
|
||||
f, err := ioutil.ReadFile(p)
|
||||
f, err := os.ReadFile(p)
|
||||
if err != nil {
|
||||
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 {
|
||||
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 {
|
||||
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)
|
||||
}
|
||||
|
||||
b, err := ioutil.ReadFile(src)
|
||||
b, err := os.ReadFile(src)
|
||||
if err != nil {
|
||||
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)
|
||||
}
|
||||
} else {
|
||||
f, err := ioutil.ReadFile(in)
|
||||
f, err := os.ReadFile(in)
|
||||
if err != nil {
|
||||
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.
|
||||
func ParseContractConfig(confFile string) (ProjectConfig, error) {
|
||||
conf := ProjectConfig{}
|
||||
confBytes, err := ioutil.ReadFile(confFile)
|
||||
confBytes, err := os.ReadFile(confFile)
|
||||
if err != nil {
|
||||
return conf, cli.NewExitError(err, 1)
|
||||
}
|
||||
|
|
|
@ -3,7 +3,6 @@ package smartcontract
|
|||
import (
|
||||
"encoding/hex"
|
||||
"flag"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
|
@ -31,13 +30,13 @@ func TestInitSmartContract(t *testing.T) {
|
|||
dirInfo, err := os.Stat(contractName)
|
||||
require.NoError(t, err)
|
||||
require.True(t, dirInfo.IsDir())
|
||||
files, err := ioutil.ReadDir(contractName)
|
||||
files, err := os.ReadDir(contractName)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 3, len(files))
|
||||
require.Equal(t, "go.mod", files[0].Name())
|
||||
require.Equal(t, "main.go", files[1].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.Equal(t,
|
||||
`package `+contractName+`
|
||||
|
@ -56,7 +55,7 @@ func RuntimeNotify(args []interface{}) {
|
|||
runtime.Notify(notificationName, args)
|
||||
}`, string(main))
|
||||
|
||||
manifest, err := ioutil.ReadFile(contractName + "/" + files[2].Name())
|
||||
manifest, err := os.ReadFile(contractName + "/" + files[2].Name())
|
||||
require.NoError(t, err)
|
||||
require.Equal(t,
|
||||
`name: testContract
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/engine
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/events
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/iterator
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -3,7 +3,7 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd-nns
|
|||
go 1.16
|
||||
|
||||
require (
|
||||
github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220310092710-5379ef75bbb9
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.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-20220318080930-d2bc4473ce9b
|
||||
github.com/stretchr/testify v1.7.0
|
||||
)
|
||||
|
|
|
@ -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/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.2-pre.0.20220310092710-5379ef75bbb9 h1:L6cY5S/1ZsH2zDax8sMidue2YpYIjrH5s773DBn+sgs=
|
||||
github.com/nspcc-dev/neo-go v0.98.2-pre.0.20220310092710-5379ef75bbb9/go.mod h1:ahEhaTYsPP78ODCXc9J6g364zEsGRlJ3Lg//REhWxaQ=
|
||||
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-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8=
|
||||
github.com/nspcc-dev/neo-go/pkg/interop v0.0.0-20220310092710-5379ef75bbb9/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
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.20220318104433-7a8dc1179138/go.mod h1:/O1Ih5Wmxg+RZgXiM/QRUkeip0Ynf1o5QuWehSIVKgc=
|
||||
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-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.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ=
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/nft-nd
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/oracle
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/runtime
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/storage
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/timer
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token-sale
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
|
@ -2,4 +2,4 @@ module github.com/nspcc-dev/neo-go/examples/token
|
|||
|
||||
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
|
||||
|
|
|
@ -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-20220310092710-5379ef75bbb9/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-20220318080930-d2bc4473ce9b/go.mod h1:QBE0I30F2kOAISNpT5oks82yF4wkkUq3SCfI3Hqgx/Y=
|
||||
|
|
4
go.mod
4
go.mod
|
@ -11,7 +11,7 @@ require (
|
|||
github.com/mr-tron/base58 v1.2.0
|
||||
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/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/rfc6979 v0.2.0
|
||||
github.com/pierrec/lz4 v2.6.1+incompatible
|
||||
|
@ -31,4 +31,4 @@ require (
|
|||
gopkg.in/yaml.v2 v2.4.0
|
||||
)
|
||||
|
||||
go 1.15
|
||||
go 1.16
|
||||
|
|
4
go.sum
4
go.sum
|
@ -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/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/pkg/interop v0.0.0-20220310092710-5379ef75bbb9 h1:RP0ZgihYsyaJrfJBJ8PhtTRz598DH9esSqZyNqnjLz8=
|
||||
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 h1:P2hmPjJP/i65zZBpReB+ve5LRNv5WhAgBoBkPMpFpdg=
|
||||
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.1 h1:SVqc523pZsSaS9vnPS1mm3VV6b6xY0gvdA0uYJ/GWZQ=
|
||||
github.com/nspcc-dev/neofs-api-go/v2 v2.11.1/go.mod h1:oS8dycEh8PPf2Jjp6+8dlwWyEv2Dy77h/XhhcdxYEFs=
|
||||
|
|
|
@ -9,10 +9,8 @@ import (
|
|||
"go/token"
|
||||
"go/types"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"runtime"
|
||||
"strings"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
|
||||
|
@ -156,24 +154,14 @@ func getBuildInfo(name string, src interface{}) (*buildInfo, error) {
|
|||
case string:
|
||||
buf = []byte(s)
|
||||
case io.Reader:
|
||||
buf, err = ioutil.ReadAll(s)
|
||||
buf, err = io.ReadAll(s)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
default:
|
||||
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)
|
||||
}
|
||||
conf.Overlay[absName] = buf
|
||||
} else {
|
||||
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)
|
||||
}
|
||||
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 {
|
||||
return f.Script, err
|
||||
}
|
||||
|
@ -289,7 +277,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
|||
if err != nil {
|
||||
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
|
||||
}
|
||||
}
|
||||
|
@ -311,7 +299,7 @@ func CompileAndSave(src string, o *Options) ([]byte, error) {
|
|||
if err != nil {
|
||||
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 {
|
||||
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 {
|
||||
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
|
||||
|
|
|
@ -2,7 +2,6 @@ package compiler_test
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -49,7 +48,7 @@ func TestCompiler(t *testing.T) {
|
|||
{
|
||||
name: "TestCompile",
|
||||
function: func(t *testing.T) {
|
||||
infos, err := ioutil.ReadDir(examplePath)
|
||||
infos, err := os.ReadDir(examplePath)
|
||||
require.NoError(t, err)
|
||||
for _, info := range infos {
|
||||
if !info.IsDir() {
|
||||
|
@ -66,7 +65,7 @@ func TestCompiler(t *testing.T) {
|
|||
{
|
||||
name: "TestCompileAndSave",
|
||||
function: func(t *testing.T) {
|
||||
infos, err := ioutil.ReadDir(exampleCompilePath)
|
||||
infos, err := os.ReadDir(exampleCompilePath)
|
||||
require.NoError(t, err)
|
||||
err = os.MkdirAll(exampleSavePath, os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
|
|
|
@ -2,7 +2,6 @@ package config
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"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)
|
||||
}
|
||||
|
||||
configData, err := ioutil.ReadFile(configPath)
|
||||
configData, err := os.ReadFile(configPath)
|
||||
if err != nil {
|
||||
return Config{}, fmt.Errorf("unable to read config: %w", err)
|
||||
}
|
||||
|
|
|
@ -4,7 +4,7 @@ import (
|
|||
"encoding/hex"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"testing"
|
||||
|
||||
"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) {
|
||||
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 {
|
||||
return nil, err
|
||||
}
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
|
@ -988,7 +987,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
|||
bytes, err := ne.Bytes()
|
||||
require.NoError(t, err)
|
||||
if saveState {
|
||||
err = ioutil.WriteFile(helper1ContractNEFPath, bytes, os.ModePerm)
|
||||
err = os.WriteFile(helper1ContractNEFPath, bytes, os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
@ -996,7 +995,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
|||
mData, err := json.Marshal(m)
|
||||
require.NoError(t, err)
|
||||
if saveState {
|
||||
err = ioutil.WriteFile(helper1ContractManifestPath, mData, os.ModePerm)
|
||||
err = os.WriteFile(helper1ContractManifestPath, mData, os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
@ -1022,7 +1021,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
|||
bytes, err = ne.Bytes()
|
||||
require.NoError(t, err)
|
||||
if saveState {
|
||||
err = ioutil.WriteFile(helper2ContractNEFPath, bytes, os.ModePerm)
|
||||
err = os.WriteFile(helper2ContractNEFPath, bytes, os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
@ -1030,7 +1029,7 @@ func TestGenerateManagementHelperContracts(t *testing.T) {
|
|||
mData, err = json.Marshal(m)
|
||||
require.NoError(t, err)
|
||||
if saveState {
|
||||
err = ioutil.WriteFile(helper2ContractManifestPath, mData, os.ModePerm)
|
||||
err = os.WriteFile(helper2ContractManifestPath, mData, os.ModePerm)
|
||||
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) {
|
||||
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))
|
||||
ne, err := nef.FileFromBytes(neBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
mBytes, err := ioutil.ReadFile(helper1ContractManifestPath)
|
||||
mBytes, err := os.ReadFile(helper1ContractManifestPath)
|
||||
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
|
||||
m := &manifest.Manifest{}
|
||||
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))
|
||||
ne, err = nef.FileFromBytes(neBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
mBytes, err = ioutil.ReadFile(helper2ContractManifestPath)
|
||||
mBytes, err = os.ReadFile(helper2ContractManifestPath)
|
||||
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
|
||||
m = &manifest.Manifest{}
|
||||
err = json.Unmarshal(mBytes, m)
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"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) {
|
||||
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))
|
||||
ne, err := nef.FileFromBytes(neBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
mBytes, err := ioutil.ReadFile(helper1ContractManifestPath)
|
||||
mBytes, err := os.ReadFile(helper1ContractManifestPath)
|
||||
require.NoError(t, err, fmt.Errorf("manifest1: %w", errNotFound))
|
||||
m := &manifest.Manifest{}
|
||||
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))
|
||||
ne, err = nef.FileFromBytes(neBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
mBytes, err = ioutil.ReadFile(helper2ContractManifestPath)
|
||||
mBytes, err = os.ReadFile(helper2ContractManifestPath)
|
||||
require.NoError(t, err, fmt.Errorf("manifest2: %w", errNotFound))
|
||||
m = &manifest.Manifest{}
|
||||
err = json.Unmarshal(mBytes, m)
|
||||
|
|
|
@ -4,9 +4,9 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/big"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
"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")
|
||||
|
||||
neBytes, err := ioutil.ReadFile(oracleContractNEFPath)
|
||||
neBytes, err := os.ReadFile(oracleContractNEFPath)
|
||||
require.NoError(t, err, fmt.Errorf("nef: %w", errNotFound))
|
||||
ne, err := nef.FileFromBytes(neBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
mBytes, err := ioutil.ReadFile(oracleContractManifestPath)
|
||||
mBytes, err := os.ReadFile(oracleContractManifestPath)
|
||||
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
|
||||
m := &manifest.Manifest{}
|
||||
err = json.Unmarshal(mBytes, m)
|
||||
|
|
|
@ -6,7 +6,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
gio "io"
|
||||
"io/ioutil"
|
||||
"net/http"
|
||||
"os"
|
||||
"path"
|
||||
|
@ -124,7 +123,7 @@ func TestGenerateOracleContract(t *testing.T) {
|
|||
bytes, err := ne.Bytes()
|
||||
require.NoError(t, err)
|
||||
if saveState {
|
||||
err = ioutil.WriteFile(oracleContractNEFPath, bytes, os.ModePerm)
|
||||
err = os.WriteFile(oracleContractNEFPath, bytes, os.ModePerm)
|
||||
require.NoError(t, err)
|
||||
}
|
||||
|
||||
|
@ -132,7 +131,7 @@ func TestGenerateOracleContract(t *testing.T) {
|
|||
mData, err := json.Marshal(m)
|
||||
require.NoError(t, err)
|
||||
if saveState {
|
||||
err = ioutil.WriteFile(oracleContractManifestPath, mData, os.ModePerm)
|
||||
err = os.WriteFile(oracleContractManifestPath, mData, os.ModePerm)
|
||||
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 {
|
||||
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))
|
||||
ne, err := nef.FileFromBytes(neBytes)
|
||||
require.NoError(t, err)
|
||||
|
||||
mBytes, err := ioutil.ReadFile(oracleContractManifestPath)
|
||||
mBytes, err := os.ReadFile(oracleContractManifestPath)
|
||||
require.NoError(t, err, fmt.Errorf("manifest: %w", errNotFound))
|
||||
m := &manifest.Manifest{}
|
||||
err = json.Unmarshal(mBytes, m)
|
||||
|
@ -639,5 +638,5 @@ func newDefaultHTTPClient(returnOracleRedirectionErrOn func(address string) bool
|
|||
}
|
||||
|
||||
func newResponseBody(resp []byte) gio.ReadCloser {
|
||||
return ioutil.NopCloser(bytes.NewReader(resp))
|
||||
return gio.NopCloser(bytes.NewReader(resp))
|
||||
}
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
package network
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"net"
|
||||
"regexp"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
|
@ -19,8 +19,6 @@ type TCPTransport struct {
|
|||
quit bool
|
||||
}
|
||||
|
||||
var reClosedNetwork = regexp.MustCompile(".* use of closed network connection")
|
||||
|
||||
// NewTCPTransport returns a new TCPTransport that will listen for
|
||||
// new incoming peer connections.
|
||||
func NewTCPTransport(s *Server, bindAddr string, log *zap.Logger) *TCPTransport {
|
||||
|
@ -65,7 +63,7 @@ func (t *TCPTransport) Accept() {
|
|||
t.lock.Lock()
|
||||
quit := t.quit
|
||||
t.lock.Unlock()
|
||||
if t.isCloseError(err) && quit {
|
||||
if errors.Is(err, net.ErrClosed) && quit {
|
||||
break
|
||||
}
|
||||
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.
|
||||
func (t *TCPTransport) Close() {
|
||||
t.lock.Lock()
|
||||
|
|
|
@ -5,7 +5,7 @@ import (
|
|||
"encoding/base64"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
gio "io"
|
||||
"math/big"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
|
@ -2029,7 +2029,7 @@ func doRPCCallOverHTTP(rpcCall string, url string, t *testing.T) []byte {
|
|||
cl := http.Client{Timeout: time.Second}
|
||||
resp, err := cl.Post(url, "application/json", strings.NewReader(rpcCall))
|
||||
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)
|
||||
return bytes.TrimSpace(body)
|
||||
}
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/bits"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
"unicode/utf8"
|
||||
|
@ -436,7 +436,7 @@ func NewParameterFromString(in string) (*Parameter, error) {
|
|||
res.Type = inferParamType(val)
|
||||
}
|
||||
if res.Type == ByteArrayType && typStr == fileBytesParamType {
|
||||
res.Value, err = ioutil.ReadFile(val)
|
||||
res.Value, err = os.ReadFile(val)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to read '%s' parameter from file '%s': %w", fileBytesParamType, val, err)
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math/big"
|
||||
"os"
|
||||
"strconv"
|
||||
|
@ -503,7 +502,7 @@ func handleReset(c *cli.Context) error {
|
|||
}
|
||||
|
||||
func getManifestFromFile(name string) (*manifest.Manifest, error) {
|
||||
bs, err := ioutil.ReadFile(name)
|
||||
bs, err := os.ReadFile(name)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("%w: can't read manifest", ErrInvalidParameter)
|
||||
}
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"encoding/json"
|
||||
"fmt"
|
||||
gio "io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strings"
|
||||
|
@ -209,14 +208,14 @@ func TestLoad(t *testing.T) {
|
|||
checkLoadgo := func(t *testing.T, tName, cName, cErrName string) {
|
||||
t.Run("loadgo "+tName, func(t *testing.T) {
|
||||
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 + "'"
|
||||
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 + "'"
|
||||
goMod := []byte(`module test.example/vmcli
|
||||
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.runProgWithTimeout(t, 10*time.Second,
|
||||
|
@ -244,7 +243,7 @@ go 1.16`)
|
|||
}
|
||||
`
|
||||
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 + "'"
|
||||
wd, err := os.Getwd()
|
||||
require.NoError(t, err)
|
||||
|
@ -254,7 +253,7 @@ require (
|
|||
)
|
||||
replace github.com/nspcc-dev/neo-go/pkg/interop => ` + filepath.Join(wd, "../../interop") + `
|
||||
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.runProg(t,
|
||||
|
@ -271,15 +270,15 @@ go 1.16`)
|
|||
filename := filepath.Join(tmpDir, "vmtestcontract.nef")
|
||||
rawNef, err := nefFile.Bytes()
|
||||
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{})
|
||||
require.NoError(t, err)
|
||||
manifestFile := filepath.Join(tmpDir, "vmtestcontract.manifest.json")
|
||||
rawManifest, err := json.Marshal(m)
|
||||
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")
|
||||
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")
|
||||
|
||||
manifestFile = "'" + manifestFile + "'"
|
||||
|
@ -325,7 +324,7 @@ func TestRunWithDifferentArguments(t *testing.T) {
|
|||
|
||||
tmpDir := t.TempDir()
|
||||
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 + "'"
|
||||
e := newTestVMCLI(t)
|
||||
|
|
|
@ -7,7 +7,7 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"io"
|
||||
"math/big"
|
||||
"os"
|
||||
"path/filepath"
|
||||
|
@ -129,7 +129,7 @@ func testSyscallHandler(v *VM, id uint32) error {
|
|||
}
|
||||
|
||||
func testFile(t *testing.T, filename string) {
|
||||
data, err := ioutil.ReadFile(filename)
|
||||
data, err := os.ReadFile(filename)
|
||||
require.NoError(t, err)
|
||||
|
||||
// get rid of possible BOM
|
||||
|
@ -472,7 +472,7 @@ func decodeBytes(data []byte) ([]byte, error) {
|
|||
}
|
||||
|
||||
r := base64.NewDecoder(base64.StdEncoding, bytes.NewReader(data))
|
||||
return ioutil.ReadAll(r)
|
||||
return io.ReadAll(r)
|
||||
}
|
||||
|
||||
func decodeHex(s string) ([]byte, error) {
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"math"
|
||||
"math/big"
|
||||
"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.
|
||||
func (v *VM) LoadFileWithFlags(path string, f callflag.CallFlag) error {
|
||||
b, err := ioutil.ReadFile(path)
|
||||
b, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
|
|
@ -3,7 +3,7 @@ package wallet
|
|||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
|
||||
|
@ -227,11 +227,11 @@ func TestRegenerateCLIWallet1_solo(t *testing.T) {
|
|||
require.NoError(t, acc3.ConvertMultisig(1, keys.PublicKeys{getKeys(t)[0]}))
|
||||
|
||||
acc4 := getAccountWithScrypt(t, verifyWIF, "pass", scrypt) // deployed verify.go contract
|
||||
f, err := ioutil.ReadFile(verifyNEFPath)
|
||||
f, err := os.ReadFile(verifyNEFPath)
|
||||
require.NoError(t, err)
|
||||
nefFile, err := nef.FileFromBytes(f)
|
||||
require.NoError(t, err)
|
||||
manifestBytes, err := ioutil.ReadFile(verifyManifestPath)
|
||||
manifestBytes, err := os.ReadFile(verifyManifestPath)
|
||||
require.NoError(t, err)
|
||||
m := &manifest.Manifest{}
|
||||
require.NoError(t, json.Unmarshal(manifestBytes, m))
|
||||
|
|
|
@ -4,7 +4,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"io"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
|
||||
"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 {
|
||||
return ioutil.WriteFile(w.path, data, 0644)
|
||||
return os.WriteFile(w.path, data, 0644)
|
||||
}
|
||||
|
||||
// JSON outputs a pretty JSON representation of the wallet.
|
||||
|
|
|
@ -7,7 +7,6 @@ import (
|
|||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"sort"
|
||||
|
@ -32,7 +31,7 @@ type storageOp struct {
|
|||
}
|
||||
|
||||
func readFile(path string) (dump, error) {
|
||||
data, err := ioutil.ReadFile(path)
|
||||
data, err := os.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue