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

@ -36,7 +36,7 @@ func TestRestoreAfterDeploy(t *testing.T) {
mgmtHash := bc.ManagementContractHash()
cs1, _ := getTestContractState(bc)
cs1.ID = 1
cs1.Hash = state.CreateContractHash(testchain.MultisigScriptHash(), cs1.NEF.Script)
cs1.Hash = state.CreateContractHash(testchain.MultisigScriptHash(), cs1.NEF.Checksum, cs1.Manifest.Name)
manif1, err := json.Marshal(cs1.Manifest)
require.NoError(t, err)
nef1, err := nef.NewFile(cs1.NEF.Script)
@ -80,7 +80,7 @@ func TestContractDeploy(t *testing.T) {
mgmtHash := bc.ManagementContractHash()
cs1, _ := getTestContractState(bc)
cs1.ID = 1
cs1.Hash = state.CreateContractHash(testchain.MultisigScriptHash(), cs1.NEF.Script)
cs1.Hash = state.CreateContractHash(testchain.MultisigScriptHash(), cs1.NEF.Checksum, cs1.Manifest.Name)
manif1, err := json.Marshal(cs1.Manifest)
require.NoError(t, err)
nef1b, err := cs1.NEF.Bytes()
@ -214,7 +214,7 @@ func TestContractDeploy(t *testing.T) {
checkFAULTState(t, res)
t.Run("get after failed deploy", func(t *testing.T) {
h := state.CreateContractHash(neoOwner, deployScript)
h := state.CreateContractHash(neoOwner, nefD.Checksum, m.Name)
checkContractState(t, bc, h, nil)
})
})
@ -243,7 +243,7 @@ func TestContractDeploy(t *testing.T) {
checkFAULTState(t, res)
t.Run("get after bad _deploy", func(t *testing.T) {
h := state.CreateContractHash(neoOwner, deployScript)
h := state.CreateContractHash(neoOwner, nefD.Checksum, m.Name)
checkContractState(t, bc, h, nil)
})
})