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"
|
2020-01-14 02:51:14 +00:00
|
|
|
"time"
|
2019-07-09 16:27:07 +00:00
|
|
|
|
2020-09-22 23:07:32 +00:00
|
|
|
"github.com/filecoin-project/lotus/chain/actors/builtin/miner"
|
|
|
|
|
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-18 21:59:27 +00:00
|
|
|
miner0 "github.com/filecoin-project/specs-actors/actors/builtin/miner"
|
|
|
|
power0 "github.com/filecoin-project/specs-actors/actors/builtin/power"
|
|
|
|
verifreg0 "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
|
|
|
|
2019-10-18 04:47:41 +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
|
|
|
|
2020-09-18 21:59:27 +00:00
|
|
|
power0.ConsensusMinerMinPower = big.NewInt(2048)
|
|
|
|
miner0.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-18 21:59:27 +00:00
|
|
|
verifreg0.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
|
|
|
}
|
2019-11-06 06:26:50 +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")
|
|
|
|
|
2020-03-31 19:55:42 +00:00
|
|
|
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)
|
2020-03-31 19:55:42 +00:00
|
|
|
})
|
2020-03-30 14:08:20 +00:00
|
|
|
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)
|
2020-03-30 14:08:20 +00:00
|
|
|
})
|
2020-04-21 18:38:28 +00:00
|
|
|
t.Run("TestDoubleDealFlow", func(t *testing.T) {
|
2020-08-13 20:37:09 +00:00
|
|
|
test.TestDoubleDealFlow(t, builder.MockSbBuilder, 10*time.Millisecond)
|
2020-04-21 18:38:28 +00:00
|
|
|
})
|
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) {
|
2019-12-09 15:49:46 +00:00
|
|
|
if testing.Short() {
|
|
|
|
t.Skip("skipping test in short mode")
|
|
|
|
}
|
2020-03-25 18:21:53 +00:00
|
|
|
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-22 23:07:32 +00:00
|
|
|
// TODO: Do this better.
|
|
|
|
miner.PreCommitChallengeDelay = 5
|
2020-09-18 21:59:27 +00:00
|
|
|
miner0.PreCommitChallengeDelay = 5
|
2020-07-27 23:22:20 +00:00
|
|
|
|
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
|
|
|
})
|
2020-07-27 23:22:20 +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-07-27 23:22:20 +00:00
|
|
|
})
|
2019-11-06 06:26:50 +00:00
|
|
|
}
|
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
|
|
|
}
|
2020-07-18 03:07:02 +00:00
|
|
|
|
|
|
|
func TestPaymentChannels(t *testing.T) {
|
|
|
|
logging.SetLogLevel("miner", "ERROR")
|
|
|
|
logging.SetLogLevel("chainstore", "ERROR")
|
|
|
|
logging.SetLogLevel("chain", "ERROR")
|
|
|
|
logging.SetLogLevel("sub", "ERROR")
|
2020-07-22 18:02:29 +00:00
|
|
|
logging.SetLogLevel("pubsub", "ERROR")
|
2020-07-18 03:07:02 +00:00
|
|
|
logging.SetLogLevel("storageminer", "ERROR")
|
|
|
|
|
2020-08-13 20:37:09 +00:00
|
|
|
test.TestPaymentChannels(t, builder.MockSbBuilder, 5*time.Millisecond)
|
2020-07-18 03:07:02 +00:00
|
|
|
}
|