From fcfc214ed1c3714b6be2851e25f4b52eb3e63f08 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 | 8 ++------ node/node_test.go | 2 +- node/test/builder.go | 21 +++++++++++++++++++-- 3 files changed, 22 insertions(+), 9 deletions(-) diff --git a/api/test/verifreg.go b/api/test/verifreg.go index 806a56d04..b66ca1a36 100644 --- a/api/test/verifreg.go +++ b/api/test/verifreg.go @@ -2,10 +2,10 @@ package test import ( "context" - "fmt" - "os" "strings" + lapi "github.com/filecoin-project/lotus/api" + "github.com/filecoin-project/lotus/chain/actors" "github.com/filecoin-project/lotus/chain/actors/builtin/verifreg" "github.com/filecoin-project/lotus/node/impl" @@ -15,13 +15,9 @@ 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" ) - func AddVerifiedClient(t *testing.T, b APIBuilder) { nodes, miners := b(t, []FullNodeOpts{FullNodeWithLatestActorsAt(-1)}, OneMiner) diff --git a/node/node_test.go b/node/node_test.go index 821cc4a46..522f525d1 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 297fc5194..5d2af0724 100644 --- a/node/test/builder.go +++ b/node/test/builder.go @@ -284,7 +284,7 @@ func mockBuilderOpts(t *testing.T, fullOpts []test.FullNodeOpts, storage []test. vrk := genesis.Actor{ Type: genesis.TAccount, - Balance: big.Mul(big.NewInt(400000000), types.NewInt(build.FilecoinPrecision)), + Balance: big.Mul(big.Div(big.NewInt(int64(build.FilBase)), big.NewInt(100)), big.NewInt(int64(build.FilecoinPrecision))), Meta: (&genesis.AccountMeta{Owner: rkhKey.Address}).ActorMeta(), } keys = append(keys, rkhKey) @@ -457,12 +457,25 @@ 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.Div(big.NewInt(int64(build.FilBase)), big.NewInt(100)), big.NewInt(int64(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 +524,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