Merge pull request #1708 from nspcc-dev/native/fixname

native: fix `getCommittee` name
This commit is contained in:
Roman Khimov 2021-02-05 14:02:28 +03:00 committed by GitHub
commit b1977ea4e3
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 24 additions and 1 deletions

View file

@ -2,6 +2,7 @@ package native
import ( import (
"testing" "testing"
"unicode"
"github.com/stretchr/testify/require" "github.com/stretchr/testify/require"
) )
@ -18,3 +19,25 @@ func TestNativeHashes(t *testing.T) {
// Not yet a part of NEO. // Not yet a part of NEO.
//require.Equal(t, "", newNotary().Hash.StringLE()()) //require.Equal(t, "", newNotary().Hash.StringLE()())
} }
// "C" and "O" can easily be typed by accident.
func TestNamesASCII(t *testing.T) {
cs := NewContracts(true)
for _, c := range cs.Contracts {
require.True(t, isASCII(c.Metadata().Name))
for m := range c.Metadata().Methods {
require.True(t, isASCII(m.Name))
}
for _, e := range c.Metadata().Manifest.ABI.Events {
require.True(t, isASCII(e.Name))
}
}
}
func isASCII(s string) bool {
ok := true
for i := 0; i < len(s); i++ {
ok = ok && s[i] <= unicode.MaxASCII
}
return ok
}

View file

@ -133,7 +133,7 @@ func newNEO() *NEO {
md = newMethodAndPrice(n.getCandidatesCall, 100000000, callflag.ReadStates) md = newMethodAndPrice(n.getCandidatesCall, 100000000, callflag.ReadStates)
n.AddMethod(md, desc) n.AddMethod(md, desc)
desc = newDescriptor("getСommittee", smartcontract.ArrayType) desc = newDescriptor("getCommittee", smartcontract.ArrayType)
md = newMethodAndPrice(n.getCommittee, 100000000, callflag.ReadStates) md = newMethodAndPrice(n.getCommittee, 100000000, callflag.ReadStates)
n.AddMethod(md, desc) n.AddMethod(md, desc)