lotus/node/node_test.go

232 lines
7.0 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-09-07 03:49:10 +00:00
"github.com/filecoin-project/go-state-types/abi"
"github.com/filecoin-project/lotus/api/test"
"github.com/filecoin-project/lotus/chain/actors/policy"
2021-01-08 15:28:38 +00:00
"github.com/filecoin-project/lotus/lib/lotuslog"
builder "github.com/filecoin-project/lotus/node/test"
logging "github.com/ipfs/go-log/v2"
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
policy.SetConsensusMinerMinPower(abi.NewStoragePower(2048))
policy.SetSupportedProofTypes(abi.RegisteredSealProof_StackedDrg2KiBV1)
policy.SetMinVerifiedDealSize(abi.NewStoragePower(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")
blockTime := 10 * time.Millisecond
// For these tests where the block time is artificially short, just use
// a deal start epoch that is guaranteed to be far enough in the future
// so that the deal starts sealing in time
dealStartEpoch := abi.ChainEpoch(2 << 12)
t.Run("TestDealFlow", func(t *testing.T) {
test.TestDealFlow(t, builder.MockSbBuilder, blockTime, false, false, dealStartEpoch)
})
t.Run("WithExportedCAR", func(t *testing.T) {
test.TestDealFlow(t, builder.MockSbBuilder, blockTime, true, false, dealStartEpoch)
})
t.Run("TestDoubleDealFlow", func(t *testing.T) {
test.TestDoubleDealFlow(t, builder.MockSbBuilder, blockTime, dealStartEpoch)
})
2020-08-06 20:16:55 +00:00
t.Run("TestFastRetrievalDealFlow", func(t *testing.T) {
test.TestFastRetrievalDealFlow(t, builder.MockSbBuilder, blockTime, dealStartEpoch)
2020-08-06 20:16:55 +00:00
})
2021-01-08 15:28:38 +00:00
t.Run("TestPublishDealsBatching", func(t *testing.T) {
test.TestPublishDealsBatching(t, builder.MockSbBuilder, blockTime, dealStartEpoch)
})
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")
// TODO: just set this globally?
oldDelay := policy.GetPreCommitChallengeDelay()
policy.SetPreCommitChallengeDelay(5)
t.Cleanup(func() {
policy.SetPreCommitChallengeDelay(oldDelay)
})
2020-07-08 18:35:55 +00:00
t.Run("basic", func(t *testing.T) {
test.TestDealFlow(t, builder.Builder, time.Second, false, false, 0)
2020-07-08 18:35:55 +00:00
})
t.Run("fast-retrieval", func(t *testing.T) {
test.TestDealFlow(t, builder.Builder, time.Second, false, true, 0)
2020-07-08 18:35:55 +00:00
})
t.Run("retrieval-second", func(t *testing.T) {
test.TestSecondDealRetrieval(t, builder.Builder, time.Second)
})
}
2020-04-23 21:12:42 +00:00
func TestDealMining(t *testing.T) {
2021-02-05 12:18:41 +00:00
if testing.Short() {
t.Skip("skipping test in short mode")
}
2020-04-23 21:12:42 +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.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 TestSDRUpgrade(t *testing.T) {
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
oldDelay := policy.GetPreCommitChallengeDelay()
policy.SetPreCommitChallengeDelay(5)
t.Cleanup(func() {
policy.SetPreCommitChallengeDelay(oldDelay)
})
test.TestSDRUpgrade(t, builder.MockSbBuilder, 50*time.Millisecond)
}
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
})
}
2020-10-12 06:31:23 +00:00
func TestTapeFix(t *testing.T) {
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
test.TestTapeFix(t, builder.MockSbBuilder, 2*time.Millisecond)
}
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
2021-01-13 23:11:41 +00:00
func TestTerminate(t *testing.T) {
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
}
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
test.TestTerminate(t, builder.MockSbBuilder, 2*time.Millisecond)
}
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)
}
2021-01-22 03:48:34 +00:00
func TestWindowPostDispute(t *testing.T) {
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
}
2021-01-22 03:48:34 +00:00
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
test.TestWindowPostDispute(t, builder.MockSbBuilder, 2*time.Millisecond)
}
func TestWindowPostDisputeFails(t *testing.T) {
if os.Getenv("LOTUS_TEST_WINDOW_POST") != "1" {
t.Skip("this takes a few minutes, set LOTUS_TEST_WINDOW_POST=1 to run")
}
logging.SetLogLevel("miner", "ERROR")
logging.SetLogLevel("chainstore", "ERROR")
logging.SetLogLevel("chain", "ERROR")
logging.SetLogLevel("sub", "ERROR")
logging.SetLogLevel("storageminer", "ERROR")
test.TestWindowPostDisputeFails(t, builder.MockSbBuilder, 2*time.Millisecond)
}