2020-12-15 09:35:10 +00:00
|
|
|
package native
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2021-02-05 09:09:15 +00:00
|
|
|
"unicode"
|
2021-01-15 21:17:31 +00:00
|
|
|
|
2021-07-20 12:54:56 +00:00
|
|
|
"github.com/nspcc-dev/neo-go/pkg/config"
|
2021-01-15 21:17:31 +00:00
|
|
|
"github.com/stretchr/testify/require"
|
2020-12-15 09:35:10 +00:00
|
|
|
)
|
|
|
|
|
2021-02-05 09:09:15 +00:00
|
|
|
// "C" and "O" can easily be typed by accident.
|
|
|
|
func TestNamesASCII(t *testing.T) {
|
2021-07-20 12:54:56 +00:00
|
|
|
cfg := config.ProtocolConfiguration{P2PSigExtensions: true}
|
|
|
|
cs := NewContracts(cfg)
|
2024-03-27 17:48:14 +00:00
|
|
|
latestHF := config.LatestHardfork()
|
2021-02-05 09:09:15 +00:00
|
|
|
for _, c := range cs.Contracts {
|
|
|
|
require.True(t, isASCII(c.Metadata().Name))
|
2024-03-27 17:48:14 +00:00
|
|
|
hfMD := c.Metadata().HFSpecificContractMD(&latestHF)
|
|
|
|
for _, m := range hfMD.Methods {
|
2021-02-15 13:40:44 +00:00
|
|
|
require.True(t, isASCII(m.MD.Name))
|
2021-02-05 09:09:15 +00:00
|
|
|
}
|
2024-03-27 17:48:14 +00:00
|
|
|
for _, e := range hfMD.Manifest.ABI.Events {
|
2021-02-05 09:09:15 +00:00
|
|
|
require.True(t, isASCII(e.Name))
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
func isASCII(s string) bool {
|
|
|
|
ok := true
|
2024-08-30 18:41:02 +00:00
|
|
|
for i := range s {
|
2021-02-05 09:09:15 +00:00
|
|
|
ok = ok && s[i] <= unicode.MaxASCII
|
|
|
|
}
|
|
|
|
return ok
|
|
|
|
}
|