Skip to content

Commit

Permalink
rename DefaultGenesis to TestGenesis
Browse files Browse the repository at this point in the history
- moved to testing as its only used in testing
  • Loading branch information
frrist committed Jun 6, 2019
1 parent 9cd4835 commit 1f59eee
Show file tree
Hide file tree
Showing 9 changed files with 21 additions and 19 deletions.
2 changes: 1 addition & 1 deletion actor/builtin/miner_redeem_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ func requireGenesis(ctx context.Context, t *testing.T, targetAddresses ...addres
vms := vm.NewStorageMap(bs)

cst := hamt.NewCborStore()
blk, err := consensus.DefaultGenesis(cst, bs)
blk, err := consensus.TestGenesis(cst, bs)
require.NoError(err)

st, err := state.LoadStateTree(ctx, cst, blk.StateRoot, builtin.Actors)
Expand Down
2 changes: 1 addition & 1 deletion actor/builtin/paymentbroker/paymentbroker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1124,7 +1124,7 @@ func requireGenesis(ctx context.Context, t *testing.T, targetAddresses ...addres
vms := vm.NewStorageMap(bs)

cst := hamt.NewCborStore()
blk, err := consensus.DefaultGenesis(cst, bs)
blk, err := consensus.TestGenesis(cst, bs)
require.NoError(t, err)

builtinsWithTestActor := map[cid.Cid]exec.ExecutableActor{}
Expand Down
2 changes: 1 addition & 1 deletion consensus/expected_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func TestExpected_RunStateTransition_validateMining(t *testing.T) {
ctx := context.Background()

cistore, bstore, verifier := setupCborBlockstoreProofs()
genesisBlock, err := consensus.DefaultGenesis(cistore, bstore)
genesisBlock, err := consensus.TestGenesis(cistore, bstore)
require.NoError(t, err)

t.Run("passes the validateMining section when given valid mining blocks", func(t *testing.T) {
Expand Down
5 changes: 0 additions & 5 deletions consensus/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,11 +192,6 @@ func MakeGenesisFunc(opts ...GenOption) GenesisInitFunc {
}
}

// DefaultGenesis creates a genesis block with default accounts and actors installed.
func DefaultGenesis(cst *hamt.CborIpldStore, bs blockstore.Blockstore) (*types.Block, error) {
return MakeGenesisFunc()(cst, bs)
}

// SetupDefaultActors inits the builtin actors that are required to run filecoin.
func SetupDefaultActors(ctx context.Context, st state.Tree, storageMap vm.StorageMap, storeType types.ProofsMode) error {
for addr, val := range defaultAccounts {
Expand Down
13 changes: 10 additions & 3 deletions consensus/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,22 @@ package consensus

import (
"context"

"github.com/ipfs/go-hamt-ipld"
"github.com/ipfs/go-ipfs-blockstore"
"github.com/stretchr/testify/require"

"github.com/filecoin-project/go-filecoin/actor"
"github.com/filecoin-project/go-filecoin/address"
"github.com/filecoin-project/go-filecoin/state"
"github.com/filecoin-project/go-filecoin/types"
"github.com/ipfs/go-ipfs-blockstore"

"github.com/stretchr/testify/require"
)

// TestGenesis creates a genesis block with default accounts and actors installed for testing.
func TestGenesis(cst *hamt.CborIpldStore, bs blockstore.Blockstore) (*types.Block, error) {
return MakeGenesisFunc()(cst, bs)
}

// TestView is an implementation of stateView used for testing the chain
// manager. It provides a consistent view that the storage market
// that returns 1 for storage total and 1 for any miner storage.
Expand Down
2 changes: 1 addition & 1 deletion core/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ func CreateStorages(ctx context.Context, t *testing.T) (state.Tree, vm.StorageMa
cst := hamt.NewCborStore()
d := datastore.NewMapDatastore()
bs := blockstore.NewBlockstore(d)
blk, err := consensus.DefaultGenesis(cst, bs)
blk, err := consensus.TestGenesis(cst, bs)
require.NoError(t, err)

st, err := state.LoadStateTree(ctx, cst, blk.StateRoot, builtin.Actors)
Expand Down
8 changes: 4 additions & 4 deletions node/node_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ func TestConnectsToBootstrapNodes(t *testing.T) {
r := repo.NewInMemoryRepo()
r.Config().Swarm.Address = "/ip4/0.0.0.0/tcp/0"

require.NoError(t, node.Init(ctx, r, consensus.DefaultGenesis))
require.NoError(t, node.Init(ctx, r, consensus.TestGenesis))
r.Config().Bootstrap.Addresses = []string{}
opts, err := node.OptionsFromRepo(r)
require.NoError(t, err)
Expand All @@ -87,7 +87,7 @@ func TestConnectsToBootstrapNodes(t *testing.T) {
r := repo.NewInMemoryRepo()
r.Config().Swarm.Address = "/ip4/0.0.0.0/tcp/0"

require.NoError(t, node.Init(ctx, r, consensus.DefaultGenesis))
require.NoError(t, node.Init(ctx, r, consensus.TestGenesis))
r.Config().Bootstrap.Addresses = []string{peer1, peer2}

opts, err := node.OptionsFromRepo(r)
Expand Down Expand Up @@ -169,7 +169,7 @@ func TestOptionWithError(t *testing.T) {

ctx := context.Background()
r := repo.NewInMemoryRepo()
assert.NoError(t, node.Init(ctx, r, consensus.DefaultGenesis))
assert.NoError(t, node.Init(ctx, r, consensus.TestGenesis))

opts, err := node.OptionsFromRepo(r)
assert.NoError(t, err)
Expand Down Expand Up @@ -208,7 +208,7 @@ func TestNodeConfig(t *testing.T) {
ConfigOpts: configOptions,
InitOpts: initOpts,
OfflineMode: true,
GenesisFunc: consensus.DefaultGenesis,
GenesisFunc: consensus.TestGenesis,
}

n := node.GenNode(t, &tno)
Expand Down
4 changes: 2 additions & 2 deletions node/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,15 @@ func MakeNodesUnstartedWithGif(t *testing.T, numNodes int, offlineMode bool, gif
// MakeNodesUnstarted creates some new nodes with an InMemoryRepo, fake proof verifier, and default genesis block.
// Call StartNodes to start them.
func MakeNodesUnstarted(t *testing.T, numNodes int, offlineMode bool) []*Node {
return MakeNodesUnstartedWithGif(t, numNodes, offlineMode, consensus.DefaultGenesis)
return MakeNodesUnstartedWithGif(t, numNodes, offlineMode, consensus.TestGenesis)
}

// MakeOfflineNode returns a single unstarted offline node.
func MakeOfflineNode(t *testing.T) *Node {
return MakeNodesUnstartedWithGif(t,
1, /* 1 node */
true, /* offline */
consensus.DefaultGenesis)[0]
consensus.TestGenesis)[0]
}

// DefaultTestingConfig returns default configuration for testing
Expand Down
2 changes: 1 addition & 1 deletion plumbing/msg/waiter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type smsgs []*types.SignedMessage
type smsgsSet [][]*types.SignedMessage

func setupTest(t *testing.T) (*hamt.CborIpldStore, *chain.Store, *Waiter) {
d := requiredCommonDeps(t, consensus.DefaultGenesis)
d := requiredCommonDeps(t, consensus.TestGenesis)
return d.cst, d.chainStore, NewWaiter(d.chainStore, d.blockstore, d.cst)
}

Expand Down

0 comments on commit 1f59eee

Please sign in to comment.