native: make management compatible with C# node 3.5.0
It doesn't store id->hash mappings for native contracts. We need blockchain's GetContractScriptHash to serve both anyway, so it was changed a bit. The only other direct user of native.GetContractScriptHash is the VM CLI, but I doubt anyone will use it for native contracts (they have ~zero VM code anyway).
This commit is contained in:
parent
90a85259a8
commit
236e633ee4
5 changed files with 17 additions and 4 deletions
|
@ -688,8 +688,10 @@ func putContractState(d *dao.Simple, cs *state.Contract, updateCache bool) error
|
|||
if cs.UpdateCounter != 0 { // Update.
|
||||
return nil
|
||||
}
|
||||
key = putHashKey(key, cs.ID)
|
||||
d.PutStorageItem(ManagementContractID, key, cs.Hash.BytesBE())
|
||||
if cs.ID > 0 {
|
||||
key = putHashKey(key, cs.ID)
|
||||
d.PutStorageItem(ManagementContractID, key, cs.Hash.BytesBE())
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
|
|
@ -566,6 +566,7 @@ func TestManagement_GetContract(t *testing.T) {
|
|||
t.Run("by ID, positive", func(t *testing.T) {
|
||||
managementInvoker.Invoke(t, si, "getContractById", cs1.ID)
|
||||
})
|
||||
/* C# compatibility
|
||||
t.Run("by ID, native", func(t *testing.T) {
|
||||
csm := managementInvoker.Executor.Chain.GetContractState(managementInvoker.Hash)
|
||||
require.NotNil(t, csm)
|
||||
|
@ -573,6 +574,7 @@ func TestManagement_GetContract(t *testing.T) {
|
|||
require.NoError(t, err)
|
||||
managementInvoker.Invoke(t, sim, "getContractById", -1)
|
||||
})
|
||||
*/
|
||||
t.Run("by ID, empty", func(t *testing.T) {
|
||||
managementInvoker.Invoke(t, stackitem.Null{}, "getContractById", -100)
|
||||
})
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue