lotus/chain/gen/gen_test.go

59 lines
1.1 KiB
Go
Raw Normal View History

2019-07-25 22:15:33 +00:00
package gen
import (
"testing"
2019-12-03 01:55:10 +00:00
"github.com/filecoin-project/specs-actors/actors/abi"
2020-02-14 14:14:39 +00:00
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
2019-12-03 01:55:10 +00:00
"github.com/filecoin-project/lotus/build"
2020-02-07 07:01:37 +00:00
_ "github.com/filecoin-project/lotus/lib/sigs/bls"
_ "github.com/filecoin-project/lotus/lib/sigs/secp"
2019-07-25 22:15:33 +00:00
)
2019-12-03 01:55:10 +00:00
func init() {
2020-02-27 21:45:31 +00:00
build.SectorSizes = []abi.SectorSize{2048}
build.MinimumMinerPower = 2048
2019-12-03 01:55:10 +00:00
}
func testGeneration(t testing.TB, n int, msgs int) {
2019-07-25 22:15:33 +00:00
g, err := NewGenerator()
if err != nil {
2020-02-14 14:14:39 +00:00
t.Fatalf("%+v", err)
2019-07-25 22:15:33 +00:00
}
g.msgsPerBlock = msgs
2019-07-26 12:28:29 +00:00
for i := 0; i < n; i++ {
mts, err := g.NextTipSet()
2019-07-25 22:15:33 +00:00
if err != nil {
2020-02-19 19:39:00 +00:00
t.Fatalf("error at H:%d, %+v", i, err)
2019-07-25 22:15:33 +00:00
}
_ = mts
2019-07-25 22:15:33 +00:00
}
2019-07-26 12:28:29 +00:00
}
func TestChainGeneration(t *testing.T) {
testGeneration(t, 10, 20)
2019-07-26 12:28:29 +00:00
}
2019-07-25 22:15:33 +00:00
2019-07-26 12:28:29 +00:00
func BenchmarkChainGeneration(b *testing.B) {
b.Run("0-messages", func(b *testing.B) {
testGeneration(b, b.N, 0)
})
b.Run("10-messages", func(b *testing.B) {
testGeneration(b, b.N, 10)
})
b.Run("100-messages", func(b *testing.B) {
testGeneration(b, b.N, 100)
})
b.Run("1000-messages", func(b *testing.B) {
testGeneration(b, b.N, 1000)
})
2019-07-25 22:15:33 +00:00
}