forked from TrueCloudLab/neoneo-go
Merge pull request #2155 from nspcc-dev/block-native
native/policy: disallow blocking native contracts
This commit is contained in:
commit
bb7136e753
2 changed files with 16 additions and 4 deletions
|
@ -319,6 +319,11 @@ func (p *Policy) blockAccount(ic *interop.Context, args []stackitem.Item) stacki
|
|||
panic("invalid committee signature")
|
||||
}
|
||||
hash := toUint160(args[0])
|
||||
for i := range ic.Natives {
|
||||
if ic.Natives[i].Metadata().Hash == hash {
|
||||
panic("cannot block native contract")
|
||||
}
|
||||
}
|
||||
if p.IsBlockedInternal(ic.DAO, hash) {
|
||||
return stackitem.NewBool(false)
|
||||
}
|
||||
|
|
|
@ -201,18 +201,25 @@ func TestBlockedAccounts(t *testing.T) {
|
|||
neoHash := chain.contracts.NEO.Metadata().Hash
|
||||
res, err := invokeContractMethodGeneric(chain, 100000000, policyHash, "blockAccount", true, neoHash.BytesBE())
|
||||
require.NoError(t, err)
|
||||
checkFAULTState(t, res)
|
||||
|
||||
cs, _ := getTestContractState(chain)
|
||||
require.NoError(t, chain.contracts.Management.PutContractState(chain.dao, cs))
|
||||
|
||||
res, err = invokeContractMethodGeneric(chain, 100000000, policyHash, "blockAccount", true, cs.Hash.BytesBE())
|
||||
require.NoError(t, err)
|
||||
checkResult(t, res, stackitem.NewBool(true))
|
||||
|
||||
res, err = invokeContractMethodGeneric(chain, 100000000, neoHash, "balanceOf", true, account.BytesBE())
|
||||
res, err = invokeContractMethod(chain, 100000000, cs.Hash, "justReturn")
|
||||
require.NoError(t, err)
|
||||
checkFAULTState(t, res)
|
||||
|
||||
res, err = invokeContractMethodGeneric(chain, 100000000, policyHash, "unblockAccount", true, neoHash.BytesBE())
|
||||
res, err = invokeContractMethodGeneric(chain, 100000000, policyHash, "unblockAccount", true, cs.Hash.BytesBE())
|
||||
require.NoError(t, err)
|
||||
checkResult(t, res, stackitem.NewBool(true))
|
||||
|
||||
res, err = invokeContractMethodGeneric(chain, 100000000, neoHash, "balanceOf", true, account.BytesBE())
|
||||
res, err = invokeContractMethod(chain, 100000000, cs.Hash, "justReturn")
|
||||
require.NoError(t, err)
|
||||
checkResult(t, res, stackitem.Make(0))
|
||||
checkResult(t, res, stackitem.Null{})
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue