state: use checksums and names to calculate contract hashes

It allows to deploy the same NEF using one sender and get different contract
hashes. See neo-project/neo#2240.
This commit is contained in:
Roman Khimov 2021-01-22 12:22:48 +03:00
parent 6b9b37f170
commit 054ca27e9c
14 changed files with 76 additions and 39 deletions

View file

@ -556,11 +556,11 @@ func TestVerifyTx(t *testing.T) {
})
tx.Scripts = append(tx.Scripts, transaction.Witness{})
t.Run("NonZeroVerification", func(t *testing.T) {
script, _ := state.CreateNativeContractHash(-6) //oracleContractID
w := io.NewBufBinWriter()
emit.Opcodes(w.BinWriter, opcode.ABORT)
emit.Bytes(w.BinWriter, util.Uint160{}.BytesBE())
emit.Bytes(w.BinWriter, script)
emit.Int(w.BinWriter, int64(orc.NEF.Checksum))
emit.String(w.BinWriter, orc.Manifest.Name)
tx.Scripts[len(tx.Scripts)-1].VerificationScript = w.Bytes()
err := bc.VerifyTx(tx)
require.True(t, errors.Is(err, ErrNativeContractWitness), "got: %v", err)