lotus/chain/gen/gen_test.go

31 lines
470 B
Go
Raw Normal View History

2019-07-25 22:15:33 +00:00
package gen
import (
"testing"
)
2019-07-26 12:28:29 +00:00
func testGeneration(t testing.TB, n int) {
2019-07-25 22:15:33 +00:00
g, err := NewGenerator()
if err != nil {
t.Fatal(err)
}
2019-07-26 12:28:29 +00:00
for i := 0; i < n; i++ {
2019-07-25 22:15:33 +00:00
b, err := g.NextBlock()
if err != nil {
2019-07-26 12:19:27 +00:00
t.Fatalf("error at H:%d, %s", i, err)
2019-07-25 22:15:33 +00:00
}
if b.Header.Height != uint64(i+1) {
t.Fatal("wrong height")
}
}
2019-07-26 12:28:29 +00:00
}
func TestChainGeneration(t *testing.T) {
testGeneration(t, 10)
}
2019-07-25 22:15:33 +00:00
2019-07-26 12:28:29 +00:00
func BenchmarkChainGeneration(b *testing.B) {
testGeneration(b, b.N)
2019-07-25 22:15:33 +00:00
}