github.com/avahowell/sia@v0.5.1-beta.0.20160524050156-83dcc3d37c94/types/filecontracts_test.go (about) 1 package types 2 3 import ( 4 "testing" 5 ) 6 7 // TestFileContractTax probes the Tax function. 8 func TestTax(t *testing.T) { 9 // Test explicit values for post-hardfork tax values. 10 if Tax(1e9, NewCurrency64(125e9)).Cmp(NewCurrency64(4875e6)) != 0 { 11 t.Error("tax is being calculated incorrectly") 12 } 13 if PostTax(1e9, NewCurrency64(125e9)).Cmp(NewCurrency64(120125e6)) != 0 { 14 t.Error("tax is being calculated incorrectly") 15 } 16 17 // Test equivalency for a series of values. 18 if testing.Short() { 19 t.SkipNow() 20 } 21 // COMPATv0.4.0 - check at height 0. 22 for i := uint64(0); i < 10e3; i++ { 23 val := NewCurrency64((1e3 * i) + i) 24 tax := Tax(0, val) 25 postTax := PostTax(0, val) 26 if val.Cmp(tax.Add(postTax)) != 0 { 27 t.Error("tax calculation inconsistent for", i) 28 } 29 } 30 // Check at height 1e9 31 for i := uint64(0); i < 10e3; i++ { 32 val := NewCurrency64((1e3 * i) + i) 33 tax := Tax(1e9, val) 34 postTax := PostTax(1e9, val) 35 if val.Cmp(tax.Add(postTax)) != 0 { 36 t.Error("tax calculation inconsistent for", i) 37 } 38 } 39 }