mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-23 03:41:34 +00:00
core: fix Management.GetContract
This commit is contained in:
parent
57d4990fe6
commit
96e198de97
2 changed files with 9 additions and 8 deletions
|
@ -131,6 +131,9 @@ func (m *Management) getContract(ic *interop.Context, args []stackitem.Item) sta
|
|||
}
|
||||
ctr, err := m.GetContract(ic.DAO, hash)
|
||||
if err != nil {
|
||||
if err == storage.ErrKeyNotFound {
|
||||
return stackitem.Null{}
|
||||
}
|
||||
panic(err)
|
||||
}
|
||||
return contractToStack(ctr)
|
||||
|
|
|
@ -349,13 +349,13 @@ func checkContractState(t *testing.T, bc *Blockchain, h util.Uint160, cs *state.
|
|||
mgmtHash := bc.contracts.Management.Hash
|
||||
res, err := invokeContractMethod(bc, 1_00000000, mgmtHash, "getContract", h.BytesBE())
|
||||
require.NoError(t, err)
|
||||
if cs == nil {
|
||||
require.Equal(t, vm.FaultState, res.VMState)
|
||||
return
|
||||
}
|
||||
require.Equal(t, vm.HaltState, res.VMState)
|
||||
require.Equal(t, 1, len(res.Stack))
|
||||
compareContractStates(t, cs, res.Stack[0])
|
||||
if cs == nil {
|
||||
require.Equal(t, stackitem.Null{}, res.Stack[0])
|
||||
} else {
|
||||
compareContractStates(t, cs, res.Stack[0])
|
||||
}
|
||||
}
|
||||
|
||||
func TestContractUpdate(t *testing.T) {
|
||||
|
@ -574,9 +574,7 @@ func TestContractDestroy(t *testing.T) {
|
|||
Item: stackitem.NewArray([]stackitem.Item{stackitem.NewByteArray(cs1.Hash.BytesBE())}),
|
||||
}})
|
||||
t.Run("check contract", func(t *testing.T) {
|
||||
res, err := invokeContractMethod(bc, 1_00000000, mgmtHash, "getContract", cs1.Hash.BytesBE())
|
||||
require.NoError(t, err)
|
||||
checkFAULTState(t, res)
|
||||
checkContractState(t, bc, cs1.Hash, nil)
|
||||
})
|
||||
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue