mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 13:41:37 +00:00
Merge pull request #2215 from nspcc-dev/getproof-fix
rpc: make `getproof` work with destroyed contracts
This commit is contained in:
commit
ab3df6cc52
2 changed files with 37 additions and 3 deletions
|
@ -406,4 +406,38 @@ func TestCompatibility_Find(t *testing.T) {
|
|||
t.Run("from matching start", func(t *testing.T) {
|
||||
check(t, []byte{}, 2) // without `from` key
|
||||
})
|
||||
t.Run("TestFindStatesIssue652", func(t *testing.T) {
|
||||
tr := NewTrie(nil, false, newTestStore())
|
||||
// root is an extension node with key=abc; next=branch
|
||||
require.NoError(t, tr.Put([]byte("abc1"), []byte("01")))
|
||||
require.NoError(t, tr.Put([]byte("abc3"), []byte("02")))
|
||||
tr.Flush()
|
||||
// find items with extension's key prefix
|
||||
t.Run("from > start", func(t *testing.T) {
|
||||
res, err := tr.Find([]byte("ab"), []byte("d2"), 100)
|
||||
require.NoError(t, err)
|
||||
// nothing should be found, because from[0]=`d` > key[2]=`c`
|
||||
require.Equal(t, 0, len(res))
|
||||
})
|
||||
|
||||
t.Run("from < start", func(t *testing.T) {
|
||||
res, err := tr.Find([]byte("ab"), []byte("b2"), 100)
|
||||
require.NoError(t, err)
|
||||
// all items should be included into the result, because from[0]=`b` < key[2]=`c`
|
||||
require.Equal(t, 2, len(res))
|
||||
})
|
||||
|
||||
t.Run("from and start have common prefix", func(t *testing.T) {
|
||||
res, err := tr.Find([]byte("ab"), []byte("c"), 100)
|
||||
require.NoError(t, err)
|
||||
// all items should be included into the result, because from[0] == key[2]
|
||||
require.Equal(t, 2, len(res))
|
||||
})
|
||||
|
||||
t.Run("from equals to item key", func(t *testing.T) {
|
||||
res, err := tr.Find([]byte("ab"), []byte("c1"), 100)
|
||||
require.NoError(t, err)
|
||||
require.Equal(t, 1, len(res))
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
@ -991,9 +991,9 @@ func (s *Server) getProof(ps request.Params) (interface{}, *response.Error) {
|
|||
if err != nil {
|
||||
return nil, response.ErrInvalidParams
|
||||
}
|
||||
cs := s.chain.GetContractState(sc)
|
||||
if cs == nil {
|
||||
return nil, response.ErrInvalidParams
|
||||
cs, respErr := s.getHistoricalContractState(root, sc)
|
||||
if respErr != nil {
|
||||
return nil, respErr
|
||||
}
|
||||
skey := makeStorageKey(cs.ID, key)
|
||||
proof, err := s.chain.GetStateModule().GetStateProof(root, skey)
|
||||
|
|
Loading…
Reference in a new issue