Skip to content

Commit

Permalink
use Safe64MulDiv also in the tests
Browse files Browse the repository at this point in the history
  • Loading branch information
oliviasaa committed Mar 28, 2024
1 parent e0a3978 commit bc3b8f6
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import (

"github.com/stretchr/testify/require"

"github.com/iotaledger/hive.go/core/safemath"

"github.com/iotaledger/hive.go/kvstore"
"github.com/iotaledger/hive.go/kvstore/mapdb"
"github.com/iotaledger/hive.go/lo"
Expand Down Expand Up @@ -272,7 +274,10 @@ func (t *TestSuite) delegatorReward(epoch iotago.EpochIndex, profitMargin, poolR
if poolRewardWithFixedCost >= fixedCost {
poolRewards = poolRewardWithFixedCost - fixedCost
}
unDecayedEpochRewards := (((profitMarginComplement * poolRewards) >> profitMarginExponent) / poolStake) * delegatedAmount

result := (profitMarginComplement * poolRewards) >> profitMarginExponent
unDecayedEpochRewards, err := safemath.Safe64MulDiv(result, delegatedAmount, poolStake)
require.NoError(t.T, err)

decayProvider := t.api.ManaDecayProvider()
decayedEpochRewards, err := decayProvider.DecayManaByEpochs(iotago.Mana(unDecayedEpochRewards), epoch, epoch)
Expand Down

0 comments on commit bc3b8f6

Please sign in to comment.