Merge pull request #2527 from nspcc-dev/yaml-v3
gomod: upgrade yaml package from v2 to v3
This commit is contained in:
commit
9d0215985f
14 changed files with 40 additions and 36 deletions
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestDBRestoreDump(t *testing.T) {
|
func TestDBRestoreDump(t *testing.T) {
|
||||||
|
|
|
@ -15,7 +15,7 @@ import (
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"go.uber.org/zap"
|
"go.uber.org/zap"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
// serverTestWD is the default working directory for server tests.
|
// serverTestWD is the default working directory for server tests.
|
||||||
|
|
|
@ -12,7 +12,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/cli/server"
|
"github.com/nspcc-dev/neo-go/cli/server"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config"
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestServerStart(t *testing.T) {
|
func TestServerStart(t *testing.T) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/binding"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var generateWrapperCmd = cli.Command{
|
var generateWrapperCmd = cli.Command{
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
type permission manifest.Permission
|
type permission manifest.Permission
|
||||||
|
@ -20,20 +20,18 @@ const (
|
||||||
)
|
)
|
||||||
|
|
||||||
func (p permission) MarshalYAML() (interface{}, error) {
|
func (p permission) MarshalYAML() (interface{}, error) {
|
||||||
m := make(yaml.MapSlice, 0, 2)
|
m := yaml.Node{Kind: yaml.MappingNode}
|
||||||
switch p.Contract.Type {
|
switch p.Contract.Type {
|
||||||
case manifest.PermissionWildcard:
|
case manifest.PermissionWildcard:
|
||||||
case manifest.PermissionHash:
|
case manifest.PermissionHash:
|
||||||
m = append(m, yaml.MapItem{
|
m.Content = append(m.Content,
|
||||||
Key: permHashKey,
|
&yaml.Node{Kind: yaml.ScalarNode, Value: permHashKey},
|
||||||
Value: p.Contract.Value.(util.Uint160).StringLE(),
|
&yaml.Node{Kind: yaml.ScalarNode, Value: p.Contract.Value.(util.Uint160).StringLE()})
|
||||||
})
|
|
||||||
case manifest.PermissionGroup:
|
case manifest.PermissionGroup:
|
||||||
bs := p.Contract.Value.(*keys.PublicKey).Bytes()
|
bs := p.Contract.Value.(*keys.PublicKey).Bytes()
|
||||||
m = append(m, yaml.MapItem{
|
m.Content = append(m.Content,
|
||||||
Key: permGroupKey,
|
&yaml.Node{Kind: yaml.ScalarNode, Value: permGroupKey},
|
||||||
Value: hex.EncodeToString(bs),
|
&yaml.Node{Kind: yaml.ScalarNode, Value: hex.EncodeToString(bs)})
|
||||||
})
|
|
||||||
default:
|
default:
|
||||||
return nil, fmt.Errorf("invalid permission type: %d", p.Contract.Type)
|
return nil, fmt.Errorf("invalid permission type: %d", p.Contract.Type)
|
||||||
}
|
}
|
||||||
|
@ -43,10 +41,15 @@ func (p permission) MarshalYAML() (interface{}, error) {
|
||||||
val = p.Methods.Value
|
val = p.Methods.Value
|
||||||
}
|
}
|
||||||
|
|
||||||
m = append(m, yaml.MapItem{
|
n := &yaml.Node{Kind: yaml.ScalarNode}
|
||||||
Key: permMethodKey,
|
err := n.Encode(val)
|
||||||
Value: val,
|
if err != nil {
|
||||||
})
|
return nil, err
|
||||||
|
}
|
||||||
|
m.Content = append(m.Content,
|
||||||
|
&yaml.Node{Kind: yaml.ScalarNode, Value: permMethodKey},
|
||||||
|
n)
|
||||||
|
|
||||||
return m, nil
|
return m, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -29,7 +29,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm"
|
"github.com/nspcc-dev/neo-go/pkg/vm"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
"github.com/nspcc-dev/neo-go/pkg/wallet"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -11,7 +11,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/manifest"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"github.com/urfave/cli"
|
"github.com/urfave/cli"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestInitSmartContract(t *testing.T) {
|
func TestInitSmartContract(t *testing.T) {
|
||||||
|
@ -57,19 +57,19 @@ func RuntimeNotify(args []interface{}) {
|
||||||
|
|
||||||
manifest, err := os.ReadFile(contractName + "/" + files[2].Name())
|
manifest, err := os.ReadFile(contractName + "/" + files[2].Name())
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t,
|
expected := `name: testContract
|
||||||
`name: testContract
|
|
||||||
sourceurl: http://example.com/
|
sourceurl: http://example.com/
|
||||||
safemethods: []
|
safemethods: []
|
||||||
supportedstandards: []
|
supportedstandards: []
|
||||||
events:
|
events:
|
||||||
- name: Hello world!
|
- name: Hello world!
|
||||||
parameters:
|
parameters:
|
||||||
- name: args
|
- name: args
|
||||||
type: Array
|
type: Array
|
||||||
permissions:
|
permissions:
|
||||||
- methods: '*'
|
- methods: '*'
|
||||||
`, string(manifest))
|
`
|
||||||
|
require.Equal(t, expected, string(manifest))
|
||||||
}
|
}
|
||||||
|
|
||||||
func testPermissionMarshal(t *testing.T, p *manifest.Permission, expected string) {
|
func testPermissionMarshal(t *testing.T, p *manifest.Permission, expected string) {
|
||||||
|
@ -110,7 +110,7 @@ func TestPermissionMarshal(t *testing.T) {
|
||||||
p.Methods.Add("lamao")
|
p.Methods.Add("lamao")
|
||||||
testPermissionMarshal(t, p,
|
testPermissionMarshal(t, p,
|
||||||
"group: "+hex.EncodeToString(priv.PublicKey().Bytes())+"\n"+
|
"group: "+hex.EncodeToString(priv.PublicKey().Bytes())+"\n"+
|
||||||
"methods:\n- abc\n- lamao\n")
|
"methods:\n - abc\n - lamao\n")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
2
go.mod
2
go.mod
|
@ -29,7 +29,7 @@ require (
|
||||||
golang.org/x/term v0.0.0-20210429154555-c04ba851c2a4
|
golang.org/x/term v0.0.0-20210429154555-c04ba851c2a4
|
||||||
golang.org/x/text v0.3.7
|
golang.org/x/text v0.3.7
|
||||||
golang.org/x/tools v0.1.8
|
golang.org/x/tools v0.1.8
|
||||||
gopkg.in/yaml.v2 v2.4.0
|
gopkg.in/yaml.v3 v3.0.1
|
||||||
)
|
)
|
||||||
|
|
||||||
go 1.16
|
go 1.16
|
||||||
|
|
3
go.sum
3
go.sum
|
@ -448,7 +448,8 @@ gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
|
||||||
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY=
|
||||||
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b h1:h8qDotaEPuJATrMmW04NCwg7v22aHH28wwpauUhK9Oo=
|
|
||||||
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4=
|
||||||
|
|
|
@ -19,7 +19,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
"github.com/nspcc-dev/neo-go/pkg/smartcontract/nef"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"golang.org/x/tools/go/packages"
|
"golang.org/x/tools/go/packages"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const fileExt = "nef"
|
const fileExt = "nef"
|
||||||
|
|
|
@ -6,7 +6,7 @@ import (
|
||||||
|
|
||||||
"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/rpc"
|
"github.com/nspcc-dev/neo-go/pkg/rpc"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestFixed8FromInt64(t *testing.T) {
|
func TestFixed8FromInt64(t *testing.T) {
|
||||||
|
|
|
@ -5,7 +5,7 @@ import (
|
||||||
|
|
||||||
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestCallFlag_Has(t *testing.T) {
|
func TestCallFlag_Has(t *testing.T) {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/stretchr/testify/assert"
|
"github.com/stretchr/testify/assert"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
"gopkg.in/yaml.v2"
|
"gopkg.in/yaml.v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestUint160UnmarshalJSON(t *testing.T) {
|
func TestUint160UnmarshalJSON(t *testing.T) {
|
||||||
|
|
Loading…
Reference in a new issue