Merge pull request #727 from nspcc-dev/fix-wrong-endian-in-interop-hashes

core: fix wrong endian used in interop functions
This commit is contained in:
Roman Khimov 2020-03-06 19:07:28 +03:00 committed by GitHub
commit 0e8ff558d1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 9 additions and 9 deletions

View file

@ -60,7 +60,7 @@ func (ic *interopContext) headerGetMerkleRoot(v *vm.VM) error {
if err != nil {
return err
}
v.Estack().PushVal(header.MerkleRoot.BytesLE())
v.Estack().PushVal(header.MerkleRoot.BytesBE())
return nil
}
@ -70,7 +70,7 @@ func (ic *interopContext) headerGetNextConsensus(v *vm.VM) error {
if err != nil {
return err
}
v.Estack().PushVal(header.NextConsensus.BytesLE())
v.Estack().PushVal(header.NextConsensus.BytesBE())
return nil
}

View file

@ -147,7 +147,7 @@ func TestHeaderGetMerkleRoot(t *testing.T) {
err := context.headerGetMerkleRoot(v)
require.NoError(t, err)
value := v.Estack().Pop().Value()
require.Equal(t, block.MerkleRoot.BytesLE(), value)
require.Equal(t, block.MerkleRoot.BytesBE(), value)
}
func TestHeaderGetNextConsensus(t *testing.T) {
@ -157,7 +157,7 @@ func TestHeaderGetNextConsensus(t *testing.T) {
err := context.headerGetNextConsensus(v)
require.NoError(t, err)
value := v.Estack().Pop().Value()
require.Equal(t, block.NextConsensus.BytesLE(), value)
require.Equal(t, block.NextConsensus.BytesBE(), value)
}
func TestTxGetAttributes(t *testing.T) {

View file

@ -41,7 +41,7 @@ func getBlockHashFromElement(bc Blockchainer, element *vm.Element) (util.Uint256
}
hash = bc.GetHeaderHash(int(hashint))
} else {
return util.Uint256DecodeBytesLE(hashbytes)
return util.Uint256DecodeBytesBE(hashbytes)
}
return hash, nil
}
@ -102,7 +102,7 @@ func (ic *interopContext) bcGetHeight(v *vm.VM) error {
// returns transaction and its height if it's present in the blockchain.
func getTransactionAndHeight(cd *cachedDao, v *vm.VM) (*transaction.Transaction, uint32, error) {
hashbytes := v.Estack().Pop().Bytes()
hash, err := util.Uint256DecodeBytesLE(hashbytes)
hash, err := util.Uint256DecodeBytesBE(hashbytes)
if err != nil {
return nil, 0, err
}
@ -161,7 +161,7 @@ func (ic *interopContext) headerGetHash(v *vm.VM) error {
if err != nil {
return err
}
v.Estack().PushVal(header.Hash().BytesLE())
v.Estack().PushVal(header.Hash().BytesBE())
return nil
}
@ -171,7 +171,7 @@ func (ic *interopContext) headerGetPrevHash(v *vm.VM) error {
if err != nil {
return err
}
v.Estack().PushVal(header.PrevHash.BytesLE())
v.Estack().PushVal(header.PrevHash.BytesBE())
return nil
}
@ -238,7 +238,7 @@ func (ic *interopContext) txGetHash(v *vm.VM) error {
if !ok {
return errors.New("value is not a transaction")
}
v.Estack().PushVal(tx.Hash().BytesLE())
v.Estack().PushVal(tx.Hash().BytesBE())
return nil
}