You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

42 lines
1.4 KiB

  1. package emission
  2. //import "encoding/hex"
  3. //import "bytes"
  4. import "testing"
  5. func Test_Emission_Rewards(t *testing.T) {
  6. bl_median_size := uint64(0)
  7. bl_current_size := uint64(0)
  8. already_generated_coins := uint64(0)
  9. hard_fork_version := uint64(6)
  10. fee := uint64(0)
  11. if GetBlockReward(bl_median_size, bl_current_size, already_generated_coins, hard_fork_version, fee) != uint64(1000000000000) {
  12. t.Error("Block reward failed for genesis block\n")
  13. }
  14. already_generated_coins = uint64(1000000000000)
  15. if GetBlockReward(bl_median_size, bl_current_size, already_generated_coins, hard_fork_version, fee) != uint64(2000000000000000000) {
  16. t.Error("Block reward failed for pre-mine\n")
  17. }
  18. already_generated_coins += uint64(2000000000000000000)
  19. calculated := GetBlockReward(bl_median_size, bl_current_size, already_generated_coins, hard_fork_version, fee)
  20. expected := uint64(31369672915858)
  21. if calculated != expected {
  22. t.Errorf("Block reward failed for 2nd block estm %d calculated %d\n", expected, calculated)
  23. }
  24. already_generated_coins += uint64(31369672915858)
  25. // calculated block reward for 3rd block
  26. calculated = GetBlockReward(bl_median_size, bl_current_size, already_generated_coins, hard_fork_version, fee)
  27. expected = uint64(31369613082955)
  28. if calculated != expected {
  29. t.Errorf("Block reward failed for 3rd block estm %d calculated %d\n", expected, calculated)
  30. }
  31. }