mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-11-22 19:29:39 +00:00
nef: drop scripthash
It's no longer a part of the file.
This commit is contained in:
parent
1cf1fe5d74
commit
0c7e727859
5 changed files with 7 additions and 31 deletions
BIN
cli/testdata/verify.nef
vendored
BIN
cli/testdata/verify.nef
vendored
Binary file not shown.
|
@ -57,7 +57,7 @@ type rpcTestCase struct {
|
|||
}
|
||||
|
||||
const testContractHash = "743ed26f78e29ecd595535b74a943b1f9ccbc444"
|
||||
const deploymentTxHash = "8e848d367d6194c0ddc12310e0509c0bb3bf716b0bcd9c10508b4bc9c954408d"
|
||||
const deploymentTxHash = "f4abbf6a5af7b79819378cce1576dd72663a95961010383d67d8c4e1f00fac02"
|
||||
const genesisBlockHash = "a496577895eb8c227bb866dc44f99f21c0cf06417ca8f2a877cc5d761a50dac0"
|
||||
|
||||
const verifyContractHash = "a2eb22340979804cb10cc1add0b8822c201f4d8a"
|
||||
|
@ -1345,7 +1345,7 @@ func checkNep17Balances(t *testing.T, e *executor, acc interface{}) {
|
|||
},
|
||||
{
|
||||
Asset: e.chain.UtilityTokenHash(),
|
||||
Amount: "80009690770",
|
||||
Amount: "80009730770",
|
||||
LastUpdated: 7,
|
||||
}},
|
||||
Address: testchain.PrivateKeyByID(0).GetScriptHash().StringLE(),
|
||||
|
|
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
|
@ -11,7 +11,6 @@ import (
|
|||
"github.com/nspcc-dev/neo-go/pkg/config"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/io"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
)
|
||||
|
||||
// NEO Executable Format 3 (NEF3)
|
||||
|
@ -23,7 +22,6 @@ import (
|
|||
// | Magic | 4 bytes | Magic header |
|
||||
// | Compiler | 32 bytes | Compiler used |
|
||||
// | Version | 16 bytes | Compiler version (Major, Minor, Build, Version) |
|
||||
// | ScriptHash | 20 bytes | ScriptHash for the script (BE) |
|
||||
// +------------+-----------+------------------------------------------------------------+
|
||||
// | Checksum | 4 bytes | First four bytes of double SHA256 hash of the header |
|
||||
// +------------+-----------+------------------------------------------------------------+
|
||||
|
@ -48,10 +46,9 @@ type File struct {
|
|||
|
||||
// Header represents File header.
|
||||
type Header struct {
|
||||
Magic uint32
|
||||
Compiler string
|
||||
Version Version
|
||||
ScriptHash util.Uint160
|
||||
Magic uint32
|
||||
Compiler string
|
||||
Version Version
|
||||
}
|
||||
|
||||
// Version represents compiler version.
|
||||
|
@ -66,9 +63,8 @@ type Version struct {
|
|||
func NewFile(script []byte) (File, error) {
|
||||
file := File{
|
||||
Header: Header{
|
||||
Magic: Magic,
|
||||
Compiler: "neo-go",
|
||||
ScriptHash: hash.Hash160(script),
|
||||
Magic: Magic,
|
||||
Compiler: "neo-go",
|
||||
},
|
||||
Script: script,
|
||||
}
|
||||
|
@ -156,7 +152,6 @@ func (h *Header) EncodeBinary(w *io.BinWriter) {
|
|||
w.WriteBytes(make([]byte, compilerFieldSize-len(bytes)))
|
||||
}
|
||||
h.Version.EncodeBinary(w)
|
||||
h.ScriptHash.EncodeBinary(w)
|
||||
}
|
||||
|
||||
// DecodeBinary implements io.Serializable interface.
|
||||
|
@ -173,7 +168,6 @@ func (h *Header) DecodeBinary(r *io.BinReader) {
|
|||
})
|
||||
h.Compiler = string(buf)
|
||||
h.Version.DecodeBinary(r)
|
||||
h.ScriptHash.DecodeBinary(r)
|
||||
}
|
||||
|
||||
// CalculateChecksum returns first 4 bytes of double-SHA256(Header) converted to uint32.
|
||||
|
@ -207,10 +201,6 @@ func (n *File) DecodeBinary(r *io.BinReader) {
|
|||
r.Err = errors.New("empty script")
|
||||
return
|
||||
}
|
||||
if !hash.Hash160(n.Script).Equals(n.Header.ScriptHash) {
|
||||
r.Err = errors.New("script hashes mismatch")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
// Bytes returns byte array with serialized NEF File.
|
||||
|
|
|
@ -4,8 +4,6 @@ import (
|
|||
"testing"
|
||||
|
||||
"github.com/nspcc-dev/neo-go/internal/testserdes"
|
||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
|
@ -21,7 +19,6 @@ func TestEncodeDecodeBinary(t *testing.T) {
|
|||
Build: 3,
|
||||
Revision: 4,
|
||||
},
|
||||
ScriptHash: hash.Hash160(script),
|
||||
},
|
||||
Script: script,
|
||||
}
|
||||
|
@ -39,7 +36,6 @@ func TestEncodeDecodeBinary(t *testing.T) {
|
|||
|
||||
t.Run("zero-length script", func(t *testing.T) {
|
||||
expected.Script = make([]byte, 0)
|
||||
expected.Header.ScriptHash = hash.Hash160(expected.Script)
|
||||
expected.Checksum = expected.Header.CalculateChecksum()
|
||||
checkDecodeError(t, expected)
|
||||
})
|
||||
|
@ -47,21 +43,12 @@ func TestEncodeDecodeBinary(t *testing.T) {
|
|||
t.Run("invalid script length", func(t *testing.T) {
|
||||
newScript := make([]byte, MaxScriptLength+1)
|
||||
expected.Script = newScript
|
||||
expected.Header.ScriptHash = hash.Hash160(newScript)
|
||||
expected.Checksum = expected.Header.CalculateChecksum()
|
||||
checkDecodeError(t, expected)
|
||||
})
|
||||
|
||||
t.Run("invalid scripthash", func(t *testing.T) {
|
||||
expected.Script = script
|
||||
expected.Header.ScriptHash = util.Uint160{1, 2, 3}
|
||||
expected.Checksum = expected.Header.CalculateChecksum()
|
||||
checkDecodeError(t, expected)
|
||||
})
|
||||
|
||||
t.Run("positive", func(t *testing.T) {
|
||||
expected.Script = script
|
||||
expected.Header.ScriptHash = hash.Hash160(script)
|
||||
expected.Checksum = expected.Header.CalculateChecksum()
|
||||
expected.Header.Magic = Magic
|
||||
testserdes.EncodeDecodeBinary(t, expected, &File{})
|
||||
|
@ -86,7 +73,6 @@ func TestBytesFromBytes(t *testing.T) {
|
|||
Build: 3,
|
||||
Revision: 4,
|
||||
},
|
||||
ScriptHash: hash.Hash160(script),
|
||||
},
|
||||
Script: script,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue