OSDN Git Service

Merge pull request #201 from Bytom/v0.1
[bytom/vapor.git] / vendor / github.com / bytom / consensus / general_test.go
diff --git a/vendor/github.com/bytom/consensus/general_test.go b/vendor/github.com/bytom/consensus/general_test.go
new file mode 100644 (file)
index 0000000..5006743
--- /dev/null
@@ -0,0 +1,38 @@
+package consensus
+
+import "testing"
+
+func TestSubsidy(t *testing.T) {
+       cases := []struct {
+               subsidy uint64
+               height  uint64
+       }{
+               {
+                       subsidy: baseSubsidy,
+                       height:  1,
+               },
+               {
+                       subsidy: baseSubsidy,
+                       height:  subsidyReductionInterval - 1,
+               },
+               {
+                       subsidy: baseSubsidy / 2,
+                       height:  subsidyReductionInterval,
+               },
+               {
+                       subsidy: baseSubsidy / 2,
+                       height:  subsidyReductionInterval + 1,
+               },
+               {
+                       subsidy: baseSubsidy / 1024,
+                       height:  subsidyReductionInterval * 10,
+               },
+       }
+
+       for _, c := range cases {
+               subsidy := BlockSubsidy(c.height)
+               if subsidy != c.subsidy {
+                       t.Errorf("got subsidy %d, want %d", subsidy, c.subsidy)
+               }
+       }
+}