mirror of
https://github.com/nspcc-dev/neo-go.git
synced 2024-12-24 09:25:21 +00:00
Merge pull request #1829 from nspcc-dev/change-hashing-scheme
Change hashing scheme
This commit is contained in:
commit
f7d74190f5
17 changed files with 90 additions and 71 deletions
|
@ -22,7 +22,7 @@ func InitAndSave(tx *transaction.Transaction, acc *wallet.Account, filename stri
|
||||||
priv := acc.PrivateKey()
|
priv := acc.PrivateKey()
|
||||||
pub := priv.PublicKey()
|
pub := priv.PublicKey()
|
||||||
sign := priv.Sign(tx.GetSignedPart())
|
sign := priv.Sign(tx.GetSignedPart())
|
||||||
scCtx := context.NewParameterContext("Neo.Core.ContractTransaction", tx)
|
scCtx := context.NewParameterContext("Neo.Core.ContractTransaction", tx.Network, tx)
|
||||||
h, err := address.StringToUint160(acc.Address)
|
h, err := address.StringToUint160(acc.Address)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("invalid address: %s", acc.Address)
|
return fmt.Errorf("invalid address: %s", acc.Address)
|
||||||
|
|
BIN
cli/testdata/chain50x2.acc
vendored
BIN
cli/testdata/chain50x2.acc
vendored
Binary file not shown.
|
@ -112,7 +112,7 @@ func TestBinBlockDecodeEncode(t *testing.T) {
|
||||||
|
|
||||||
assert.NoError(t, testserdes.DecodeBinary(rawblockBytes, b))
|
assert.NoError(t, testserdes.DecodeBinary(rawblockBytes, b))
|
||||||
expected := map[string]bool{ // 1 trans
|
expected := map[string]bool{ // 1 trans
|
||||||
"affad44bb6acacabc058db0bf1e12ab1239ae5e04007b4d4a2ea0cda868e284a": false,
|
"6fcc0c48c5d1b28bb5c2effa1e5b7bb054d22a8c30d409a6a7a3527845229056": false,
|
||||||
}
|
}
|
||||||
|
|
||||||
var hashes []string
|
var hashes []string
|
||||||
|
@ -165,7 +165,7 @@ func TestBlockSizeCalculation(t *testing.T) {
|
||||||
AttributesLen int
|
AttributesLen int
|
||||||
WitnessesLen int
|
WitnessesLen int
|
||||||
}{ // 1 trans
|
}{ // 1 trans
|
||||||
{ID: "affad44bb6acacabc058db0bf1e12ab1239ae5e04007b4d4a2ea0cda868e284a", Size: 864, Version: 0, SignersLen: 2, AttributesLen: 0, WitnessesLen: 2},
|
{ID: "6fcc0c48c5d1b28bb5c2effa1e5b7bb054d22a8c30d409a6a7a3527845229056", Size: 864, Version: 0, SignersLen: 2, AttributesLen: 0, WitnessesLen: 2},
|
||||||
}
|
}
|
||||||
|
|
||||||
for i, tx := range b.Transactions {
|
for i, tx := range b.Transactions {
|
||||||
|
@ -193,7 +193,7 @@ func TestBlockSizeCalculation(t *testing.T) {
|
||||||
|
|
||||||
assert.Equal(t, "DEAZyIVwKWzpgvm8bSzWuVF1awS0QBguORR682YoVfkJ05KGG7pz9OsLBZ9/F1BHO7TCIcEcc8Sr9AcqbonrSRoCDEDhhZnqTUi8tXYbrTBrVj8i9Yxl8NraAMID4DJryWdD6u42OzAHr0of27qc5nojujhLffBfljuBSyQpyeQcUOpyDEAZr7sLz6n4TgNApkwATGXiP/DZ8AummAGDtznrW6Y8XWHngB7F0j3NKvUQ7lyRt11rT+zNjz5R5vIbBrs8C2ktDEDgNW0xGP/OB8CRHXX/l/+0tPO3drkyCddpG9PKCgyd4oEhQu8cwbSv4Q0V1Y0dZcJBoxUB5Qus/U+Xli7jb6OJDEADaXZxdEb56jlYhF4oM8I8KnthEzGw1Q7pfeI97fehTm78ZOJXWIxESThZzI3D2ndVz0Rcdr5MeA/espG6J2ao", base64.StdEncoding.EncodeToString(b.Script.InvocationScript))
|
assert.Equal(t, "DEAZyIVwKWzpgvm8bSzWuVF1awS0QBguORR682YoVfkJ05KGG7pz9OsLBZ9/F1BHO7TCIcEcc8Sr9AcqbonrSRoCDEDhhZnqTUi8tXYbrTBrVj8i9Yxl8NraAMID4DJryWdD6u42OzAHr0of27qc5nojujhLffBfljuBSyQpyeQcUOpyDEAZr7sLz6n4TgNApkwATGXiP/DZ8AummAGDtznrW6Y8XWHngB7F0j3NKvUQ7lyRt11rT+zNjz5R5vIbBrs8C2ktDEDgNW0xGP/OB8CRHXX/l/+0tPO3drkyCddpG9PKCgyd4oEhQu8cwbSv4Q0V1Y0dZcJBoxUB5Qus/U+Xli7jb6OJDEADaXZxdEb56jlYhF4oM8I8KnthEzGw1Q7pfeI97fehTm78ZOJXWIxESThZzI3D2ndVz0Rcdr5MeA/espG6J2ao", base64.StdEncoding.EncodeToString(b.Script.InvocationScript))
|
||||||
assert.Equal(t, "FQwhAwCbdUDhDyVi5f2PrJ6uwlFmpYsm5BI0j/WoaSe/rCKiDCEDAgXpzvrqWh38WAryDI1aokaLsBSPGl5GBfxiLIDmBLoMIQIUuvDO6jpm8X5+HoOeol/YvtbNgua7bmglAYkGX0T/AQwhAj6bMuqJuU0GbmSbEk/VDjlu6RNp6OKmrhsRwXDQIiVtDCEDQI3NQWOW9keDrFh+oeFZPFfZ/qiAyKahkg6SollHeAYMIQKng0vpsy4pgdFXy1u9OstCz9EepcOxAiTXpE6YxZEPGwwhAroscPWZbzV6QxmHBYWfriz+oT4RcpYoAHcrPViKnUq9FwtBE43vrw==", base64.StdEncoding.EncodeToString(b.Script.VerificationScript))
|
assert.Equal(t, "FQwhAwCbdUDhDyVi5f2PrJ6uwlFmpYsm5BI0j/WoaSe/rCKiDCEDAgXpzvrqWh38WAryDI1aokaLsBSPGl5GBfxiLIDmBLoMIQIUuvDO6jpm8X5+HoOeol/YvtbNgua7bmglAYkGX0T/AQwhAj6bMuqJuU0GbmSbEk/VDjlu6RNp6OKmrhsRwXDQIiVtDCEDQI3NQWOW9keDrFh+oeFZPFfZ/qiAyKahkg6SollHeAYMIQKng0vpsy4pgdFXy1u9OstCz9EepcOxAiTXpE6YxZEPGwwhAroscPWZbzV6QxmHBYWfriz+oT4RcpYoAHcrPViKnUq9FwtBE43vrw==", base64.StdEncoding.EncodeToString(b.Script.VerificationScript))
|
||||||
assert.Equal(t, "63d18734a3edbe92a9480b690734b85aaf9c24361d034afbea37d749cfc62d6a", b.Hash().StringLE())
|
assert.Equal(t, "53b3d970ccb235bef785633817f2a947f63bac1f7fa23103f7d080a53f0361f4", b.Hash().StringLE())
|
||||||
|
|
||||||
benc, err := testserdes.EncodeBinary(b)
|
benc, err := testserdes.EncodeBinary(b)
|
||||||
assert.NoError(t, err)
|
assert.NoError(t, err)
|
||||||
|
|
|
@ -110,14 +110,19 @@ func (b *Header) EncodeBinary(bw *io.BinWriter) {
|
||||||
|
|
||||||
// GetSignedPart returns serialized hashable data of the block.
|
// GetSignedPart returns serialized hashable data of the block.
|
||||||
func (b *Header) GetSignedPart() []byte {
|
func (b *Header) GetSignedPart() []byte {
|
||||||
|
if b.hash.Equals(util.Uint256{}) {
|
||||||
|
b.createHash()
|
||||||
|
}
|
||||||
buf := io.NewBufBinWriter()
|
buf := io.NewBufBinWriter()
|
||||||
buf.WriteU32LE(uint32(b.Network))
|
b.writeSignedPart(buf)
|
||||||
// No error can occure while encoding hashable fields.
|
|
||||||
b.encodeHashableFields(buf.BinWriter)
|
|
||||||
|
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (b *Header) writeSignedPart(buf *io.BufBinWriter) {
|
||||||
|
buf.WriteU32LE(uint32(b.Network))
|
||||||
|
buf.WriteBytes(b.hash[:])
|
||||||
|
}
|
||||||
|
|
||||||
// createHash creates the hash of the block.
|
// createHash creates the hash of the block.
|
||||||
// When calculating the hash value of the block, instead of calculating the entire block,
|
// When calculating the hash value of the block, instead of calculating the entire block,
|
||||||
// only first seven fields in the block head will be calculated, which are
|
// only first seven fields in the block head will be calculated, which are
|
||||||
|
@ -125,9 +130,14 @@ func (b *Header) GetSignedPart() []byte {
|
||||||
// Since MerkleRoot already contains the hash value of all transactions,
|
// Since MerkleRoot already contains the hash value of all transactions,
|
||||||
// the modification of transaction will influence the hash value of the block.
|
// the modification of transaction will influence the hash value of the block.
|
||||||
func (b *Header) createHash() {
|
func (b *Header) createHash() {
|
||||||
bb := b.GetSignedPart()
|
buf := io.NewBufBinWriter()
|
||||||
b.verificationHash = hash.Sha256(bb)
|
// No error can occur while encoding hashable fields.
|
||||||
b.hash = hash.Sha256(b.verificationHash.BytesBE())
|
b.encodeHashableFields(buf.BinWriter)
|
||||||
|
|
||||||
|
b.hash = hash.Sha256(buf.Bytes())
|
||||||
|
buf.Reset()
|
||||||
|
b.writeSignedPart(buf)
|
||||||
|
b.verificationHash = hash.Sha256(buf.Bytes())
|
||||||
}
|
}
|
||||||
|
|
||||||
// encodeHashableFields will only encode the fields used for hashing.
|
// encodeHashableFields will only encode the fields used for hashing.
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
"confirmations" : 10883,
|
"confirmations" : 10883,
|
||||||
"previousblockhash" : "0xfd2b68ac95461aa8ecd9ce7817bc0dea12985fc5ca52cfb5c39426e4071c1952",
|
"previousblockhash" : "0xfd2b68ac95461aa8ecd9ce7817bc0dea12985fc5ca52cfb5c39426e4071c1952",
|
||||||
"nextconsensus" : "NgPkjjLTNcQad99iRYeXRUuowE4gxLAnDL",
|
"nextconsensus" : "NgPkjjLTNcQad99iRYeXRUuowE4gxLAnDL",
|
||||||
"hash" : "0x63d18734a3edbe92a9480b690734b85aaf9c24361d034afbea37d749cfc62d6a",
|
"hash" : "0x53b3d970ccb235bef785633817f2a947f63bac1f7fa23103f7d080a53f0361f4",
|
||||||
"witnesses" : [
|
"witnesses" : [
|
||||||
{
|
{
|
||||||
"verification" : "FQwhAwCbdUDhDyVi5f2PrJ6uwlFmpYsm5BI0j/WoaSe/rCKiDCEDAgXpzvrqWh38WAryDI1aokaLsBSPGl5GBfxiLIDmBLoMIQIUuvDO6jpm8X5+HoOeol/YvtbNgua7bmglAYkGX0T/AQwhAj6bMuqJuU0GbmSbEk/VDjlu6RNp6OKmrhsRwXDQIiVtDCEDQI3NQWOW9keDrFh+oeFZPFfZ/qiAyKahkg6SollHeAYMIQKng0vpsy4pgdFXy1u9OstCz9EepcOxAiTXpE6YxZEPGwwhAroscPWZbzV6QxmHBYWfriz+oT4RcpYoAHcrPViKnUq9FwtBE43vrw==",
|
"verification" : "FQwhAwCbdUDhDyVi5f2PrJ6uwlFmpYsm5BI0j/WoaSe/rCKiDCEDAgXpzvrqWh38WAryDI1aokaLsBSPGl5GBfxiLIDmBLoMIQIUuvDO6jpm8X5+HoOeol/YvtbNgua7bmglAYkGX0T/AQwhAj6bMuqJuU0GbmSbEk/VDjlu6RNp6OKmrhsRwXDQIiVtDCEDQI3NQWOW9keDrFh+oeFZPFfZ/qiAyKahkg6SollHeAYMIQKng0vpsy4pgdFXy1u9OstCz9EepcOxAiTXpE6YxZEPGwwhAroscPWZbzV6QxmHBYWfriz+oT4RcpYoAHcrPViKnUq9FwtBE43vrw==",
|
||||||
|
@ -51,4 +51,4 @@
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"merkleroot" : "0x0a4ce89ab8b057ff5f3b421f5c85d3a90db9e613c020b9916096fb5282f719a9"
|
"merkleroot" : "0x0a4ce89ab8b057ff5f3b421f5c85d3a90db9e613c020b9916096fb5282f719a9"
|
||||||
}
|
}
|
||||||
|
|
|
@ -212,6 +212,17 @@ func (t *Transaction) encodeHashableFields(bw *io.BinWriter) {
|
||||||
|
|
||||||
// createHash creates the hash of the transaction.
|
// createHash creates the hash of the transaction.
|
||||||
func (t *Transaction) createHash() error {
|
func (t *Transaction) createHash() error {
|
||||||
|
buf := io.NewBufBinWriter()
|
||||||
|
t.encodeHashableFields(buf.BinWriter)
|
||||||
|
if buf.Err != nil {
|
||||||
|
return buf.Err
|
||||||
|
}
|
||||||
|
|
||||||
|
t.hash = hash.Sha256(buf.Bytes())
|
||||||
|
buf.Reset()
|
||||||
|
t.writeSignedPart(buf)
|
||||||
|
t.verificationHash = hash.Sha256(buf.Bytes())
|
||||||
|
|
||||||
b := t.GetSignedPart()
|
b := t.GetSignedPart()
|
||||||
if b == nil {
|
if b == nil {
|
||||||
return errors.New("failed to serialize hashable data")
|
return errors.New("failed to serialize hashable data")
|
||||||
|
@ -230,7 +241,6 @@ func (t *Transaction) updateHashes(b []byte) {
|
||||||
// GetSignedPart returns a part of the transaction which must be signed.
|
// GetSignedPart returns a part of the transaction which must be signed.
|
||||||
func (t *Transaction) GetSignedPart() []byte {
|
func (t *Transaction) GetSignedPart() []byte {
|
||||||
buf := io.NewBufBinWriter()
|
buf := io.NewBufBinWriter()
|
||||||
buf.WriteU32LE(uint32(t.Network))
|
|
||||||
t.encodeHashableFields(buf.BinWriter)
|
t.encodeHashableFields(buf.BinWriter)
|
||||||
if buf.Err != nil {
|
if buf.Err != nil {
|
||||||
return nil
|
return nil
|
||||||
|
@ -238,10 +248,14 @@ func (t *Transaction) GetSignedPart() []byte {
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (t *Transaction) writeSignedPart(buf *io.BufBinWriter) {
|
||||||
|
buf.WriteU32LE(uint32(t.Network))
|
||||||
|
buf.WriteBytes(t.hash[:])
|
||||||
|
}
|
||||||
|
|
||||||
// DecodeSignedPart decodes a part of transaction from GetSignedPart data.
|
// DecodeSignedPart decodes a part of transaction from GetSignedPart data.
|
||||||
func (t *Transaction) DecodeSignedPart(buf []byte) error {
|
func (t *Transaction) DecodeSignedPart(buf []byte) error {
|
||||||
r := io.NewBinReaderFromBuf(buf)
|
r := io.NewBinReaderFromBuf(buf)
|
||||||
t.Network = netmode.Magic(r.ReadU32LE())
|
|
||||||
t.decodeHashableFields(r)
|
t.decodeHashableFields(r)
|
||||||
if r.Err != nil {
|
if r.Err != nil {
|
||||||
return r.Err
|
return r.Err
|
||||||
|
|
|
@ -50,7 +50,7 @@ func TestDecodeEncodeInvocationTX(t *testing.T) {
|
||||||
assert.Equal(t, int64(9999540), tx.SystemFee)
|
assert.Equal(t, int64(9999540), tx.SystemFee)
|
||||||
assert.Equal(t, int64(8731800), tx.NetworkFee)
|
assert.Equal(t, int64(8731800), tx.NetworkFee)
|
||||||
assert.Equal(t, uint32(6015), tx.ValidUntilBlock)
|
assert.Equal(t, uint32(6015), tx.ValidUntilBlock)
|
||||||
assert.Equal(t, "affad44bb6acacabc058db0bf1e12ab1239ae5e04007b4d4a2ea0cda868e284a", tx.Hash().StringLE())
|
assert.Equal(t, "6fcc0c48c5d1b28bb5c2effa1e5b7bb054d22a8c30d409a6a7a3527845229056", tx.Hash().StringLE())
|
||||||
|
|
||||||
assert.Equal(t, 2, len(tx.Signers))
|
assert.Equal(t, 2, len(tx.Signers))
|
||||||
assert.Equal(t, None, tx.Signers[0].Scopes)
|
assert.Equal(t, None, tx.Signers[0].Scopes)
|
||||||
|
@ -133,7 +133,7 @@ func TestDecodingTxWithInvalidWitnessesNumber(t *testing.T) {
|
||||||
func TestUnmarshalNeoFSTX(t *testing.T) {
|
func TestUnmarshalNeoFSTX(t *testing.T) {
|
||||||
txjson := []byte(`
|
txjson := []byte(`
|
||||||
{
|
{
|
||||||
"hash": "0x635a3624bbe6cf99aee70e9cbd6473d913b6712cad6e717647f3ddf0fd13bfbb",
|
"hash": "0xb229ff232b2adf62ffdae21d892c3e8a71301530ec06037f98f1c6ba77989a09",
|
||||||
"size": 232,
|
"size": 232,
|
||||||
"version": 0,
|
"version": 0,
|
||||||
"nonce": 737880259,
|
"nonce": 737880259,
|
||||||
|
|
|
@ -17,7 +17,7 @@ func TestGenesisBlockMainNet(t *testing.T) {
|
||||||
block, err := createGenesisBlock(cfg.ProtocolConfiguration)
|
block, err := createGenesisBlock(cfg.ProtocolConfiguration)
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
|
|
||||||
expect := "de3bfe3e328af04d48f62bd7a9c533641cc0e1fb6a7741c5119d6a6eaedc5269"
|
expect := "5816ac116af288777c4c454425fb687981f508826ec474810ff9e6b24202fd9a"
|
||||||
assert.Equal(t, expect, block.Hash().StringLE())
|
assert.Equal(t, expect, block.Hash().StringLE())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -84,7 +84,7 @@ func (e *Extensible) DecodeBinary(r *io.BinReader) {
|
||||||
// GetSignedPart implements crypto.Verifiable.
|
// GetSignedPart implements crypto.Verifiable.
|
||||||
func (e *Extensible) GetSignedPart() []byte {
|
func (e *Extensible) GetSignedPart() []byte {
|
||||||
if e.signedpart == nil {
|
if e.signedpart == nil {
|
||||||
e.updateSignedPart()
|
e.createHash()
|
||||||
}
|
}
|
||||||
return e.signedpart
|
return e.signedpart
|
||||||
}
|
}
|
||||||
|
@ -107,21 +107,17 @@ func (e *Extensible) Hash() util.Uint256 {
|
||||||
|
|
||||||
// createHash creates hashes of the payload.
|
// createHash creates hashes of the payload.
|
||||||
func (e *Extensible) createHash() {
|
func (e *Extensible) createHash() {
|
||||||
b := e.GetSignedPart()
|
buf := io.NewBufBinWriter()
|
||||||
e.updateHashes(b)
|
e.encodeBinaryUnsigned(buf.BinWriter)
|
||||||
}
|
e.hash = hash.Sha256(buf.Bytes())
|
||||||
|
e.updateSignedPart()
|
||||||
// updateHashes updates hashes based on the given buffer which should
|
e.signedHash = hash.Sha256(e.signedpart)
|
||||||
// be a signable data slice.
|
|
||||||
func (e *Extensible) updateHashes(b []byte) {
|
|
||||||
e.signedHash = hash.Sha256(b)
|
|
||||||
e.hash = hash.Sha256(e.signedHash.BytesBE())
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateSignedPart updates serialized message if needed.
|
// updateSignedPart updates serialized message if needed.
|
||||||
func (e *Extensible) updateSignedPart() {
|
func (e *Extensible) updateSignedPart() {
|
||||||
w := io.NewBufBinWriter()
|
buf := io.NewBufBinWriter()
|
||||||
w.WriteU32LE(uint32(e.Network))
|
buf.WriteU32LE(uint32(e.Network))
|
||||||
e.encodeBinaryUnsigned(w.BinWriter)
|
buf.WriteBytes(e.hash[:])
|
||||||
e.signedpart = w.Bytes()
|
e.signedpart = buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,32 +71,27 @@ func (r *P2PNotaryRequest) GetSignedHash() util.Uint256 {
|
||||||
|
|
||||||
// GetSignedPart returns a part of the payload which must be signed.
|
// GetSignedPart returns a part of the payload which must be signed.
|
||||||
func (r *P2PNotaryRequest) GetSignedPart() []byte {
|
func (r *P2PNotaryRequest) GetSignedPart() []byte {
|
||||||
|
if r.hash.Equals(util.Uint256{}) {
|
||||||
|
if r.createHash() != nil {
|
||||||
|
panic("failed to compute hash!")
|
||||||
|
}
|
||||||
|
}
|
||||||
buf := io.NewBufBinWriter()
|
buf := io.NewBufBinWriter()
|
||||||
buf.WriteU32LE(uint32(r.Network))
|
buf.WriteU32LE(uint32(r.Network))
|
||||||
r.encodeHashableFields(buf.BinWriter)
|
buf.WriteBytes(r.hash[:])
|
||||||
if buf.Err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
|
||||||
return buf.Bytes()
|
return buf.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
// createHash creates hash of the payload.
|
// createHash creates hash of the payload.
|
||||||
func (r *P2PNotaryRequest) createHash() error {
|
func (r *P2PNotaryRequest) createHash() error {
|
||||||
b := r.GetSignedPart()
|
buf := io.NewBufBinWriter()
|
||||||
if b == nil {
|
r.encodeHashableFields(buf.BinWriter)
|
||||||
return errors.New("failed to serialize hashable data")
|
r.hash = hash.Sha256(buf.Bytes())
|
||||||
}
|
signed := r.GetSignedPart()
|
||||||
r.updateHashes(b)
|
r.signedHash = hash.Sha256(signed)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// updateHashes updates Payload's hashes based on the given buffer which should
|
|
||||||
// be a signable data slice.
|
|
||||||
func (r *P2PNotaryRequest) updateHashes(b []byte) {
|
|
||||||
r.signedHash = hash.Sha256(b)
|
|
||||||
r.hash = hash.Sha256(r.signedHash.BytesBE())
|
|
||||||
}
|
|
||||||
|
|
||||||
// DecodeBinaryUnsigned reads payload from w excluding signature.
|
// DecodeBinaryUnsigned reads payload from w excluding signature.
|
||||||
func (r *P2PNotaryRequest) decodeHashableFields(br *io.BinReader) {
|
func (r *P2PNotaryRequest) decodeHashableFields(br *io.BinReader) {
|
||||||
r.MainTransaction = &transaction.Transaction{Network: r.Network}
|
r.MainTransaction = &transaction.Transaction{Network: r.Network}
|
||||||
|
|
|
@ -6,7 +6,6 @@ import (
|
||||||
"github.com/nspcc-dev/neo-go/internal/random"
|
"github.com/nspcc-dev/neo-go/internal/random"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/hash"
|
|
||||||
"github.com/nspcc-dev/neo-go/pkg/util"
|
"github.com/nspcc-dev/neo-go/pkg/util"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
"github.com/nspcc-dev/neo-go/pkg/vm/opcode"
|
||||||
"github.com/stretchr/testify/require"
|
"github.com/stretchr/testify/require"
|
||||||
|
@ -182,8 +181,8 @@ func TestNotaryRequestBytesFromBytes(t *testing.T) {
|
||||||
VerificationScript: []byte{7, 8, 9},
|
VerificationScript: []byte{7, 8, 9},
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
require.Equal(t, hash.Sha256(p.GetSignedHash().BytesBE()), p.Hash())
|
|
||||||
|
|
||||||
|
_ = p.Hash() // initialize hash caches
|
||||||
bytes, err := p.Bytes()
|
bytes, err := p.Bytes()
|
||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
actual, err := NewP2PNotaryRequestFromBytes(netmode.UnitTestNet, bytes)
|
actual, err := NewP2PNotaryRequestFromBytes(netmode.UnitTestNet, bytes)
|
||||||
|
|
|
@ -50,13 +50,13 @@ const base64B1 = "AAAAAMU1lpLU9L9XS3U0WvRgGV9aU5WoX8f6MWgNjfz89nyeomtq7Iw0SoX9ca
|
||||||
|
|
||||||
const base64TxMoveNeo = "AAIAAADA2KcAAAAAABJ9QwAAAAAAsAQAAAFeEr6oeuuVWIT2+c54RYzMuXwwlQEAWwsCGN31BQwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFF4Svqh665VYhPb5znhFjMy5fDCVFMAfDAh0cmFuc2ZlcgwUg6sGea1VwFChOtQ/WTbqc/XrHvZBYn1bUjkBxgxAihAB65HLkuCPgxiK4X20uEB5iEp/o+tzNxsoZ5abP4o1ZQsj6ZBt4M8VYbeYbA+RIEQtWpUytQ2qKBkt+UmE3AxAG6o6TzGtWUDHkDlVr0WUyG7eKj7Aiu5s+hY2vSySUEqHjwf3DdYc99MUFIBbwz14+i79NVczjRf5TTt/L6z7wwxAiXDUApf9+TWufUaqNk6o2aFWNA+bpOTsJvV/N4FrhtogTLkOZpozxrKHS2bw3dVzwk1LCcr3W8hc8b8D1EpMq5QTDCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4MIQKnvFX+hoTgEZdo0QS6MHlb3MhmGehkrdJhVnI+0YXNYgwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CDCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5pkUC0ETje+v"
|
const base64TxMoveNeo = "AAIAAADA2KcAAAAAABJ9QwAAAAAAsAQAAAFeEr6oeuuVWIT2+c54RYzMuXwwlQEAWwsCGN31BQwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFF4Svqh665VYhPb5znhFjMy5fDCVFMAfDAh0cmFuc2ZlcgwUg6sGea1VwFChOtQ/WTbqc/XrHvZBYn1bUjkBxgxAihAB65HLkuCPgxiK4X20uEB5iEp/o+tzNxsoZ5abP4o1ZQsj6ZBt4M8VYbeYbA+RIEQtWpUytQ2qKBkt+UmE3AxAG6o6TzGtWUDHkDlVr0WUyG7eKj7Aiu5s+hY2vSySUEqHjwf3DdYc99MUFIBbwz14+i79NVczjRf5TTt/L6z7wwxAiXDUApf9+TWufUaqNk6o2aFWNA+bpOTsJvV/N4FrhtogTLkOZpozxrKHS2bw3dVzwk1LCcr3W8hc8b8D1EpMq5QTDCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4MIQKnvFX+hoTgEZdo0QS6MHlb3MhmGehkrdJhVnI+0YXNYgwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CDCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5pkUC0ETje+v"
|
||||||
|
|
||||||
const b1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"size":1433,"nextblockhash":"0x85ab779bc19247aa504c36879ce75cb7f662b4e8067fbc83e5d24ef0afd9a84f","confirmations":6,"hash":"0xea6385e943832b65ee225aaeb31933a97f3362505ab84cfe5dbd91cd1672b9b7","version":0,"previousblockhash":"0x9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5","merkleroot":"0x07a982b6d287d1abbb62bdbfccc540e9e21390bed3a071fd854a348cec6a6ba2","time":1614602006001,"index":1,"nextconsensus":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","primary":0,"witnesses":[{"invocation":"DEBUsre4rmqvJm/6MG4fR0GftVT6xjO05uPWyPrn9rPW/ZcKuUuUvbPYt4dxxGefuMBdQTSbzSrtADERbKHMk8D9DEA4JwDK1q9NM+/S5D6uGgFFe/LFpoR1IJmrRUMkI20jg72IVer5D74YmPMDTjPhBmjsoIHwoPxqu4Fzr2Lo+irDDEBHt3M3UMCT0bVEK5JnHtftT+qol9PtZrhSz2Sr/jQBWkmDCvRE1QZZ/VeHwrnd/63PDVS0dkygjlhnIm0wSJBj","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}],"tx":[{"hash":"0x7c10b90077bddfe9095b2db96bb4ac33994ed1ca99c805410f55c771eee0b77b","size":489,"version":0,"nonce":2,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4422930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBSqis+FnU/kArNOZz8hVoIXlqSI6wwUXhK+qHrrlViE9vnOeEWMzLl8MJUUwB8MCHRyYW5zZmVyDBSDqwZ5rVXAUKE61D9ZNupz9ese9kFifVtSOQ==","witnesses":[{"invocation":"DECKEAHrkcuS4I+DGIrhfbS4QHmISn+j63M3Gyhnlps/ijVlCyPpkG3gzxVht5hsD5EgRC1alTK1DaooGS35SYTcDEAbqjpPMa1ZQMeQOVWvRZTIbt4qPsCK7mz6Fja9LJJQSoePB/cN1hz30xQUgFvDPXj6Lv01VzONF/lNO38vrPvDDECJcNQCl/35Na59Rqo2TqjZoVY0D5uk5Owm9X83gWuG2iBMuQ5mmjPGsodLZvDd1XPCTUsJyvdbyFzxvwPUSkyr","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]},{"hash":"0x41846075f4c5aec54d70b476befb97b35696700454b1168e1ae8888d8fb204a3","size":493,"version":0,"nonce":3,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4426930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwMA6HZIFwAAAAwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFF4Svqh665VYhPb5znhFjMy5fDCVFMAfDAh0cmFuc2ZlcgwUKLOtq3Jp+cIYHbPLdB6/VRkw4nBBYn1bUjk=","witnesses":[{"invocation":"DEA7aJyGTIq0pV20LzVWOCreh6XIxLUCWHVgUFsCTxPOPdqtZBHKnejng3d2BRm/lecTyPLeq7KpRCD9awRvadFWDEBjVZRvSGtGcOEjtUxl4AH5XelYlIUG5k+x3QyYKZtWQc96lUX1hohrNkCmWeWNwC2l8eJGpUxicM+WZGODCVp8DEDbQxvmqRTQ+flc6JetmaqHyw8rfoeQNtmEFpw2cNhyAo5L5Ilp2wbVtJNOJPfw72J7E6FhTK8slIKRqXzpdnyK","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]}]}}`
|
const b1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"size":1433,"nextblockhash":"0x85ab779bc19247aa504c36879ce75cb7f662b4e8067fbc83e5d24ef0afd9a84f","confirmations":6,"hash":"0x5097754aca68e5db86070db369ae4c18bbd021a86dc88fafc5c809afe15e819e","version":0,"previousblockhash":"0x9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5","merkleroot":"0x07a982b6d287d1abbb62bdbfccc540e9e21390bed3a071fd854a348cec6a6ba2","time":1614602006001,"index":1,"nextconsensus":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","primary":0,"witnesses":[{"invocation":"DEBUsre4rmqvJm/6MG4fR0GftVT6xjO05uPWyPrn9rPW/ZcKuUuUvbPYt4dxxGefuMBdQTSbzSrtADERbKHMk8D9DEA4JwDK1q9NM+/S5D6uGgFFe/LFpoR1IJmrRUMkI20jg72IVer5D74YmPMDTjPhBmjsoIHwoPxqu4Fzr2Lo+irDDEBHt3M3UMCT0bVEK5JnHtftT+qol9PtZrhSz2Sr/jQBWkmDCvRE1QZZ/VeHwrnd/63PDVS0dkygjlhnIm0wSJBj","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}],"tx":[{"hash":"0xa10e7ff4103b5fbe57137012e7060760b7b7caffb4dfe70fb45d1cf8a5045b09","size":489,"version":0,"nonce":2,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4422930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBSqis+FnU/kArNOZz8hVoIXlqSI6wwUXhK+qHrrlViE9vnOeEWMzLl8MJUUwB8MCHRyYW5zZmVyDBSDqwZ5rVXAUKE61D9ZNupz9ese9kFifVtSOQ==","witnesses":[{"invocation":"DECKEAHrkcuS4I+DGIrhfbS4QHmISn+j63M3Gyhnlps/ijVlCyPpkG3gzxVht5hsD5EgRC1alTK1DaooGS35SYTcDEAbqjpPMa1ZQMeQOVWvRZTIbt4qPsCK7mz6Fja9LJJQSoePB/cN1hz30xQUgFvDPXj6Lv01VzONF/lNO38vrPvDDECJcNQCl/35Na59Rqo2TqjZoVY0D5uk5Owm9X83gWuG2iBMuQ5mmjPGsodLZvDd1XPCTUsJyvdbyFzxvwPUSkyr","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]},{"hash":"0xcebbbdbd35faeb3d15e9c6e804efdf250fc23685e324bf31c1c142a1b78be5e7","size":493,"version":0,"nonce":3,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4426930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwMA6HZIFwAAAAwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFF4Svqh665VYhPb5znhFjMy5fDCVFMAfDAh0cmFuc2ZlcgwUKLOtq3Jp+cIYHbPLdB6/VRkw4nBBYn1bUjk=","witnesses":[{"invocation":"DEA7aJyGTIq0pV20LzVWOCreh6XIxLUCWHVgUFsCTxPOPdqtZBHKnejng3d2BRm/lecTyPLeq7KpRCD9awRvadFWDEBjVZRvSGtGcOEjtUxl4AH5XelYlIUG5k+x3QyYKZtWQc96lUX1hohrNkCmWeWNwC2l8eJGpUxicM+WZGODCVp8DEDbQxvmqRTQ+flc6JetmaqHyw8rfoeQNtmEFpw2cNhyAo5L5Ilp2wbVtJNOJPfw72J7E6FhTK8slIKRqXzpdnyK","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]}]}}`
|
||||||
|
|
||||||
const base64Header1 = "AAAAAMU1lpLU9L9XS3U0WvRgGV9aU5WoX8f6MWgNjfz89nyeomtq7Iw0SoX9caDTvpAT4ulAxcy/vWK7q9GH0raCqQfxbcftdwEAAAEAAAAAXhK+qHrrlViE9vnOeEWMzLl8MJUBxgxAVLK3uK5qryZv+jBuH0dBn7VU+sYztObj1sj65/az1v2XCrlLlL2z2LeHccRnn7jAXUE0m80q7QAxEWyhzJPA/QxAOCcAytavTTPv0uQ+rhoBRXvyxaaEdSCZq0VDJCNtI4O9iFXq+Q++GJjzA04z4QZo7KCB8KD8aruBc69i6PoqwwxAR7dzN1DAk9G1RCuSZx7X7U/qqJfT7Wa4Us9kq/40AVpJgwr0RNUGWf1Xh8K53f+tzw1UtHZMoI5YZyJtMEiQY5QTDCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4MIQKnvFX+hoTgEZdo0QS6MHlb3MhmGehkrdJhVnI+0YXNYgwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CDCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5pkUC0ETje+vAA=="
|
const base64Header1 = "AAAAAMU1lpLU9L9XS3U0WvRgGV9aU5WoX8f6MWgNjfz89nyeomtq7Iw0SoX9caDTvpAT4ulAxcy/vWK7q9GH0raCqQfxbcftdwEAAAEAAAAAXhK+qHrrlViE9vnOeEWMzLl8MJUBxgxAVLK3uK5qryZv+jBuH0dBn7VU+sYztObj1sj65/az1v2XCrlLlL2z2LeHccRnn7jAXUE0m80q7QAxEWyhzJPA/QxAOCcAytavTTPv0uQ+rhoBRXvyxaaEdSCZq0VDJCNtI4O9iFXq+Q++GJjzA04z4QZo7KCB8KD8aruBc69i6PoqwwxAR7dzN1DAk9G1RCuSZx7X7U/qqJfT7Wa4Us9kq/40AVpJgwr0RNUGWf1Xh8K53f+tzw1UtHZMoI5YZyJtMEiQY5QTDCECEDp/fdAWVYWX95YNJ8UWpDlP2Wi55lFV60sBPkBAQG4MIQKnvFX+hoTgEZdo0QS6MHlb3MhmGehkrdJhVnI+0YXNYgwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CDCED2QwH32PmkM53kS4Qq1GsyUS2aGAje2CMT4+DCece5pkUC0ETje+vAA=="
|
||||||
|
|
||||||
const header1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"hash":"0xea6385e943832b65ee225aaeb31933a97f3362505ab84cfe5dbd91cd1672b9b7","size":451,"version":0,"previousblockhash":"0x9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5","merkleroot":"0x07a982b6d287d1abbb62bdbfccc540e9e21390bed3a071fd854a348cec6a6ba2","time":1614602006001,"index":1,"nextconsensus":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","witnesses":[{"invocation":"DEBUsre4rmqvJm/6MG4fR0GftVT6xjO05uPWyPrn9rPW/ZcKuUuUvbPYt4dxxGefuMBdQTSbzSrtADERbKHMk8D9DEA4JwDK1q9NM+/S5D6uGgFFe/LFpoR1IJmrRUMkI20jg72IVer5D74YmPMDTjPhBmjsoIHwoPxqu4Fzr2Lo+irDDEBHt3M3UMCT0bVEK5JnHtftT+qol9PtZrhSz2Sr/jQBWkmDCvRE1QZZ/VeHwrnd/63PDVS0dkygjlhnIm0wSJBj","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}],"confirmations":6,"nextblockhash":"0x85ab779bc19247aa504c36879ce75cb7f662b4e8067fbc83e5d24ef0afd9a84f"}}`
|
const header1Verbose = `{"id":5,"jsonrpc":"2.0","result":{"hash":"0x5097754aca68e5db86070db369ae4c18bbd021a86dc88fafc5c809afe15e819e","size":451,"version":0,"previousblockhash":"0x9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5","merkleroot":"0x07a982b6d287d1abbb62bdbfccc540e9e21390bed3a071fd854a348cec6a6ba2","time":1614602006001,"index":1,"nextconsensus":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","witnesses":[{"invocation":"DEBUsre4rmqvJm/6MG4fR0GftVT6xjO05uPWyPrn9rPW/ZcKuUuUvbPYt4dxxGefuMBdQTSbzSrtADERbKHMk8D9DEA4JwDK1q9NM+/S5D6uGgFFe/LFpoR1IJmrRUMkI20jg72IVer5D74YmPMDTjPhBmjsoIHwoPxqu4Fzr2Lo+irDDEBHt3M3UMCT0bVEK5JnHtftT+qol9PtZrhSz2Sr/jQBWkmDCvRE1QZZ/VeHwrnd/63PDVS0dkygjlhnIm0wSJBj","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}],"confirmations":6,"nextblockhash":"0x85ab779bc19247aa504c36879ce75cb7f662b4e8067fbc83e5d24ef0afd9a84f"}}`
|
||||||
|
|
||||||
const txMoveNeoVerbose = `{"id":5,"jsonrpc":"2.0","result":{"blockhash":"0xea6385e943832b65ee225aaeb31933a97f3362505ab84cfe5dbd91cd1672b9b7","confirmations":6,"blocktime":1614602006001,"vmstate":"HALT","hash":"0x7c10b90077bddfe9095b2db96bb4ac33994ed1ca99c805410f55c771eee0b77b","size":489,"version":0,"nonce":2,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4422930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBSqis+FnU/kArNOZz8hVoIXlqSI6wwUXhK+qHrrlViE9vnOeEWMzLl8MJUUwB8MCHRyYW5zZmVyDBSDqwZ5rVXAUKE61D9ZNupz9ese9kFifVtSOQ==","witnesses":[{"invocation":"DECKEAHrkcuS4I+DGIrhfbS4QHmISn+j63M3Gyhnlps/ijVlCyPpkG3gzxVht5hsD5EgRC1alTK1DaooGS35SYTcDEAbqjpPMa1ZQMeQOVWvRZTIbt4qPsCK7mz6Fja9LJJQSoePB/cN1hz30xQUgFvDPXj6Lv01VzONF/lNO38vrPvDDECJcNQCl/35Na59Rqo2TqjZoVY0D5uk5Owm9X83gWuG2iBMuQ5mmjPGsodLZvDd1XPCTUsJyvdbyFzxvwPUSkyr","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]}}`
|
const txMoveNeoVerbose = `{"id":5,"jsonrpc":"2.0","result":{"blockhash":"0x5097754aca68e5db86070db369ae4c18bbd021a86dc88fafc5c809afe15e819e","confirmations":6,"blocktime":1614602006001,"vmstate":"HALT","hash":"0xa10e7ff4103b5fbe57137012e7060760b7b7caffb4dfe70fb45d1cf8a5045b09","size":489,"version":0,"nonce":2,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4422930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBSqis+FnU/kArNOZz8hVoIXlqSI6wwUXhK+qHrrlViE9vnOeEWMzLl8MJUUwB8MCHRyYW5zZmVyDBSDqwZ5rVXAUKE61D9ZNupz9ese9kFifVtSOQ==","witnesses":[{"invocation":"DECKEAHrkcuS4I+DGIrhfbS4QHmISn+j63M3Gyhnlps/ijVlCyPpkG3gzxVht5hsD5EgRC1alTK1DaooGS35SYTcDEAbqjpPMa1ZQMeQOVWvRZTIbt4qPsCK7mz6Fja9LJJQSoePB/cN1hz30xQUgFvDPXj6Lv01VzONF/lNO38vrPvDDECJcNQCl/35Na59Rqo2TqjZoVY0D5uk5Owm9X83gWuG2iBMuQ5mmjPGsodLZvDd1XPCTUsJyvdbyFzxvwPUSkyr","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]}}`
|
||||||
|
|
||||||
// getResultBlock1 returns data for block number 1 which is used by several tests.
|
// getResultBlock1 returns data for block number 1 which is used by several tests.
|
||||||
func getResultBlock1() *result.Block {
|
func getResultBlock1() *result.Block {
|
||||||
|
|
|
@ -118,7 +118,7 @@ func TestWSClientEvents(t *testing.T) {
|
||||||
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"container":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","trigger":"Application","vmstate":"HALT","gasconsumed":"22910000","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","eventname":"contract call","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","eventname":"transfer","state":{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}}]}]}`,
|
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"container":"0xe1cd5e57e721d2a2e05fb1f08721b12057b25ab1dd7fd0f33ee1639932fdfad7","trigger":"Application","vmstate":"HALT","gasconsumed":"22910000","stack":[],"notifications":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","eventname":"contract call","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}},{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","eventname":"transfer","state":{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}}]}]}`,
|
||||||
`{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","eventname":"contract call","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}}]}`,
|
`{"jsonrpc":"2.0","method":"notification_from_execution","params":[{"contract":"0x1b4357bff5a01bdf2a6581247cf9ed1e24629176","eventname":"contract call","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"dpFiJB7t+XwkgWUq3xug9b9XQxs="},{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"Integer","value":"1000"}]}]}}]}`,
|
||||||
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"container":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","trigger":"Application","vmstate":"HALT","gasconsumed":"6042610","stack":[],"notifications":[{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","eventname":"contract call","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}]}},{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","eventname":"transfer","state":{"type":"Array","value":[{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}}]}]}`,
|
`{"jsonrpc":"2.0","method":"transaction_executed","params":[{"container":"0xf97a72b7722c109f909a8bc16c22368c5023d85828b09b127b237aace33cf099","trigger":"Application","vmstate":"HALT","gasconsumed":"6042610","stack":[],"notifications":[{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","eventname":"contract call","state":{"type":"Array","value":[{"type":"ByteString","value":"dHJhbnNmZXI="},{"type":"Array","value":[{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}]}},{"contract":"0xe65ff7b3a02d207b584a5c27057d4e9862ef01da","eventname":"transfer","state":{"type":"Array","value":[{"type":"ByteString","value":"MW6FEDkBnTnfwsN9bD/uGf1YCYc="},{"type":"ByteString","value":"IHKCdK+vw29DoHHTKM+j5inZy7A="},{"type":"Integer","value":"123"}]}}]}]}`,
|
||||||
`{"jsonrpc":"2.0","method":"block_added","params":[{"size":1433,"nextblockhash":"0x85ab779bc19247aa504c36879ce75cb7f662b4e8067fbc83e5d24ef0afd9a84f","confirmations":6,"hash":"0xea6385e943832b65ee225aaeb31933a97f3362505ab84cfe5dbd91cd1672b9b7","version":0,"previousblockhash":"0x9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5","merkleroot":"0x07a982b6d287d1abbb62bdbfccc540e9e21390bed3a071fd854a348cec6a6ba2","time":1614602006001,"index":1,"nextconsensus":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","primary":0,"witnesses":[{"invocation":"DEBUsre4rmqvJm/6MG4fR0GftVT6xjO05uPWyPrn9rPW/ZcKuUuUvbPYt4dxxGefuMBdQTSbzSrtADERbKHMk8D9DEA4JwDK1q9NM+/S5D6uGgFFe/LFpoR1IJmrRUMkI20jg72IVer5D74YmPMDTjPhBmjsoIHwoPxqu4Fzr2Lo+irDDEBHt3M3UMCT0bVEK5JnHtftT+qol9PtZrhSz2Sr/jQBWkmDCvRE1QZZ/VeHwrnd/63PDVS0dkygjlhnIm0wSJBj","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}],"tx":[{"hash":"0x7c10b90077bddfe9095b2db96bb4ac33994ed1ca99c805410f55c771eee0b77b","size":489,"version":0,"nonce":2,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4422930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBSqis+FnU/kArNOZz8hVoIXlqSI6wwUXhK+qHrrlViE9vnOeEWMzLl8MJUUwB8MCHRyYW5zZmVyDBSDqwZ5rVXAUKE61D9ZNupz9ese9kFifVtSOQ==","witnesses":[{"invocation":"DECKEAHrkcuS4I+DGIrhfbS4QHmISn+j63M3Gyhnlps/ijVlCyPpkG3gzxVht5hsD5EgRC1alTK1DaooGS35SYTcDEAbqjpPMa1ZQMeQOVWvRZTIbt4qPsCK7mz6Fja9LJJQSoePB/cN1hz30xQUgFvDPXj6Lv01VzONF/lNO38vrPvDDECJcNQCl/35Na59Rqo2TqjZoVY0D5uk5Owm9X83gWuG2iBMuQ5mmjPGsodLZvDd1XPCTUsJyvdbyFzxvwPUSkyr","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]},{"hash":"0x41846075f4c5aec54d70b476befb97b35696700454b1168e1ae8888d8fb204a3","size":493,"version":0,"nonce":3,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4426930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwMA6HZIFwAAAAwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFF4Svqh665VYhPb5znhFjMy5fDCVFMAfDAh0cmFuc2ZlcgwUKLOtq3Jp+cIYHbPLdB6/VRkw4nBBYn1bUjk=","witnesses":[{"invocation":"DEA7aJyGTIq0pV20LzVWOCreh6XIxLUCWHVgUFsCTxPOPdqtZBHKnejng3d2BRm/lecTyPLeq7KpRCD9awRvadFWDEBjVZRvSGtGcOEjtUxl4AH5XelYlIUG5k+x3QyYKZtWQc96lUX1hohrNkCmWeWNwC2l8eJGpUxicM+WZGODCVp8DEDbQxvmqRTQ+flc6JetmaqHyw8rfoeQNtmEFpw2cNhyAo5L5Ilp2wbVtJNOJPfw72J7E6FhTK8slIKRqXzpdnyK","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]}]}]}`,
|
`{"jsonrpc":"2.0","method":"block_added","params":[{"size":1433,"nextblockhash":"0x85ab779bc19247aa504c36879ce75cb7f662b4e8067fbc83e5d24ef0afd9a84f","confirmations":6,"hash":"0x5097754aca68e5db86070db369ae4c18bbd021a86dc88fafc5c809afe15e819e","version":0,"previousblockhash":"0x9e7cf6fcfc8d0d6831fac75fa895535a5f1960f45a34754b57bff4d4929635c5","merkleroot":"0x07a982b6d287d1abbb62bdbfccc540e9e21390bed3a071fd854a348cec6a6ba2","time":1614602006001,"index":1,"nextconsensus":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","primary":0,"witnesses":[{"invocation":"DEBUsre4rmqvJm/6MG4fR0GftVT6xjO05uPWyPrn9rPW/ZcKuUuUvbPYt4dxxGefuMBdQTSbzSrtADERbKHMk8D9DEA4JwDK1q9NM+/S5D6uGgFFe/LFpoR1IJmrRUMkI20jg72IVer5D74YmPMDTjPhBmjsoIHwoPxqu4Fzr2Lo+irDDEBHt3M3UMCT0bVEK5JnHtftT+qol9PtZrhSz2Sr/jQBWkmDCvRE1QZZ/VeHwrnd/63PDVS0dkygjlhnIm0wSJBj","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}],"tx":[{"hash":"0xa10e7ff4103b5fbe57137012e7060760b7b7caffb4dfe70fb45d1cf8a5045b09","size":489,"version":0,"nonce":2,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4422930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwIY3fUFDBSqis+FnU/kArNOZz8hVoIXlqSI6wwUXhK+qHrrlViE9vnOeEWMzLl8MJUUwB8MCHRyYW5zZmVyDBSDqwZ5rVXAUKE61D9ZNupz9ese9kFifVtSOQ==","witnesses":[{"invocation":"DECKEAHrkcuS4I+DGIrhfbS4QHmISn+j63M3Gyhnlps/ijVlCyPpkG3gzxVht5hsD5EgRC1alTK1DaooGS35SYTcDEAbqjpPMa1ZQMeQOVWvRZTIbt4qPsCK7mz6Fja9LJJQSoePB/cN1hz30xQUgFvDPXj6Lv01VzONF/lNO38vrPvDDECJcNQCl/35Na59Rqo2TqjZoVY0D5uk5Owm9X83gWuG2iBMuQ5mmjPGsodLZvDd1XPCTUsJyvdbyFzxvwPUSkyr","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]},{"hash":"0xcebbbdbd35faeb3d15e9c6e804efdf250fc23685e324bf31c1c142a1b78be5e7","size":493,"version":0,"nonce":3,"sender":"NUVPACMnKFhpuHjsRjhUvXz1XhqfGZYVtY","sysfee":"11000000","netfee":"4426930","validuntilblock":1200,"attributes":[],"signers":[{"account":"0x95307cb9cc8c4578cef9f6845895eb7aa8be125e","scopes":"CalledByEntry"}],"script":"CwMA6HZIFwAAAAwUqorPhZ1P5AKzTmc/IVaCF5akiOsMFF4Svqh665VYhPb5znhFjMy5fDCVFMAfDAh0cmFuc2ZlcgwUKLOtq3Jp+cIYHbPLdB6/VRkw4nBBYn1bUjk=","witnesses":[{"invocation":"DEA7aJyGTIq0pV20LzVWOCreh6XIxLUCWHVgUFsCTxPOPdqtZBHKnejng3d2BRm/lecTyPLeq7KpRCD9awRvadFWDEBjVZRvSGtGcOEjtUxl4AH5XelYlIUG5k+x3QyYKZtWQc96lUX1hohrNkCmWeWNwC2l8eJGpUxicM+WZGODCVp8DEDbQxvmqRTQ+flc6JetmaqHyw8rfoeQNtmEFpw2cNhyAo5L5Ilp2wbVtJNOJPfw72J7E6FhTK8slIKRqXzpdnyK","verification":"EwwhAhA6f33QFlWFl/eWDSfFFqQ5T9loueZRVetLAT5AQEBuDCECp7xV/oaE4BGXaNEEujB5W9zIZhnoZK3SYVZyPtGFzWIMIQKzYiv0AXvf4xfFiu1fTHU/IGt9uJYEb6fXdLvEv3+NwgwhA9kMB99j5pDOd5EuEKtRrMlEtmhgI3tgjE+PgwnnHuaZFAtBE43vrw=="}]}]}]}`,
|
||||||
`{"jsonrpc":"2.0","method":"event_missed","params":[]}`,
|
`{"jsonrpc":"2.0","method":"event_missed","params":[]}`,
|
||||||
}
|
}
|
||||||
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
srv := httptest.NewServer(http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
|
||||||
|
|
|
@ -60,8 +60,8 @@ type rpcTestCase struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
const testContractHash = "1e1c3024bd955ff3baf7cb92e3b7608c7bb3712b"
|
const testContractHash = "1e1c3024bd955ff3baf7cb92e3b7608c7bb3712b"
|
||||||
const deploymentTxHash = "7cf43b182dee2e8bd2c5209cd230799aeba1b5b13000db682d917c89eacd1eae"
|
const deploymentTxHash = "b67eb38f1e6805d60b68cbec9cf8db7e4a71313b6f53ff8545c578b51ce874c5"
|
||||||
const genesisBlockHash = "d237e3500d8b4cf0df3fd9c4c053016afae141207a6c732303bdd91aff444ecc"
|
const genesisBlockHash = "5b60644c6c6f58faca72c70689d7ed1f40c2e795772bd0de5a88e983ad55080c"
|
||||||
|
|
||||||
const verifyContractHash = "5bb4bac40e961e334ba7bd36d2496010f67e246e"
|
const verifyContractHash = "5bb4bac40e961e334ba7bd36d2496010f67e246e"
|
||||||
const verifyContractAVM = "VwMAQS1RCDAhcAwUVVQtU+0PVUb61E1umZEoZwIvzl7bMHFoE87bKGnbKJdA"
|
const verifyContractAVM = "VwMAQS1RCDAhcAwUVVQtU+0PVUb61E1umZEoZwIvzl7bMHFoE87bKGnbKJdA"
|
||||||
|
@ -865,13 +865,12 @@ var rpcTestCases = map[string][]rpcTestCase{
|
||||||
"sendrawtransaction": {
|
"sendrawtransaction": {
|
||||||
{
|
{
|
||||||
name: "positive",
|
name: "positive",
|
||||||
params: `["ADQSAADA2KcAAAAAABDiEgAAAAAAgBYAAAFVVC1T7Q9VRvrUTW6ZkShnAi/OXgEAYBDAAwDodkgXAAAADBRdSe/t0S4+BgGLRljbEKiXX8gLTgwUVVQtU+0PVUb61E1umZEoZwIvzl4UwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQFCDEAppqgOf7RZvrS+uOVzVNlcQAQnyujtzHzv9/Za+FFkxWFd8mZ6AvWnFXAL0W5NafW4xyP7Kp/qgWCmZrHINaLkKAwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CQXR0dqo="]`,
|
params: `["ADQSAADA2KcAAAAAABDiEgAAAAAAgBYAAAFVVC1T7Q9VRvrUTW6ZkShnAi/OXgEAYBDAAwDodkgXAAAADBRdSe/t0S4+BgGLRljbEKiXX8gLTgwUVVQtU+0PVUb61E1umZEoZwIvzl4UwB8MCHRyYW5zZmVyDBT1Y+pAvCg9TQ4FxI6jBbPyoHNA70FifVtSOQFCDEAOJpFi9vI44kaLJcBvEyqSO9Q76XluNyozh0lBueRwXMijYJa1Zlp5jLkqCsmNsEaF1kCpIQ+2wtpDT+HHZGI4KAwhArNiK/QBe9/jF8WK7V9MdT8ga324lgRvp9d0u8S/f43CQXR0dqo="]`,
|
||||||
result: func(e *executor) interface{} { return &result.RelayResult{} },
|
result: func(e *executor) interface{} { return &result.RelayResult{} },
|
||||||
check: func(t *testing.T, e *executor, inv interface{}) {
|
check: func(t *testing.T, e *executor, inv interface{}) {
|
||||||
res, ok := inv.(*result.RelayResult)
|
res, ok := inv.(*result.RelayResult)
|
||||||
require.True(t, ok)
|
require.True(t, ok)
|
||||||
expectedHash, err := util.Uint256DecodeStringLE("3b133d0c2912da4f99680ae3a5f0e178bc761f2c360662a1fabbe1a8dbe309ea")
|
expectedHash := util.Uint256{0x6c, 0x8d, 0x40, 0xba, 0x91, 0xde, 0xe8, 0x74, 0xf0, 0x24, 0xc3, 0xbc, 0xb6, 0x8e, 0x7e, 0xf4, 0xf5, 0x77, 0xd7, 0x6c, 0x9f, 0x10, 0x66, 0xb7, 0xc3, 0xab, 0x71, 0xd, 0x19, 0x1a, 0xeb, 0xac}
|
||||||
require.NoError(t, err)
|
|
||||||
assert.Equal(t, expectedHash, res.Hash)
|
assert.Equal(t, expectedHash, res.Hash)
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
|
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
BIN
pkg/rpc/server/testdata/testblocks.acc
vendored
Binary file not shown.
|
@ -9,6 +9,7 @@ import (
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/nspcc-dev/neo-go/pkg/config/netmode"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
"github.com/nspcc-dev/neo-go/pkg/core/transaction"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto"
|
"github.com/nspcc-dev/neo-go/pkg/crypto"
|
||||||
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
"github.com/nspcc-dev/neo-go/pkg/crypto/keys"
|
||||||
|
@ -24,6 +25,8 @@ import (
|
||||||
type ParameterContext struct {
|
type ParameterContext struct {
|
||||||
// Type is a type of a verifiable item.
|
// Type is a type of a verifiable item.
|
||||||
Type string
|
Type string
|
||||||
|
// Network is a network this context belongs to.
|
||||||
|
Network netmode.Magic
|
||||||
// Verifiable is an object which can be (de-)serialized.
|
// Verifiable is an object which can be (de-)serialized.
|
||||||
Verifiable crypto.VerifiableDecodable
|
Verifiable crypto.VerifiableDecodable
|
||||||
// Items is a map from script hashes to context items.
|
// Items is a map from script hashes to context items.
|
||||||
|
@ -32,7 +35,8 @@ type ParameterContext struct {
|
||||||
|
|
||||||
type paramContext struct {
|
type paramContext struct {
|
||||||
Type string `json:"type"`
|
Type string `json:"type"`
|
||||||
Hex string `json:"hex"`
|
Net uint32 `json:"network"`
|
||||||
|
Data []byte `json:"data"`
|
||||||
Items map[string]json.RawMessage `json:"items"`
|
Items map[string]json.RawMessage `json:"items"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -42,9 +46,10 @@ type sigWithIndex struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewParameterContext returns ParameterContext with the specified type and item to sign.
|
// NewParameterContext returns ParameterContext with the specified type and item to sign.
|
||||||
func NewParameterContext(typ string, verif crypto.VerifiableDecodable) *ParameterContext {
|
func NewParameterContext(typ string, network netmode.Magic, verif crypto.VerifiableDecodable) *ParameterContext {
|
||||||
return &ParameterContext{
|
return &ParameterContext{
|
||||||
Type: typ,
|
Type: typ,
|
||||||
|
Network: network,
|
||||||
Verifiable: verif,
|
Verifiable: verif,
|
||||||
Items: make(map[util.Uint160]*Item),
|
Items: make(map[util.Uint160]*Item),
|
||||||
}
|
}
|
||||||
|
@ -164,7 +169,8 @@ func (c ParameterContext) MarshalJSON() ([]byte, error) {
|
||||||
}
|
}
|
||||||
pc := ¶mContext{
|
pc := ¶mContext{
|
||||||
Type: c.Type,
|
Type: c.Type,
|
||||||
Hex: hex.EncodeToString(verif),
|
Net: uint32(c.Network),
|
||||||
|
Data: verif,
|
||||||
Items: items,
|
Items: items,
|
||||||
}
|
}
|
||||||
return json.Marshal(pc)
|
return json.Marshal(pc)
|
||||||
|
@ -176,19 +182,17 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error {
|
||||||
if err := json.Unmarshal(data, pc); err != nil {
|
if err := json.Unmarshal(data, pc); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
data, err := hex.DecodeString(pc.Hex)
|
|
||||||
if err != nil {
|
|
||||||
return err
|
|
||||||
}
|
|
||||||
|
|
||||||
var verif crypto.VerifiableDecodable
|
var verif crypto.VerifiableDecodable
|
||||||
switch pc.Type {
|
switch pc.Type {
|
||||||
case "Neo.Core.ContractTransaction":
|
case "Neo.Core.ContractTransaction":
|
||||||
verif = new(transaction.Transaction)
|
tx := new(transaction.Transaction)
|
||||||
|
tx.Network = netmode.Magic(pc.Net)
|
||||||
|
verif = tx
|
||||||
default:
|
default:
|
||||||
return fmt.Errorf("unsupported type: %s", c.Type)
|
return fmt.Errorf("unsupported type: %s", c.Type)
|
||||||
}
|
}
|
||||||
err = verif.DecodeSignedPart(data)
|
err := verif.DecodeSignedPart(pc.Data)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
@ -205,6 +209,7 @@ func (c *ParameterContext) UnmarshalJSON(data []byte) error {
|
||||||
items[u] = item
|
items[u] = item
|
||||||
}
|
}
|
||||||
c.Type = pc.Type
|
c.Type = pc.Type
|
||||||
|
c.Network = netmode.Magic(pc.Net)
|
||||||
c.Verifiable = verif
|
c.Verifiable = verif
|
||||||
c.Items = items
|
c.Items = items
|
||||||
return nil
|
return nil
|
||||||
|
|
|
@ -27,7 +27,7 @@ func TestParameterContext_AddSignatureSimpleContract(t *testing.T) {
|
||||||
sig := priv.Sign(tx.GetSignedPart())
|
sig := priv.Sign(tx.GetSignedPart())
|
||||||
|
|
||||||
t.Run("invalid contract", func(t *testing.T) {
|
t.Run("invalid contract", func(t *testing.T) {
|
||||||
c := NewParameterContext("Neo.Core.ContractTransaction", tx)
|
c := NewParameterContext("Neo.Core.ContractTransaction", netmode.UnitTestNet, tx)
|
||||||
ctr := &wallet.Contract{
|
ctr := &wallet.Contract{
|
||||||
Script: pub.GetVerificationScript(),
|
Script: pub.GetVerificationScript(),
|
||||||
Parameters: []wallet.ContractParam{
|
Parameters: []wallet.ContractParam{
|
||||||
|
@ -47,7 +47,7 @@ func TestParameterContext_AddSignatureSimpleContract(t *testing.T) {
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
c := NewParameterContext("Neo.Core.ContractTransaction", tx)
|
c := NewParameterContext("Neo.Core.ContractTransaction", netmode.UnitTestNet, tx)
|
||||||
ctr := &wallet.Contract{
|
ctr := &wallet.Contract{
|
||||||
Script: pub.GetVerificationScript(),
|
Script: pub.GetVerificationScript(),
|
||||||
Parameters: []wallet.ContractParam{newParam(smartcontract.SignatureType, "parameter0")},
|
Parameters: []wallet.ContractParam{newParam(smartcontract.SignatureType, "parameter0")},
|
||||||
|
@ -77,7 +77,7 @@ func TestParameterContext_AddSignatureSimpleContract(t *testing.T) {
|
||||||
|
|
||||||
func TestParameterContext_AddSignatureMultisig(t *testing.T) {
|
func TestParameterContext_AddSignatureMultisig(t *testing.T) {
|
||||||
tx := getContractTx()
|
tx := getContractTx()
|
||||||
c := NewParameterContext("Neo.Core.ContractTransaction", tx)
|
c := NewParameterContext("Neo.Core.ContractTransaction", netmode.UnitTestNet, tx)
|
||||||
privs, pubs := getPrivateKeys(t, 4)
|
privs, pubs := getPrivateKeys(t, 4)
|
||||||
pubsCopy := keys.PublicKeys(pubs).Copy()
|
pubsCopy := keys.PublicKeys(pubs).Copy()
|
||||||
script, err := smartcontract.CreateMultiSigRedeemScript(3, pubsCopy)
|
script, err := smartcontract.CreateMultiSigRedeemScript(3, pubsCopy)
|
||||||
|
@ -137,6 +137,7 @@ func TestParameterContext_MarshalJSON(t *testing.T) {
|
||||||
|
|
||||||
expected := &ParameterContext{
|
expected := &ParameterContext{
|
||||||
Type: "Neo.Core.ContractTransaction",
|
Type: "Neo.Core.ContractTransaction",
|
||||||
|
Network: netmode.UnitTestNet,
|
||||||
Verifiable: tx,
|
Verifiable: tx,
|
||||||
Items: map[util.Uint160]*Item{
|
Items: map[util.Uint160]*Item{
|
||||||
priv.GetScriptHash(): {
|
priv.GetScriptHash(): {
|
||||||
|
|
Loading…
Reference in a new issue