Merge pull request #1386 from nspcc-dev/fix-neo-utxo-tracking

core: fix NEO UTXO tracking, drop Fixed8 multiplier
This commit is contained in:
Roman Khimov 2020-09-04 15:40:24 +03:00 committed by GitHub
commit 04ebef9119
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 4 deletions

View file

@ -933,10 +933,15 @@ func processTransfer(cache *dao.Cached, tx *transaction.Transaction, b *block.Bl
if !isGoverning && !out.AssetID.Equals(UtilityTokenID()) {
return nil
}
var amount = int64(out.Amount)
// NEO has no fractional part and Fixed8 representation is just misleading here.
if isGoverning {
amount = out.Amount.IntegralValue()
}
tr := &state.Transfer{
IsGoverning: isGoverning,
IsSent: isSent,
Amount: int64(out.Amount),
Amount: amount,
Block: b.Index,
Timestamp: b.Timestamp,
Tx: tx.Hash(),

View file

@ -1288,7 +1288,7 @@ func checkTransfers(t *testing.T, e *executor, acc interface{}, asset string, st
u := getUTXOForBlock(res, false, "neo", 1)
if start <= 1 && (stop == 0 || stop >= 1) && (asset == "neo" || asset == "") {
require.NotNil(t, u)
require.EqualValues(t, int64(util.Fixed8FromInt64(99999000)), u.Amount)
require.EqualValues(t, int64(99999000), u.Amount)
} else {
require.Nil(t, u)
}
@ -1306,7 +1306,7 @@ func checkTransfers(t *testing.T, e *executor, acc interface{}, asset string, st
u = getUTXOForBlock(res, true, "neo", 206)
if start <= 206 && (stop == 0 || stop >= 206) && (asset == "neo" || asset == "") {
require.NotNil(t, u)
require.EqualValues(t, int64(util.Fixed8FromInt64(99999000)), u.Amount)
require.EqualValues(t, int64(99999000), u.Amount)
} else {
require.Nil(t, u)
}
@ -1314,7 +1314,7 @@ func checkTransfers(t *testing.T, e *executor, acc interface{}, asset string, st
u = getUTXOForBlock(res, false, "neo", 206)
if start <= 206 && (stop == 0 || stop >= 206) && (asset == "neo" || asset == "") {
require.NotNil(t, u)
require.EqualValues(t, int64(util.Fixed8FromInt64(99998000)), u.Amount)
require.EqualValues(t, int64(99998000), u.Amount)
} else {
require.Nil(t, u)
}