feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
package mining
|
|
|
|
|
|
|
|
|
|
// ManagerInterface defines the interface for a miner manager.
|
2025-11-14 14:32:57 +00:00
|
|
|
// This interface abstracts the core functionalities of a miner manager,
|
|
|
|
|
// allowing for different implementations to be used interchangeably. It provides
|
|
|
|
|
// a standard way to manage the lifecycle of miners and retrieve their data.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
type ManagerInterface interface {
|
2025-11-14 14:32:57 +00:00
|
|
|
// StartMiner starts a new miner with the given configuration.
|
|
|
|
|
// It takes the miner type and a configuration object, and returns the
|
|
|
|
|
// created miner instance or an error if the miner could not be started.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
StartMiner(minerType string, config *Config) (Miner, error)
|
2025-11-14 14:32:57 +00:00
|
|
|
|
|
|
|
|
// StopMiner stops a running miner.
|
|
|
|
|
// It takes the name of the miner to be stopped and returns an error if the
|
|
|
|
|
// miner could not be stopped.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
StopMiner(name string) error
|
2025-11-14 14:32:57 +00:00
|
|
|
|
|
|
|
|
// GetMiner retrieves a running miner by its name.
|
|
|
|
|
// It returns the miner instance or an error if the miner is not found.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
GetMiner(name string) (Miner, error)
|
2025-11-14 14:32:57 +00:00
|
|
|
|
|
|
|
|
// ListMiners returns a slice of all running miners.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
ListMiners() []Miner
|
2025-11-14 14:32:57 +00:00
|
|
|
|
|
|
|
|
// ListAvailableMiners returns a list of available miners that can be started.
|
|
|
|
|
// This provides a way to discover the types of miners supported by the manager.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
ListAvailableMiners() []AvailableMiner
|
2025-11-14 14:32:57 +00:00
|
|
|
|
|
|
|
|
// GetMinerHashrateHistory returns the hashrate history for a specific miner.
|
|
|
|
|
// It takes the name of the miner and returns a slice of hashrate points
|
|
|
|
|
// or an error if the miner is not found.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
GetMinerHashrateHistory(name string) ([]HashratePoint, error)
|
2025-11-14 14:32:57 +00:00
|
|
|
|
|
|
|
|
// Stop stops the manager and its background goroutines.
|
|
|
|
|
// It should be called when the manager is no longer needed to ensure a
|
|
|
|
|
// graceful shutdown of any background processes.
|
feat: Increase test coverage for pkg/mining
This commit introduces a number of new tests for the `pkg/mining` package,
increasing the overall test coverage from 8.2% to 40.7%.
The following changes were made:
- Added tests for the `XMRigMiner` struct, including its methods for
installation, starting, stopping, and getting stats.
- Added tests for the `Service` layer, including the API endpoints for
listing, starting, stopping, and getting stats for miners.
- Added tests for the `Manager`, including starting and stopping multiple
miners, collecting stats, and getting hashrate history.
- Introduced a `ManagerInterface` to decouple the `Service` layer from the
concrete `Manager` implementation, facilitating testing with mocks.
2025-11-10 00:06:35 +00:00
|
|
|
Stop()
|
|
|
|
|
}
|