mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-25 03:47:18 +00:00
rpcsrv: fix findstorage if a contract state is not found
Previously findstorage returns null for the results key if a contract state is not found. C# returns an empty list. Close #3370 Signed-off-by: Ekaterina Pavlova <ekt@morphbits.io>
This commit is contained in:
parent
e7a0ded65e
commit
fff25bd85c
3 changed files with 18 additions and 5 deletions
|
@ -2321,7 +2321,11 @@ func TestClient_FindStorage(t *testing.T) {
|
||||||
// Missing item.
|
// Missing item.
|
||||||
actual, err = c.FindStorageByHash(h, []byte("unknown prefix"), nil)
|
actual, err = c.FindStorageByHash(h, []byte("unknown prefix"), nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, result.FindStorage{}, actual)
|
require.Equal(t, result.FindStorage{
|
||||||
|
Results: []result.KeyValue{},
|
||||||
|
Next: 0,
|
||||||
|
Truncated: false,
|
||||||
|
}, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_FindStorageHistoric(t *testing.T) {
|
func TestClient_FindStorageHistoric(t *testing.T) {
|
||||||
|
@ -2386,7 +2390,11 @@ func TestClient_FindStorageHistoric(t *testing.T) {
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
actual, err = c.FindStorageByHashHistoric(earlyRoot.Root, h, prefix, nil)
|
actual, err = c.FindStorageByHashHistoric(earlyRoot.Root, h, prefix, nil)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
require.Equal(t, result.FindStorage{}, actual)
|
require.Equal(t, result.FindStorage{
|
||||||
|
Results: []result.KeyValue{},
|
||||||
|
Next: 0,
|
||||||
|
Truncated: false,
|
||||||
|
}, actual)
|
||||||
}
|
}
|
||||||
|
|
||||||
func TestClient_GetStorageHistoric(t *testing.T) {
|
func TestClient_GetStorageHistoric(t *testing.T) {
|
||||||
|
|
|
@ -1750,7 +1750,8 @@ func (s *Server) findStorageInternal(id int32, prefix []byte, start, take int, s
|
||||||
var (
|
var (
|
||||||
i int
|
i int
|
||||||
end = start + take
|
end = start + take
|
||||||
res = new(result.FindStorage)
|
// Result is an empty list if a contract state is not found as it is in C# implementation.
|
||||||
|
res = &result.FindStorage{Results: make([]result.KeyValue, 0)}
|
||||||
)
|
)
|
||||||
seeker.SeekStorage(id, prefix, func(k, v []byte) bool {
|
seeker.SeekStorage(id, prefix, func(k, v []byte) bool {
|
||||||
if i < start {
|
if i < start {
|
||||||
|
|
|
@ -817,7 +817,7 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
expected := &result.FindStorage{
|
expected := &result.FindStorage{
|
||||||
Results: nil,
|
Results: []result.KeyValue{},
|
||||||
Next: 0,
|
Next: 0,
|
||||||
Truncated: false,
|
Truncated: false,
|
||||||
}
|
}
|
||||||
|
@ -956,7 +956,11 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
actual, ok := res.(*result.FindStorage)
|
actual, ok := res.(*result.FindStorage)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
|
|
||||||
expected := &result.FindStorage{}
|
expected := &result.FindStorage{
|
||||||
|
Results: []result.KeyValue{},
|
||||||
|
Next: 0,
|
||||||
|
Truncated: false,
|
||||||
|
}
|
||||||
require.Equal(t, expected, actual)
|
require.Equal(t, expected, actual)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
Loading…
Reference in a new issue