mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2025-05-03 23:02:27 +00:00
rpcbinding: use binding condig to generate code for simple arrays
Part of #2767.
This commit is contained in:
parent
b5c79f4be3
commit
82c6ce218b
6 changed files with 266 additions and 1 deletions
|
@ -365,6 +365,44 @@ func TestGenerateRPCBindings(t *testing.T) {
|
|||
filepath.Join("testdata", "nonepiter", "iter.go"))
|
||||
}
|
||||
|
||||
func TestAssistedRPCBindings(t *testing.T) {
|
||||
tmpDir := t.TempDir()
|
||||
app := cli.NewApp()
|
||||
app.Commands = NewCommands()
|
||||
|
||||
var checkBinding = func(source string) {
|
||||
t.Run(source, func(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",
|
||||
"--in", source,
|
||||
"--config", filepath.Join(source, "config.yml"),
|
||||
"--manifest", manifestF,
|
||||
"--bindings", bindingF,
|
||||
"--out", nefF,
|
||||
}))
|
||||
outFile := filepath.Join(tmpDir, "out.go")
|
||||
require.NoError(t, app.Run([]string{"", "contract", "generate-rpcwrapper",
|
||||
"--config", bindingF,
|
||||
"--manifest", manifestF,
|
||||
"--out", outFile,
|
||||
"--hash", "0x00112233445566778899aabbccddeeff00112233",
|
||||
}))
|
||||
|
||||
data, err := os.ReadFile(outFile)
|
||||
require.NoError(t, err)
|
||||
data = bytes.ReplaceAll(data, []byte("\r"), []byte{}) // Windows.
|
||||
expected, err := os.ReadFile(filepath.Join(source, "rpcbindings.out"))
|
||||
require.NoError(t, err)
|
||||
expected = bytes.ReplaceAll(expected, []byte("\r"), []byte{}) // Windows.
|
||||
require.Equal(t, string(expected), string(data))
|
||||
})
|
||||
}
|
||||
|
||||
checkBinding(filepath.Join("testdata", "types"))
|
||||
}
|
||||
|
||||
func TestGenerate_Errors(t *testing.T) {
|
||||
app := cli.NewApp()
|
||||
app.Commands = []cli.Command{generateWrapperCmd}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue