2019-07-25 22:15:33 +00:00
|
|
|
package gen
|
|
|
|
|
|
|
|
import (
|
|
|
|
"testing"
|
2019-12-03 01:55:10 +00:00
|
|
|
|
2020-02-10 19:16:36 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi"
|
2020-05-12 17:58:12 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/abi/big"
|
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
2020-05-14 02:32:04 +00:00
|
|
|
"github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
|
2020-02-10 19:16:36 +00:00
|
|
|
|
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-07-25 22:15:33 +00:00
|
|
|
)
|
|
|
|
|
2019-12-03 01:55:10 +00:00
|
|
|
func init() {
|
2020-06-15 16:30:49 +00:00
|
|
|
miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
|
|
|
|
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
|
2020-05-12 17:58:12 +00:00
|
|
|
}
|
2020-05-14 02:32:04 +00:00
|
|
|
verifreg.MinVerifiedDealSize = big.NewInt(256)
|
2019-12-03 01:55:10 +00:00
|
|
|
}
|
|
|
|
|
2020-05-01 00:54:41 +00:00
|
|
|
func testGeneration(t testing.TB, n int, msgs int, sectors int) {
|
|
|
|
g, err := NewGeneratorWithSectors(sectors)
|
2019-07-25 22:15:33 +00:00
|
|
|
if err != nil {
|
2020-02-14 14:14:39 +00:00
|
|
|
t.Fatalf("%+v", err)
|
2019-07-25 22:15:33 +00:00
|
|
|
}
|
|
|
|
|
2019-08-30 07:05:21 +00:00
|
|
|
g.msgsPerBlock = msgs
|
|
|
|
|
2019-07-26 12:28:29 +00:00
|
|
|
for i := 0; i < n; i++ {
|
2019-09-03 04:36:07 +00:00
|
|
|
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
|
|
|
}
|
2019-11-19 15:53:00 +00:00
|
|
|
_ = mts
|
2019-07-25 22:15:33 +00:00
|
|
|
}
|
2019-07-26 12:28:29 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
func TestChainGeneration(t *testing.T) {
|
2020-07-20 15:59:05 +00:00
|
|
|
t.Run("10-20-1", func(t *testing.T) { testGeneration(t, 10, 20, 1) })
|
|
|
|
t.Run("10-20-25", func(t *testing.T) { testGeneration(t, 10, 20, 25) })
|
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) {
|
2019-08-30 07:05:21 +00:00
|
|
|
b.Run("0-messages", func(b *testing.B) {
|
2020-05-01 00:54:41 +00:00
|
|
|
testGeneration(b, b.N, 0, 1)
|
2019-08-30 07:05:21 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
b.Run("10-messages", func(b *testing.B) {
|
2020-05-01 00:54:41 +00:00
|
|
|
testGeneration(b, b.N, 10, 1)
|
2019-08-30 07:05:21 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
b.Run("100-messages", func(b *testing.B) {
|
2020-05-01 00:54:41 +00:00
|
|
|
testGeneration(b, b.N, 100, 1)
|
2019-08-30 07:05:21 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
b.Run("1000-messages", func(b *testing.B) {
|
2020-05-01 00:54:41 +00:00
|
|
|
testGeneration(b, b.N, 1000, 1)
|
2019-08-30 07:05:21 +00:00
|
|
|
})
|
2019-07-25 22:15:33 +00:00
|
|
|
}
|