Merge pull request #3385 from nspcc-dev/findstorage
rpcsrv: fix findstorage if a contract state is not found
This commit is contained in:
commit
c5ba53986f
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