Skip to content

Commit

Permalink
test: fix miner to respect cooldown
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Sep 25, 2023
1 parent 7b95300 commit 9253aaa
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 0 deletions.
1 change: 1 addition & 0 deletions packages/cli/lib/behavior/behavior.dart
Original file line number Diff line number Diff line change
Expand Up @@ -160,6 +160,7 @@ class MultiJob {
centralCommand,
caches,
ship,
getNow: getNow,
);
shipDetail(ship, '$name ${state.jobIndex} $result');
if (result.isComplete) {
Expand Down
34 changes: 34 additions & 0 deletions packages/cli/test/behavior/miner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,40 @@ void main() {
when(() => db.insertExtraction(any())).thenAnswer((_) => Future.value());

final logger = _MockLogger();

// With the reactor expiration, we should wait.
final reactorExpiration = now.add(const Duration(seconds: 10));
when(() => ship.cooldown).thenReturn(
Cooldown(
shipSymbol: shipSymbol.symbol,
totalSeconds: 0,
remainingSeconds: 0,
expiration: reactorExpiration,
),
);
final reactorWait = await runWithLogger(
logger,
() => advanceMiner(
api,
db,
centralCommand,
caches,
state,
ship,
getNow: getNow,
),
);
expect(reactorWait, reactorExpiration);

// With no wait, we should be able to complete the mining.
when(() => ship.cooldown).thenReturn(
Cooldown(
shipSymbol: shipSymbol.symbol,
totalSeconds: 0,
remainingSeconds: 0,
),
);

final waitUntil = await runWithLogger(
logger,
() => advanceMiner(
Expand Down

0 comments on commit 9253aaa

Please sign in to comment.