Use MockSbBuilder

This commit is contained in:
Jennifer Wang 2021-05-31 16:12:06 -04:00
parent ac2887c01b
commit fcfc214ed1
3 changed files with 22 additions and 9 deletions

View File

@ -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)

View File

@ -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)
}

View File

@ -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