cli: add test for --guessed-eventtypes RPC binding generator flag

Currently we have problems with unnamed structs used as a parameter for
notifications, because there's no one-to-one correspondence between
notification parameter and the list of extended types used by the whole
contract. Otherwise eventtypes guessing works OK.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
This commit is contained in:
Anna Shaleva 2023-05-25 18:39:27 +03:00
parent 3e2755e66d
commit 0195aae824
3 changed files with 1183 additions and 7 deletions

View file

@ -379,7 +379,7 @@ func TestAssistedRPCBindings(t *testing.T) {
app := cli.NewApp()
app.Commands = NewCommands()
var checkBinding = func(source string, suffix ...string) {
var checkBinding = func(source string, guessEventTypes bool, suffix ...string) {
testName := source
if len(suffix) != 0 {
testName += suffix[0]
@ -394,13 +394,17 @@ func TestAssistedRPCBindings(t *testing.T) {
manifestF := filepath.Join(tmpDir, "manifest.json")
bindingF := filepath.Join(tmpDir, "binding.yml")
nefF := filepath.Join(tmpDir, "out.nef")
require.NoError(t, app.Run([]string{"", "contract", "compile",
cmd := []string{"", "contract", "compile",
"--in", source,
"--config", configFile,
"--manifest", manifestF,
"--bindings", bindingF,
"--out", nefF,
}))
}
if guessEventTypes {
cmd = append(cmd, "--guess-eventtypes")
}
require.NoError(t, app.Run(cmd))
outFile := filepath.Join(tmpDir, "out.go")
require.NoError(t, app.Run([]string{"", "contract", "generate-rpcwrapper",
"--config", bindingF,
@ -423,10 +427,11 @@ func TestAssistedRPCBindings(t *testing.T) {
})
}
checkBinding(filepath.Join("testdata", "types"))
checkBinding(filepath.Join("testdata", "structs"))
checkBinding(filepath.Join("testdata", "notifications"))
checkBinding(filepath.Join("testdata", "notifications"), "_extended")
checkBinding(filepath.Join("testdata", "types"), false)
checkBinding(filepath.Join("testdata", "structs"), false)
checkBinding(filepath.Join("testdata", "notifications"), false)
checkBinding(filepath.Join("testdata", "notifications"), false, "_extended")
checkBinding(filepath.Join("testdata", "notifications"), true, "_guessed")
require.False(t, rewriteExpectedOutputs)
}

View file

@ -0,0 +1,19 @@
name: "Notifications"
sourceurl: https://github.com/nspcc-dev/neo-go/
events:
- name: "! complicated name %$#"
parameters:
- name: ! complicated param @#$%
type: String
- name: "SomeMap"
parameters:
- name: m
type: Map
- name: "SomeStruct"
parameters:
- name: s
type: Struct
- name: "SomeArray"
parameters:
- name: a
type: Array

File diff suppressed because it is too large Load diff