Skip to content

Commit

Permalink
chore: delete nearestWaypointWithMarket, dead code
Browse files Browse the repository at this point in the history
  • Loading branch information
eseidel committed Oct 10, 2023
1 parent 38de7de commit 0cc5274
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 82 deletions.
20 changes: 0 additions & 20 deletions packages/cli/lib/behavior/miner.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,26 +149,6 @@ int expectedValueFromSurvey(
return totalValue ~/ survey.deposits.length;
}

/// Returns the nearest waypoint with a marketplace.
Future<Waypoint?> nearestWaypointWithMarket(
WaypointCache waypointCache,
Waypoint start, {
int maxJumps = 1,
}) async {
if (start.hasMarketplace) {
return start;
}
await for (final waypoint in waypointCache.waypointsInJumpRadius(
startSystem: start.systemSymbolObject,
maxJumps: maxJumps,
)) {
if (waypoint.hasMarketplace) {
return waypoint;
}
}
return null;
}

class _ValuedSurvey {
_ValuedSurvey({
required this.expectedValue,
Expand Down
62 changes: 0 additions & 62 deletions packages/cli/test/behavior/miner_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -101,68 +101,6 @@ void main() {
);
expect(maybeSurvey!.deposits.first.symbol, 'DIAMONDS');
});
test('nearestWaypointWithMarket returns start', () async {
final waypointCache = _MockWaypointCache();
final start = _MockWaypoint();
when(() => start.traits).thenReturn(
[
WaypointTrait(
symbol: WaypointTraitSymbolEnum.MARKETPLACE,
name: '',
description: '',
),
],
);
final nearest = await nearestWaypointWithMarket(waypointCache, start);
expect(nearest, start);
});

test('nearestWaypointWithMarket null', () async {
final waypointCache = _MockWaypointCache();
final start = _MockWaypoint();
final market = _MockWaypoint();
when(() => start.traits).thenReturn([]);
final symbol = WaypointSymbol.fromString('S-E-W');
when(() => start.symbol).thenReturn(symbol.waypoint);
when(() => start.systemSymbol).thenReturn(symbol.system);
when(
() => waypointCache.waypointsInJumpRadius(
startSystem: symbol.systemSymbol,
maxJumps: any(named: 'maxJumps'),
),
).thenAnswer((_) => Stream.fromIterable([market]));
when(() => market.traits).thenReturn([]);
final nearest = await nearestWaypointWithMarket(waypointCache, start);
expect(nearest, isNull);
});

test('nearestWaypointWithMarket', () async {
final waypointCache = _MockWaypointCache();
final start = _MockWaypoint();
final market = _MockWaypoint();
when(() => start.traits).thenReturn([]);
final symbol = WaypointSymbol.fromString('S-E-W');
when(() => start.symbol).thenReturn(symbol.waypoint);
when(() => start.systemSymbol).thenReturn(symbol.system);
when(
() => waypointCache.waypointsInJumpRadius(
startSystem: symbol.systemSymbol,
maxJumps: any(named: 'maxJumps'),
),
).thenAnswer((_) => Stream.fromIterable([market]));
when(() => market.traits).thenReturn(
[
WaypointTrait(
symbol: WaypointTraitSymbolEnum.MARKETPLACE,
name: '',
description: '',
),
],
);
final nearest = await nearestWaypointWithMarket(waypointCache, start);
expect(nearest, market);
});

test('advanceMiner smoke test', () async {
final api = _MockApi();
final db = _MockDatabase();
Expand Down

0 comments on commit 0cc5274

Please sign in to comment.