mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-26 19:42:23 +00:00
Merge pull request #2142 from nspcc-dev/fix-customgroups-witness-scope
runtime: fix CustomGroups witness
This commit is contained in:
commit
7b9558d756
2 changed files with 3 additions and 25 deletions
|
@ -49,16 +49,12 @@ func checkScope(ic *interop.Context, tx *transaction.Transaction, v *vm.VM, hash
|
|||
}
|
||||
}
|
||||
if c.Scopes&transaction.CustomGroups != 0 {
|
||||
callingScriptHash := v.GetCallingScriptHash()
|
||||
if callingScriptHash.Equals(util.Uint160{}) {
|
||||
return false, nil
|
||||
}
|
||||
if !v.Context().GetCallFlags().Has(callflag.ReadStates) {
|
||||
return false, errors.New("missing ReadStates call flag")
|
||||
}
|
||||
cs, err := ic.GetContract(callingScriptHash)
|
||||
cs, err := ic.GetContract(v.GetCurrentScriptHash())
|
||||
if err != nil {
|
||||
return false, fmt.Errorf("unable to find calling script: %w", err)
|
||||
return false, nil
|
||||
}
|
||||
// check if the current group is the required one
|
||||
for _, allowedGroup := range c.AllowedGroups {
|
||||
|
|
|
@ -1119,23 +1119,6 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
|||
ic.VM.LoadScriptWithHash([]byte{0x1}, random.Uint160(), callflag.AllowCall)
|
||||
check(t, ic, hash.BytesBE(), true)
|
||||
})
|
||||
t.Run("CustomGroups, unknown contract", func(t *testing.T) {
|
||||
hash := random.Uint160()
|
||||
tx := &transaction.Transaction{
|
||||
Signers: []transaction.Signer{
|
||||
{
|
||||
Account: hash,
|
||||
Scopes: transaction.CustomGroups,
|
||||
AllowedGroups: []*keys.PublicKey{},
|
||||
},
|
||||
},
|
||||
}
|
||||
ic.Container = tx
|
||||
callingScriptHash := scriptHash
|
||||
loadScriptWithHashAndFlags(ic, script, callingScriptHash, callflag.All)
|
||||
ic.VM.LoadScriptWithHash([]byte{0x1}, random.Uint160(), callflag.ReadStates)
|
||||
check(t, ic, hash.BytesBE(), true)
|
||||
})
|
||||
})
|
||||
})
|
||||
t.Run("positive", func(t *testing.T) {
|
||||
|
@ -1200,7 +1183,7 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
|||
check(t, ic, hash.BytesBE(), false, true)
|
||||
})
|
||||
t.Run("CustomGroups", func(t *testing.T) {
|
||||
t.Run("empty calling scripthash", func(t *testing.T) {
|
||||
t.Run("unknown scripthash", func(t *testing.T) {
|
||||
hash := random.Uint160()
|
||||
tx := &transaction.Transaction{
|
||||
Signers: []transaction.Signer{
|
||||
|
@ -1244,7 +1227,6 @@ func TestRuntimeCheckWitness(t *testing.T) {
|
|||
}
|
||||
require.NoError(t, bc.contracts.Management.PutContractState(ic.DAO, contractState))
|
||||
loadScriptWithHashAndFlags(ic, contractScript, contractScriptHash, callflag.All)
|
||||
ic.VM.LoadScriptWithHash([]byte{0x1}, random.Uint160(), callflag.ReadStates)
|
||||
ic.Container = tx
|
||||
check(t, ic, targetHash.BytesBE(), false, true)
|
||||
})
|
||||
|
|
Loading…
Reference in a new issue