lotus/node/node_test.go

154 lines
4.5 KiB
Go
Raw Normal View History

2019-07-10 13:06:04 +00:00
package node_test
2019-07-09 16:27:07 +00:00
import (
2020-06-01 12:59:51 +00:00
"os"
2019-07-09 16:27:07 +00:00
"testing"
"time"
2019-07-09 16:27:07 +00:00
2020-08-13 20:37:09 +00:00
builder "github.com/filecoin-project/lotus/node/test"
2019-07-10 17:28:49 +00:00
2020-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/go-state-types/big"
2020-08-13 20:37:09 +00:00
"github.com/filecoin-project/lotus/lib/lotuslog"
2020-09-17 02:34:13 +00:00
v0miner "github.com/filecoin-project/specs-actors/actors/builtin/miner"
v0power "github.com/filecoin-project/specs-actors/actors/builtin/power"
2020-09-17 07:48:39 +00:00
v0verifreg "github.com/filecoin-project/specs-actors/actors/builtin/verifreg"
2020-08-13 20:37:09 +00:00
logging "github.com/ipfs/go-log/v2"
2020-02-23 15:50:36 +00:00
"github.com/filecoin-project/lotus/api/test"
2019-07-09 16:27:07 +00:00
)
2019-11-30 22:22:26 +00:00
func init() {
2019-12-02 12:51:16 +00:00
_ = logging.SetLogLevel("*", "INFO")
2019-12-03 01:41:31 +00:00
v0power.ConsensusMinerMinPower = big.NewInt(2048)
2020-09-17 02:34:13 +00:00
v0miner.SupportedProofTypes = map[abi.RegisteredSealProof]struct{}{
2020-06-15 16:30:49 +00:00
abi.RegisteredSealProof_StackedDrg2KiBV1: {},
2020-05-12 16:58:43 +00:00
}
2020-09-17 07:48:39 +00:00
v0verifreg.MinVerifiedDealSize = big.NewInt(256)
2019-11-30 22:22:26 +00:00
}
2019-07-09 16:27:07 +00:00
func TestAPI(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestApis(t, builder.Builder)
2019-07-09 16:36:40 +00:00
}
func TestAPIRPC(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestApis(t, builder.RPCBuilder)
2019-07-09 16:36:40 +00:00
}
func TestAPIDealFlow(t *testing.T) {
2020-01-21 16:05:10 +00:00
logging.SetLogLevel("miner", "ERROR")
2020-03-06 07:30:20 +00:00
logging.SetLogLevel("chainstore", "ERROR")
2020-01-21 16:05:10 +00:00
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
t.Run("TestDealFlow", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestDealFlow(t, builder.MockSbBuilder, 10*time.Millisecond, false, false)
})
t.Run("WithExportedCAR", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestDealFlow(t, builder.MockSbBuilder, 10*time.Millisecond, true, false)
})
t.Run("TestDoubleDealFlow", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestDoubleDealFlow(t, builder.MockSbBuilder, 10*time.Millisecond)
})
2020-08-06 20:16:55 +00:00
t.Run("TestFastRetrievalDealFlow", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestFastRetrievalDealFlow(t, builder.MockSbBuilder, 10*time.Millisecond)
2020-08-06 20:16:55 +00:00
})
2020-01-14 02:04:33 +00:00
}
func TestAPIDealFlowReal(t *testing.T) {
if testing.Short() {
t.Skip("skipping test in short mode")
}
lotuslog.SetupLogLevels()
2020-03-06 07:30:20 +00:00
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
2020-09-17 02:34:13 +00:00
v0miner.PreCommitChallengeDelay = 5
2020-07-08 18:35:55 +00:00
t.Run("basic", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestDealFlow(t, builder.Builder, time.Second, false, false)
2020-07-08 18:35:55 +00:00
})
t.Run("fast-retrieval", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestDealFlow(t, builder.Builder, time.Second, false, true)
2020-07-08 18:35:55 +00:00
})
t.Run("retrieval-second", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestSenondDealRetrieval(t, builder.Builder, time.Second)
})
}
2020-04-23 21:12:42 +00:00
func TestDealMining(t *testing.T) {
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
2020-08-13 20:37:09 +00:00
test.TestDealMining(t, builder.MockSbBuilder, 50*time.Millisecond, false)
2020-04-23 21:12:42 +00:00
}
2020-06-01 12:49:48 +00:00
func TestPledgeSectors(t *testing.T) {
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
t.Run("1", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestPledgeSector(t, builder.MockSbBuilder, 50*time.Millisecond, 1)
2020-06-01 12:49:48 +00:00
})
t.Run("100", func(t *testing.T) {
2020-08-13 20:37:09 +00:00
test.TestPledgeSector(t, builder.MockSbBuilder, 50*time.Millisecond, 100)
2020-06-01 12:49:48 +00:00
})
t.Run("1000", func(t *testing.T) {
if testing.Short() { // takes ~16s
t.Skip("skipping test in short mode")
}
2020-08-13 20:37:09 +00:00
test.TestPledgeSector(t, builder.MockSbBuilder, 50*time.Millisecond, 1000)
2020-06-01 12:49:48 +00:00
})
}
func TestWindowedPost(t *testing.T) {
2020-06-01 12:59:51 +00:00
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
2020-06-01 12:49:48 +00:00
}
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
2020-08-13 20:37:09 +00:00
test.TestWindowPost(t, builder.MockSbBuilder, 2*time.Millisecond, 10)
2020-06-01 12:49:48 +00:00
}
2020-07-01 14:49:17 +00:00
func TestCCUpgrade(t *testing.T) {
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
2020-08-13 20:37:09 +00:00
test.TestCCUpgrade(t, builder.MockSbBuilder, 5*time.Millisecond)
2020-07-01 14:49:17 +00:00
}
func TestPaymentChannels(t *testing.T) {
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("pubsub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
2020-08-13 20:37:09 +00:00
test.TestPaymentChannels(t, builder.MockSbBuilder, 5*time.Millisecond)
}