forked from TrueCloudLab/neoneo-go
Merge pull request #1851 from nspcc-dev/management-fix
core: fix Management.GetContract
This commit is contained in:
commit
ebce6b7597
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)
|
ctr, err := m.GetContract(ic.DAO, hash)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == storage.ErrKeyNotFound {
|
||||||
|
return stackitem.Null{}
|
||||||
|
}
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
return contractToStack(ctr)
|
return contractToStack(ctr)
|
||||||
|
|
|
@ -349,13 +349,13 @@ func checkContractState(t *testing.T, bc *Blockchain, h util.Uint160, cs *state.
|
||||||
mgmtHash := bc.contracts.Management.Hash
|
mgmtHash := bc.contracts.Management.Hash
|
||||||
res, err := invokeContractMethod(bc, 1_00000000, mgmtHash, "getContract", h.BytesBE())
|
res, err := invokeContractMethod(bc, 1_00000000, mgmtHash, "getContract", h.BytesBE())
|
||||||
require.NoError(t, err)
|
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, vm.HaltState, res.VMState)
|
||||||
require.Equal(t, 1, len(res.Stack))
|
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) {
|
func TestContractUpdate(t *testing.T) {
|
||||||
|
@ -574,9 +574,7 @@ func TestContractDestroy(t *testing.T) {
|
||||||
Item: stackitem.NewArray([]stackitem.Item{stackitem.NewByteArray(cs1.Hash.BytesBE())}),
|
Item: stackitem.NewArray([]stackitem.Item{stackitem.NewByteArray(cs1.Hash.BytesBE())}),
|
||||||
}})
|
}})
|
||||||
t.Run("check contract", func(t *testing.T) {
|
t.Run("check contract", func(t *testing.T) {
|
||||||
res, err := invokeContractMethod(bc, 1_00000000, mgmtHash, "getContract", cs1.Hash.BytesBE())
|
checkContractState(t, bc, cs1.Hash, nil)
|
||||||
require.NoError(t, err)
|
|
||||||
checkFAULTState(t, res)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in a new issue