-
Notifications
You must be signed in to change notification settings - Fork 154
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Feature] Lathe Arbitrage Integration Test (#997)
* Lathe Arbitrage Integration Test * Fix All argitrage recipes * Fix pricing? * Update electronics.yml
- Loading branch information
Showing
21 changed files
with
102 additions
and
26 deletions.
There are no files selected for viewing
62 changes: 62 additions & 0 deletions
62
Content.IntegrationTests/Tests/Backmen/Lathe/LatheRecipyCostTest.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
using System.Collections.Generic; | ||
using Content.Server.Cargo.Systems; | ||
using Content.Shared.Research.Prototypes; | ||
|
||
namespace Content.IntegrationTests.Tests.Backmen.Lathe; | ||
|
||
[TestFixture] | ||
public sealed class LatheRecipyCostTest | ||
{ | ||
private const double Tolerance = 10; | ||
|
||
[Test] | ||
public async Task LatheRecipesNoArbitrageTest() | ||
{ | ||
await using var pair = await PoolManager.GetServerClient(); | ||
|
||
var server = pair.Server; | ||
var proto = server.ProtoMan; | ||
var entMan = server.EntMan; | ||
var priceSystem = entMan.System<PricingSystem>(); | ||
|
||
var fails = new List<string>(); | ||
|
||
await server.WaitAssertion(() => | ||
{ | ||
var recipes = proto.EnumeratePrototypes<LatheRecipePrototype>(); | ||
foreach (var recipe in recipes) | ||
{ | ||
var resultPrice = Math.Round(priceSystem.GetLatheRecipePrice(recipe)); | ||
var matPrice = 0.0; | ||
bool ignoreRecipe = false; | ||
foreach (var (materialId, count) in recipe.Materials) | ||
{ | ||
var material = proto.Index(materialId); | ||
|
||
if (material.IgnoreArbitrage) | ||
ignoreRecipe = true; | ||
|
||
matPrice += material.Price * count; | ||
} | ||
|
||
if (ignoreRecipe) | ||
continue; | ||
|
||
matPrice = Math.Round(matPrice); | ||
|
||
if (resultPrice > matPrice + Tolerance) | ||
{ | ||
fails.Add($"ID: {recipe.ID} Materials: {matPrice} Result: {resultPrice} Dif: {resultPrice - matPrice}"); | ||
} | ||
} | ||
}); | ||
|
||
if (fails.Count > 0) | ||
{ | ||
var msg = string.Join("\n", fails) + "\n" + "Following RecipePrototypes are giving Arbitrage when printed!"; | ||
Assert.Fail(msg); | ||
} | ||
|
||
await pair.CleanReturnAsync(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ | |
- type: Tag | ||
tags: | ||
- StationMapElectronics | ||
- type: StaticPrice | ||
price: 30 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ | |
- type: Tag | ||
tags: | ||
- FirelockElectronics | ||
- type: StaticPrice | ||
price: 61 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,3 @@ | |
tags: | ||
- FreezerElectronics | ||
- type: DoorElectronics | ||
- type: StaticPrice | ||
price: 55 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -586,6 +586,4 @@ | |
min: 2 | ||
max: 2 | ||
- type: StaticPrice | ||
price: 250 | ||
|
||
|
||
price: 170 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters