variadic WithSubsystems

This commit is contained in:
Anton Evangelatov 2021-07-07 13:35:40 +02:00
parent 42ae876711
commit caa366bc6a
2 changed files with 6 additions and 4 deletions

View File

@ -31,14 +31,14 @@ func EnsembleWithMinerAndMarketNodes(t *testing.T, opts ...interface{}) (*TestFu
main, market TestMiner
)
mainNodeOpts := []NodeOpt{WithSubsystem(SSealing), WithSubsystem(SSectorStorage), WithSubsystem(SMining), DisableLibp2p()}
mainNodeOpts := []NodeOpt{WithSubsystems(SSealing, SSectorStorage, SMining), DisableLibp2p()}
mainNodeOpts = append(mainNodeOpts, nopts...)
blockTime := 100 * time.Millisecond
ens := NewEnsemble(t, eopts...).FullNode(&fullnode, nopts...).Miner(&main, &fullnode, mainNodeOpts...).Start()
ens.BeginMining(blockTime)
marketNodeOpts := []NodeOpt{OwnerAddr(fullnode.DefaultKey), MainMiner(&main), WithSubsystem(SStorageMarket)}
marketNodeOpts := []NodeOpt{OwnerAddr(fullnode.DefaultKey), MainMiner(&main), WithSubsystems(SStorageMarket)}
marketNodeOpts = append(marketNodeOpts, nopts...)
ens.Miner(&market, &fullnode, marketNodeOpts...).Start().Connect(market, fullnode)

View File

@ -58,9 +58,11 @@ func WithAllSubsystems() NodeOpt {
}
}
func WithSubsystem(single MinerSubsystem) NodeOpt {
func WithSubsystems(systems ...MinerSubsystem) NodeOpt {
return func(opts *nodeOpts) error {
opts.subsystems = opts.subsystems.Add(single)
for _, s := range systems {
opts.subsystems = opts.subsystems.Add(s)
}
return nil
}
}