Skip to content

Commit

Permalink
native: fix formulae of unclaimed GAS calculation in test
Browse files Browse the repository at this point in the history
The behaviour is the same, the result is also the same, but the meaning
is fixed.

Signed-off-by: Anna Shaleva <shaleva.ann@nspcc.ru>
  • Loading branch information
AnnaShaleva committed Oct 4, 2024
1 parent 4a9003f commit a7e3ce0
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions pkg/core/native/native_test/neo_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -743,13 +743,15 @@ func TestNEO_CalculateBonus(t *testing.T) {

t.Run("Many blocks", func(t *testing.T) {
amount := 100
defaultGASParBlock := 5
defaultGASPerBlock := 5
newGASPerBlock := 1
neoHolderRewardRatio := 10

initialGASBalance := e.Chain.GetUtilityTokenBalance(accH)

// Five blocks of NEO owning with default GasPerBlockValue.
neoValidatorsInvoker.Invoke(t, true, "transfer", e.Validator.ScriptHash(), accH, amount, nil)

for range rewardDistance/2 - 2 {
e.AddNewBlock(t)
}
Expand All @@ -764,8 +766,12 @@ func TestNEO_CalculateBonus(t *testing.T) {
h := acc.Invoke(t, true, "transfer", accH, accH, amount, nil)
claimTx, _ := e.GetTransaction(t, h)

firstPart := int64(amount*rewardDistance/2*defaultGASParBlock) / int64(rewardDistance)
secondPart := int64(amount*rewardDistance/2*newGASPerBlock) / int64(rewardDistance)
firstPart := int64(amount * neoHolderRewardRatio / 100 * // reward for a part of the whole NEO total supply that is owned by acc
defaultGASPerBlock * // GAS generated by a single block
rewardDistance / 2) // number of blocks generated with specified GasPerBlock
secondPart := int64(amount * neoHolderRewardRatio / 100 * // reward for a part of the whole NEO total supply that is owned by acc
newGASPerBlock * // GAS generated by a single block after GasPerBlock update
rewardDistance / 2) // number of blocks generated with specified GasPerBlock
e.CheckGASBalance(t, accH, big.NewInt(initialGASBalance.Int64()-
claimTx.SystemFee-claimTx.NetworkFee + +firstPart + secondPart))
})
Expand Down

0 comments on commit a7e3ce0

Please sign in to comment.