mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-29 13:41:47 +00:00
1b83dc2476
Mostly it's about Go 1.22+ syntax with ranging over integers, but it also prefers ranging over slices where possible (it makes code a little better to read). Notice that we have a number of dangerous loops where slices are mutated during loop execution, many of these can't be converted since we need proper length evalutation at every iteration. Signed-off-by: Roman Khimov <roman@nspcc.ru>
34 lines
761 B
Go
34 lines
761 B
Go
package native
|
|
|
|
import (
|
|
"testing"
|
|
"unicode"
|
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
|
"github.com/stretchr/testify/require"
|
|
)
|
|
|
|
// "C" and "O" can easily be typed by accident.
|
|
func TestNamesASCII(t *testing.T) {
|
|
cfg := config.ProtocolConfiguration{P2PSigExtensions: true}
|
|
cs := NewContracts(cfg)
|
|
latestHF := config.LatestHardfork()
|
|
for _, c := range cs.Contracts {
|
|
require.True(t, isASCII(c.Metadata().Name))
|
|
hfMD := c.Metadata().HFSpecificContractMD(&latestHF)
|
|
for _, m := range hfMD.Methods {
|
|
require.True(t, isASCII(m.MD.Name))
|
|
}
|
|
for _, e := range hfMD.Manifest.ABI.Events {
|
|
require.True(t, isASCII(e.Name))
|
|
}
|
|
}
|
|
}
|
|
|
|
func isASCII(s string) bool {
|
|
ok := true
|
|
for i := range s {
|
|
ok = ok && s[i] <= unicode.MaxASCII
|
|
}
|
|
return ok
|
|
}
|