*: fix ineffassign where the value should really be used

Found with GoReportCard.
This commit is contained in:
Roman Khimov 2020-08-14 12:08:57 +03:00
parent ec2a2f3fb9
commit f6a308f7f6
3 changed files with 5 additions and 1 deletions

View file

@ -89,7 +89,7 @@ func contractCreate(ic *interop.Context) error {
return err
}
contract, err := ic.DAO.GetContractState(newcontract.ScriptHash())
if contract != nil {
if contract != nil && err == nil {
return errors.New("contract already exists")
}
id, err := ic.DAO.GetAndUpdateNextContractID()

View file

@ -733,6 +733,7 @@ func TestContractUpdate(t *testing.T) {
// updated contract should have new scripthash
actual, err := ic.DAO.GetContractState(cs.ScriptHash())
require.NoError(t, err)
expected := &state.Contract{
ID: cs.ID,
Script: cs.Script,

View file

@ -160,6 +160,7 @@ func TestBlockedAccounts(t *testing.T) {
require.NoError(t, chain.persist())
res, err = invokeNativePolicyMethod(chain, "unblockAccount", account.BytesBE())
require.NoError(t, err)
checkResult(t, res, stackitem.NewBool(true))
accounts, err = chain.contracts.Policy.GetBlockedAccountsInternal(chain.dao)
@ -183,11 +184,13 @@ func TestBlockedAccounts(t *testing.T) {
// unblock
res, err = invokeNativePolicyMethod(chain, "unblockAccount", account.BytesBE())
require.NoError(t, err)
checkResult(t, res, stackitem.NewBool(true))
require.NoError(t, chain.persist())
// unblock the same account should fail as we don't have it blocked
res, err = invokeNativePolicyMethod(chain, "unblockAccount", account.BytesBE())
require.NoError(t, err)
checkResult(t, res, stackitem.NewBool(false))
require.NoError(t, chain.persist())
})