2019-09-21 00:22:28 +00:00
|
|
|
package vm
|
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/filecoin-project/go-lotus/build"
|
|
|
|
"github.com/filecoin-project/go-lotus/chain/types"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestBlockReward(t *testing.T) {
|
2019-09-26 22:33:38 +00:00
|
|
|
coffer := types.FromFil(build.MiningRewardTotal)
|
2019-09-21 00:22:28 +00:00
|
|
|
sum := types.NewInt(0)
|
2019-09-26 22:33:38 +00:00
|
|
|
N := build.HalvingPeriodBlocks
|
|
|
|
for i := 0; i < N; i++ {
|
|
|
|
a := MiningReward(coffer)
|
|
|
|
sum = types.BigAdd(sum, a)
|
|
|
|
coffer = types.BigSub(coffer, a)
|
2019-09-21 00:22:28 +00:00
|
|
|
}
|
|
|
|
|
2019-09-26 22:33:38 +00:00
|
|
|
//sum = types.BigMul(sum, types.NewInt(60))
|
|
|
|
|
|
|
|
fmt.Println("After a halving period")
|
|
|
|
fmt.Printf("Total reward: %d\n", build.MiningRewardTotal)
|
|
|
|
fmt.Printf("Remaining: %s\n", types.BigDiv(coffer, types.NewInt(build.FilecoinPrecision)))
|
|
|
|
fmt.Printf("Given out: %s\n", types.BigDiv(sum, types.NewInt(build.FilecoinPrecision)))
|
2019-09-21 00:22:28 +00:00
|
|
|
}
|