forked from TrueCloudLab/neoneo-go
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:
parent
3e2755e66d
commit
0195aae824
3 changed files with 1183 additions and 7 deletions
|
@ -379,7 +379,7 @@ func TestAssistedRPCBindings(t *testing.T) {
|
||||||
app := cli.NewApp()
|
app := cli.NewApp()
|
||||||
app.Commands = NewCommands()
|
app.Commands = NewCommands()
|
||||||
|
|
||||||
var checkBinding = func(source string, suffix ...string) {
|
var checkBinding = func(source string, guessEventTypes bool, suffix ...string) {
|
||||||
testName := source
|
testName := source
|
||||||
if len(suffix) != 0 {
|
if len(suffix) != 0 {
|
||||||
testName += suffix[0]
|
testName += suffix[0]
|
||||||
|
@ -394,13 +394,17 @@ func TestAssistedRPCBindings(t *testing.T) {
|
||||||
manifestF := filepath.Join(tmpDir, "manifest.json")
|
manifestF := filepath.Join(tmpDir, "manifest.json")
|
||||||
bindingF := filepath.Join(tmpDir, "binding.yml")
|
bindingF := filepath.Join(tmpDir, "binding.yml")
|
||||||
nefF := filepath.Join(tmpDir, "out.nef")
|
nefF := filepath.Join(tmpDir, "out.nef")
|
||||||
require.NoError(t, app.Run([]string{"", "contract", "compile",
|
cmd := []string{"", "contract", "compile",
|
||||||
"--in", source,
|
"--in", source,
|
||||||
"--config", configFile,
|
"--config", configFile,
|
||||||
"--manifest", manifestF,
|
"--manifest", manifestF,
|
||||||
"--bindings", bindingF,
|
"--bindings", bindingF,
|
||||||
"--out", nefF,
|
"--out", nefF,
|
||||||
}))
|
}
|
||||||
|
if guessEventTypes {
|
||||||
|
cmd = append(cmd, "--guess-eventtypes")
|
||||||
|
}
|
||||||
|
require.NoError(t, app.Run(cmd))
|
||||||
outFile := filepath.Join(tmpDir, "out.go")
|
outFile := filepath.Join(tmpDir, "out.go")
|
||||||
require.NoError(t, app.Run([]string{"", "contract", "generate-rpcwrapper",
|
require.NoError(t, app.Run([]string{"", "contract", "generate-rpcwrapper",
|
||||||
"--config", bindingF,
|
"--config", bindingF,
|
||||||
|
@ -423,10 +427,11 @@ func TestAssistedRPCBindings(t *testing.T) {
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
checkBinding(filepath.Join("testdata", "types"))
|
checkBinding(filepath.Join("testdata", "types"), false)
|
||||||
checkBinding(filepath.Join("testdata", "structs"))
|
checkBinding(filepath.Join("testdata", "structs"), false)
|
||||||
checkBinding(filepath.Join("testdata", "notifications"))
|
checkBinding(filepath.Join("testdata", "notifications"), false)
|
||||||
checkBinding(filepath.Join("testdata", "notifications"), "_extended")
|
checkBinding(filepath.Join("testdata", "notifications"), false, "_extended")
|
||||||
|
checkBinding(filepath.Join("testdata", "notifications"), true, "_guessed")
|
||||||
|
|
||||||
require.False(t, rewriteExpectedOutputs)
|
require.False(t, rewriteExpectedOutputs)
|
||||||
}
|
}
|
||||||
|
|
19
cli/smartcontract/testdata/notifications/config_guessed.yml
vendored
Normal file
19
cli/smartcontract/testdata/notifications/config_guessed.yml
vendored
Normal 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
|
1152
cli/smartcontract/testdata/notifications/rpcbindings_guessed.out
vendored
Executable file
1152
cli/smartcontract/testdata/notifications/rpcbindings_guessed.out
vendored
Executable file
File diff suppressed because it is too large
Load diff
Loading…
Reference in a new issue