-
Notifications
You must be signed in to change notification settings - Fork 44
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
test: Implement unit testing for miner sector deals extraction #994
Conversation
@@ -0,0 +1,677 @@ | |||
// Code generated by mockery v0.0.0-dev. DO NOT EDIT. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code generate mocks for the miner state interface as it's quite large.
@@ -275,6 +276,10 @@ func (t *DataSource) ExecutedAndBlockMessages(ctx context.Context, ts, pts *type | |||
return value.(*lens.TipSetMessages), nil | |||
} | |||
|
|||
func (t *DataSource) MinerLoad(store adt.Store, act *types.Actor) (miner.State, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the logic responsible for loading miners from the blockstore to an interface allowing tests to use mocked miner state for validation.
@@ -14,6 +14,7 @@ import ( | |||
"github.com/filecoin-project/lily/chain/indexer/integrated/tipset" | |||
"github.com/filecoin-project/lily/model" | |||
visormodel "github.com/filecoin-project/lily/model/visor" | |||
"github.com/filecoin-project/lily/testutil" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mechanical change: package rename
"github.com/filecoin-project/lily/tasks/actorstate" | ||
) | ||
|
||
type State interface { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The state type used by miner extractors. Presents a (mockable) interface for gathering miner data for extraction
return ExtractSectorDealsModel(ctx, ec) | ||
} | ||
|
||
func ExtractSectorDealsModel(ctx context.Context, ec extraction.State) (minermodel.MinerSectorDealList, error) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Move the model extraction logic to a testable method. extraction.State
is an interface we can mock.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work!
What
This PR:
SectorDealsExtractor
andLoadMinerStates
methods.SectorDealsExtractor
to improve its testability by moving the extraction logic to a new method -ExtractSectorDealsModel
- which accepts interfaces that may be mocked to mimic a miners state.MinerLoad
on theDataSource
API permitting the miner extractors to load mocked miner states for easier testing.