From 4a88470c3416716163e527aa358c5dc08b8d0278 Mon Sep 17 00:00:00 2001 From: Jennifer Wang Date: Mon, 31 May 2021 16:12:06 -0400 Subject: [PATCH] Use MockSbBuilder --- api/test/verifreg.go | 6 +----- node/node_test.go | 2 +- node/test/builder.go | 20 +++++++++++++++++++- 3 files changed, 21 insertions(+), 7 deletions(-) diff --git a/api/test/verifreg.go b/api/test/verifreg.go index 806a56d04eb..e6d6acadfe3 100644 --- a/api/test/verifreg.go +++ b/api/test/verifreg.go @@ -2,8 +2,7 @@ package test import ( "context" - "fmt" - "os" + lapi "github.com/filecoin-project/lotus/api" "strings" "github.com/filecoin-project/lotus/chain/actors" @@ -15,10 +14,7 @@ import ( "time" "github.com/filecoin-project/go-state-types/big" - lapi "github.com/filecoin-project/lotus/api" - "github.com/filecoin-project/lotus/build" "github.com/filecoin-project/lotus/chain/types" - logging "github.com/ipfs/go-log/v2" ) diff --git a/node/node_test.go b/node/node_test.go index 821cc4a463d..522f525d1a2 100644 --- a/node/node_test.go +++ b/node/node_test.go @@ -263,5 +263,5 @@ func TestDeadlineToggling(t *testing.T) { func TestVerifiedClientTopUp(t *testing.T) { logging.SetLogLevel("storageminer", "FATAL") logging.SetLogLevel("chain", "ERROR") - test.AddVerifiedClient(t, builder.Builder) + test.AddVerifiedClient(t, builder.MockSbBuilder) } diff --git a/node/test/builder.go b/node/test/builder.go index 297fc5194b6..ed0cf3e5814 100644 --- a/node/test/builder.go +++ b/node/test/builder.go @@ -457,12 +457,26 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes maddrs = append(maddrs, maddr) genms = append(genms, *genm) } + + rkhKey, err := wallet.GenerateKey(types.KTSecp256k1) + if err != nil { + return nil, nil + } + + vrk := genesis.Actor{ + Type: genesis.TAccount, + Balance: big.Mul(big.NewInt(400000000), types.NewInt(build.FilecoinPrecision)), + Meta: (&genesis.AccountMeta{Owner: rkhKey.Address}).ActorMeta(), + } + keys = append(keys, rkhKey) + + templ := &genesis.Template{ Accounts: genaccs, Miners: genms, NetworkName: "test", Timestamp: uint64(time.Now().Unix()) - (build.BlockDelaySecs * 20000), - VerifregRootKey: gen.DefaultVerifregRootkeyActor, + VerifregRootKey: vrk, RemainderAccount: gen.DefaultRemainderAccountActor, } @@ -511,6 +525,10 @@ func mockSbBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []tes )) } + if _, err := fulls[0].FullNode.WalletImport(ctx, &rkhKey.KeyInfo); err != nil { + t.Fatal(err) + } + for i, def := range storage { // TODO: support non-bootstrap miners