diff --git a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java index c5969ab5b0d..9c5b273f09f 100644 --- a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java +++ b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderFluidIngredientTest.java @@ -32,8 +32,6 @@ import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.gametest.PrefixGameTestTemplate; -import lombok.Getter; - /** * Test cases: * Do many passes of most tests as a safeguard against bad rolls @@ -65,9 +63,10 @@ public class IntProviderFluidIngredientTest { /** * How many times to repeat the Batch and Parallel random roll tests to avoid false positives * Currently set to 7, with singleblock recipes processing up to 9 fluids, allowing for stacks of up to 63 fluids. + * Set 20 times for Batch/Parallel multis */ - @Getter private static final int REPLICAS = 7; + private static final int MULTI_REPLICAS = 20; @BeforeBatch(batch = "RangedFluidIngredients") public static void prepare(ServerLevel level) { @@ -595,9 +594,7 @@ public static void multiblockLCRRangedFluidOutput(GameTestHelper helper) { // test for multiblock machine with 16x Parallels with ranged fluid input @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedFluidIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedFluidInput16Parallel(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -614,14 +611,14 @@ public static void multiblockLCentRangedFluidInput16Parallel(GameTestHelper help itemIn.setStackInSlot(0, COBBLE.copyWithCount(batches * parallels)); fluidIn.setFluidInTank(0, new FluidStack(LCENT_IN, amount)); - // 1t to turn on, 4t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] rolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] rolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { FluidStack results = fluidIn.getFluidInTank(0); int upperLimit = amount - (batches * parallels * 0); int lowerLimit = amount - (batches * parallels * 40); @@ -631,8 +628,9 @@ public static void multiblockLCentRangedFluidInput16Parallel(GameTestHelper help ((int) Math.round(fluidOut.getTotalContentAmount()))), new FluidStack(REDSTONE, completed)), "Parallel LCent didn't complete correct number of recipes, completed [" + - ((int) Math.round(fluidOut.getTotalContentAmount())) + "] not [" + - completed + "]"); + ((int) Math.round(fluidOut.getTotalContentAmount())) + "] not [" + completed + + "].\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); helper.assertTrue(TestUtils.isFluidWithinRange(results, lowerLimit, upperLimit), "Parallel LCent didn't consume correct number of fluids, consumed " + (amount - results.getAmount()) + "] not [" + lowerLimit + "-" + upperLimit + "]"); @@ -645,10 +643,10 @@ public static void multiblockLCentRangedFluidInput16Parallel(GameTestHelper help }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - for (int i = 0; i < REPLICAS; i++) { + for (int i = 0; i < MULTI_REPLICAS; i++) { if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; GTCEu.LOGGER.warn("Parallel LCent ranged fluid input test iteration " + i + " consumed [" + @@ -669,9 +667,7 @@ public static void multiblockLCentRangedFluidInput16Parallel(GameTestHelper help // test for multiblock machine with 16x Parallels with ranged fluid output @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedFluidIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedFluidOutput16Parallel(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -685,18 +681,20 @@ public static void multiblockLCentRangedFluidOutput16Parallel(GameTestHelper hel busHolder.controller.setBatchEnabled(false); busHolder.parallelHatch.setCurrentParallel(parallels); - // 1t to turn on, 1t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] addedRolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] addedRolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { int runs = finalI * batches * parallels; helper.assertTrue(fluidIn.getFluidInTank(0).isEmpty(), "Parallel LCent didn't complete correct number of recipes, completed [" + - fluidIn.getFluidInTank(0).getAmount() + "] not [" + runs + "]"); + fluidIn.getFluidInTank(0).getAmount() + "] not [" + runs + + "]\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); int resultCount = (int) Math.round(fluidOut.getTotalContentAmount()); int lowerLimit = runs * 0; int upperLimit = runs * 40; @@ -711,10 +709,10 @@ public static void multiblockLCentRangedFluidOutput16Parallel(GameTestHelper hel }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - int[] rolls = new int[REPLICAS]; + int[] rolls = new int[MULTI_REPLICAS]; rolls[0] = addedRolls[0]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[0], batches, parallels, 1)) { @@ -723,7 +721,7 @@ public static void multiblockLCentRangedFluidOutput16Parallel(GameTestHelper hel rolls[0] + "] fluids, a multiple of its Batch * Parallel count (" + (batches * parallels) + "). If this message only appears once, this is likely a false positive."); } - for (int i = 1; i < REPLICAS; i++) { + for (int i = 1; i < MULTI_REPLICAS; i++) { rolls[i] = addedRolls[i] - addedRolls[i - 1]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; @@ -745,9 +743,7 @@ public static void multiblockLCentRangedFluidOutput16Parallel(GameTestHelper hel // test for multiblock machine with 16x Parallels with ranged fluid input @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedFluidIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedFluidInputBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -764,14 +760,14 @@ public static void multiblockLCentRangedFluidInputBatched(GameTestHelper helper) itemIn.setStackInSlot(0, COBBLE.copyWithCount(batches * parallels)); fluidIn.setFluidInTank(0, new FluidStack(LCENT_IN, amount)); - // 1t to turn on, 1t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 batches // check the results of all rolls together - // repeat recipe REPLICAS times - int[] rolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] rolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { FluidStack results = fluidIn.getFluidInTank(0); int upperLimit = amount - (batches * parallels * 0); int lowerLimit = amount - (batches * parallels * 40); @@ -781,8 +777,9 @@ public static void multiblockLCentRangedFluidInputBatched(GameTestHelper helper) ((int) Math.round(fluidOut.getTotalContentAmount()))), new FluidStack(REDSTONE, completed)), "Batched LCent didn't complete correct number of recipes, completed [" + - ((int) Math.round(fluidOut.getTotalContentAmount())) + "] not [" + - completed + "]"); + ((int) Math.round(fluidOut.getTotalContentAmount())) + "] not [" + completed + + "].\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); helper.assertTrue(TestUtils.isFluidWithinRange(results, lowerLimit, upperLimit), "Batched LCent didn't consume correct number of fluids, consumed " + (amount - results.getAmount()) + "] not [" + lowerLimit + "-" + upperLimit + "]"); @@ -795,10 +792,10 @@ public static void multiblockLCentRangedFluidInputBatched(GameTestHelper helper) }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - for (int i = 0; i < REPLICAS; i++) { + for (int i = 0; i < MULTI_REPLICAS; i++) { if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; GTCEu.LOGGER.warn("Batched LCent ranged fluid input test iteration " + i + " consumed [" + @@ -819,9 +816,7 @@ public static void multiblockLCentRangedFluidInputBatched(GameTestHelper helper) // test for multiblock machine with 16x Parallels with ranged fluid output @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedFluidIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedFluidOutputBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -835,18 +830,20 @@ public static void multiblockLCentRangedFluidOutputBatched(GameTestHelper helper busHolder.controller.setBatchEnabled(true); busHolder.parallelHatch.setCurrentParallel(parallels); - // 1t to turn on, 1t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] addedRolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] addedRolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { int runs = finalI * batches * parallels; helper.assertTrue(fluidIn.getFluidInTank(0).isEmpty(), "Batched LCent didn't complete correct number of recipes, completed [" + - fluidIn.getFluidInTank(0).getAmount() + "] not [" + runs + "]"); + fluidIn.getFluidInTank(0).getAmount() + "] not [" + runs + + "]\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); int resultCount = (int) Math.round(fluidOut.getTotalContentAmount()); int lowerLimit = runs * 0; int upperLimit = runs * 40; @@ -861,10 +858,10 @@ public static void multiblockLCentRangedFluidOutputBatched(GameTestHelper helper }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - int[] rolls = new int[REPLICAS]; + int[] rolls = new int[MULTI_REPLICAS]; rolls[0] = addedRolls[0]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[0], batches, parallels, 1)) { @@ -873,7 +870,7 @@ public static void multiblockLCentRangedFluidOutputBatched(GameTestHelper helper rolls[0] + "] fluids, a multiple of its Batch * Parallel count (" + batches + "). If this message only appears once, this is likely a false positive."); } - for (int i = 1; i < REPLICAS; i++) { + for (int i = 1; i < MULTI_REPLICAS; i++) { rolls[i] = addedRolls[i] - addedRolls[i - 1]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; @@ -895,9 +892,7 @@ public static void multiblockLCentRangedFluidOutputBatched(GameTestHelper helper // test for multiblock machine with 16x Parallels with ranged fluid input @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedFluidIngredients", - timeoutTicks = 500, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedFluidInput16ParallelBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -918,13 +913,13 @@ public static void multiblockLCentRangedFluidInput16ParallelBatched(GameTestHelp } fluidIn.setFluidInTank(0, new FluidStack(LCENT_IN, amount)); - // 1t to turn on, 64t per recipe run + // 1t to turn on, 64t per recipe run, 10t buffer for sanity // check the results of all rolls together - // repeat recipe REPLICAS times - int[] rolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] rolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(65 * finalI, () -> { + helper.runAfterDelay(75 * finalI, () -> { FluidStack results = fluidIn.getFluidInTank(0); int completed = batches * parallels * finalI; helper.assertTrue( @@ -932,7 +927,9 @@ public static void multiblockLCentRangedFluidInput16ParallelBatched(GameTestHelp new FluidStack(fluidOut.getFluidInTank(0), fluidOut.getFluidInTank(0).getAmount()), new FluidStack(REDSTONE, completed)), "Batched Parallel LCent didn't complete correct number of recipes, completed [" + - (fluidOut.getFluidInTank(0).getAmount()) + "] not [" + completed + "]"); + (fluidOut.getFluidInTank(0).getAmount()) + "] not [" + completed + + "]\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); int upperLimit = amount - (batches * parallels * 0); int lowerLimit = amount - (batches * parallels * 40); helper.assertTrue(TestUtils.isFluidWithinRange(results, lowerLimit, upperLimit), @@ -950,10 +947,10 @@ public static void multiblockLCentRangedFluidInput16ParallelBatched(GameTestHelp }); } - helper.runAfterDelay(1 + 65 * REPLICAS, () -> { + helper.runAfterDelay(1 + 75 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - for (int i = 0; i < REPLICAS; i++) { + for (int i = 0; i < MULTI_REPLICAS; i++) { if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; GTCEu.LOGGER.warn("Batched Parallel LCent ranged fluid input test iteration " + i + " consumed [" + @@ -974,9 +971,7 @@ public static void multiblockLCentRangedFluidInput16ParallelBatched(GameTestHelp // test for multiblock machine with 16x Parallels with ranged fluid output @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedFluidIngredients", - timeoutTicks = 500, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedFluidOutput16ParallelBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -990,17 +985,19 @@ public static void multiblockLCentRangedFluidOutput16ParallelBatched(GameTestHel fluidIn.setFluidInTank(0, new FluidStack(LCENT_OUT, batches * parallels)); - // 1t to turn on, 64t per recipe run + // 1t to turn on, 64t per recipe run, 10t buffer for sanity // check the results of all rolls together - // repeat recipe REPLICAS times - int[] addedRolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] addedRolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(65 * finalI, () -> { + helper.runAfterDelay(75 * finalI, () -> { int runs = finalI * batches * parallels; helper.assertTrue(fluidIn.isEmpty(), "Batched Parallel LCent didn't complete correct number of recipes, completed [" + - (runs - fluidIn.getFluidInTank(0).getAmount()) + "] not [" + runs + "]"); + (runs - fluidIn.getFluidInTank(0).getAmount()) + "] not [" + runs + + "]\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); int resultCount = fluidOut.getFluidInTank(0).getAmount(); int lowerLimit = runs * 0; int upperLimit = runs * 40; @@ -1015,10 +1012,10 @@ public static void multiblockLCentRangedFluidOutput16ParallelBatched(GameTestHel }); } - helper.runAfterDelay(1 + 65 * REPLICAS, () -> { + helper.runAfterDelay(1 + 75 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - int[] rolls = new int[REPLICAS]; + int[] rolls = new int[MULTI_REPLICAS]; rolls[0] = addedRolls[0]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[0], batches, parallels, 1)) { @@ -1027,7 +1024,7 @@ public static void multiblockLCentRangedFluidOutput16ParallelBatched(GameTestHel rolls[0] + "] fluids, a multiple of its Batch * Parallel count (" + (batches * parallels) + "). If this message only appears once, this is likely a false positive."); } - for (int i = 1; i < REPLICAS; i++) { + for (int i = 1; i < MULTI_REPLICAS; i++) { rolls[i] = addedRolls[i] - addedRolls[i - 1]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; diff --git a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java index f3b7bee123a..83cff670fa8 100644 --- a/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java +++ b/src/test/java/com/gregtechceu/gtceu/api/recipe/ingredient/IntProviderIngredientTest.java @@ -28,8 +28,6 @@ import net.minecraftforge.gametest.GameTestHolder; import net.minecraftforge.gametest.PrefixGameTestTemplate; -import lombok.Getter; - /** * Test cases: * do many passes of most tests as a safeguard against bad rolls @@ -60,9 +58,10 @@ public class IntProviderIngredientTest { /** * How many times to repeat the Batch and Parallel random roll tests to avoid false positives * Currently set to 7, with singleblock recipes processing up to 9 items, allowing for stacks of up to 63 items. + * Set 20 times for Batch/Parallel multis */ - @Getter private static final int REPLICAS = 7; + private static final int MULTI_REPLICAS = 20; @BeforeBatch(batch = "RangedIngredients") public static void prepare(ServerLevel level) { @@ -584,9 +583,7 @@ public static void multiblockLCRRangedItemOutput(GameTestHelper helper) { // test for multiblock machine with 16x Parallels with ranged item input @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedItemInput16Parallel(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -601,14 +598,14 @@ public static void multiblockLCentRangedItemInput16Parallel(GameTestHelper helpe itemIn.setStackInSlot(0, LCENT_IN.copyWithCount(64)); itemIn.setStackInSlot(1, COBBLE.copyWithCount(parallels)); - // 1t to turn on, 4t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] rolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] rolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { ItemStack results = itemIn.getStackInSlot(0); int upperLimit = 64 - (batches * parallels * 0); int lowerLimit = 64 - (batches * parallels * 4); @@ -618,8 +615,9 @@ public static void multiblockLCentRangedItemInput16Parallel(GameTestHelper helpe .copyWithCount((int) Math.round(itemOut.getTotalContentAmount())), STONE.copyWithCount(completed)), "Parallel LCent didn't complete correct number of recipes, completed [" + - ((int) Math.round(itemOut.getTotalContentAmount())) + "] not [" + - completed + "]"); + ((int) Math.round(itemOut.getTotalContentAmount())) + "] not [" + completed + + "]\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); helper.assertTrue(TestUtils.isItemWithinRange(results, lowerLimit, upperLimit), "Parallel LCent didn't consume correct number of items, consumed " + (64 - results.getCount()) + "] not [" + lowerLimit + "-" + upperLimit + "]"); @@ -632,10 +630,10 @@ public static void multiblockLCentRangedItemInput16Parallel(GameTestHelper helpe }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - for (int i = 0; i < REPLICAS; i++) { + for (int i = 0; i < MULTI_REPLICAS; i++) { if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; GTCEu.LOGGER.warn("Parallel LCent ranged item input test iteration " + i + " consumed [" + @@ -656,9 +654,7 @@ public static void multiblockLCentRangedItemInput16Parallel(GameTestHelper helpe // test for multiblock machine with 16x Parallels with ranged item output @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedItemOutput16Parallel(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -672,18 +668,21 @@ public static void multiblockLCentRangedItemOutput16Parallel(GameTestHelper help busHolder.controller.setBatchEnabled(false); busHolder.parallelHatch.setCurrentParallel(parallels); - // 1t to turn on, 1t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] addedRolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] addedRolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { int runs = finalI * batches * parallels; helper.assertTrue(itemIn.getStackInSlot(0).isEmpty(), "Parallel LCent didn't complete correct number of recipes, completed [" + - itemIn.getStackInSlot(0).getCount() + "] not [" + runs + "]"); + (int) Math.round(itemIn.getTotalContentAmount()) + "] not [" + runs + + "]\n Current machine state: " + + busHolder.controller.recipeLogic.getStatus() + "\nFailed recipes follow:\n" + + TestUtils.getFailures(busHolder.controller.recipeLogic)); int resultCount = (int) Math.round(itemOut.getTotalContentAmount()); int lowerLimit = runs * 0; int upperLimit = runs * 4; @@ -698,10 +697,10 @@ public static void multiblockLCentRangedItemOutput16Parallel(GameTestHelper help }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - int[] rolls = new int[REPLICAS]; + int[] rolls = new int[MULTI_REPLICAS]; rolls[0] = addedRolls[0]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[0], batches, parallels, 1)) { @@ -710,7 +709,7 @@ public static void multiblockLCentRangedItemOutput16Parallel(GameTestHelper help rolls[0] + "] items, a multiple of its Batch * Parallel count (" + (batches * parallels) + "). If this message only appears once, this is likely a false positive."); } - for (int i = 1; i < REPLICAS; i++) { + for (int i = 1; i < MULTI_REPLICAS; i++) { rolls[i] = addedRolls[i] - addedRolls[i - 1]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; @@ -732,9 +731,7 @@ public static void multiblockLCentRangedItemOutput16Parallel(GameTestHelper help // test for multiblock machine with 16x Parallels with ranged item input @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedItemInputBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -749,14 +746,14 @@ public static void multiblockLCentRangedItemInputBatched(GameTestHelper helper) itemIn.setStackInSlot(0, LCENT_IN.copyWithCount(64)); itemIn.setStackInSlot(1, COBBLE.copyWithCount(batches)); - // 1t to turn on, 1t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 batches // check the results of all rolls together - // repeat recipe REPLICAS times - int[] rolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] rolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { ItemStack results = itemIn.getStackInSlot(0); int upperLimit = 64 - (batches * parallels * 0); int lowerLimit = 64 - (batches * parallels * 4); @@ -766,8 +763,9 @@ public static void multiblockLCentRangedItemInputBatched(GameTestHelper helper) .copyWithCount((int) Math.round(itemOut.getTotalContentAmount())), STONE.copyWithCount(completed)), "Parallel LCent didn't complete correct number of recipes, completed [" + - ((int) Math.round(itemOut.getTotalContentAmount())) + "] not [" + - completed + "]"); + ((int) Math.round(itemOut.getTotalContentAmount())) + "] not [" + completed + + "]\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); helper.assertTrue(TestUtils.isItemWithinRange(results, lowerLimit, upperLimit), "Parallel LCent didn't consume correct number of items, consumed " + (64 - results.getCount()) + "] not [" + lowerLimit + "-" + upperLimit + "]"); @@ -780,10 +778,10 @@ public static void multiblockLCentRangedItemInputBatched(GameTestHelper helper) }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - for (int i = 0; i < REPLICAS; i++) { + for (int i = 0; i < MULTI_REPLICAS; i++) { if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; GTCEu.LOGGER.warn("Parallel LCent ranged item input test iteration " + i + " consumed [" + @@ -804,9 +802,7 @@ public static void multiblockLCentRangedItemInputBatched(GameTestHelper helper) // test for multiblock machine with 16x Parallels with ranged item output @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedIngredients", - timeoutTicks = 200, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedItemOutputBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -820,18 +816,20 @@ public static void multiblockLCentRangedItemOutputBatched(GameTestHelper helper) busHolder.controller.setBatchEnabled(true); busHolder.parallelHatch.setCurrentParallel(parallels); - // 1t to turn on, 1t per recipe run + // 1t to turn on, 1t per recipe run, 4t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] addedRolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] addedRolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(17 * finalI, () -> { + helper.runAfterDelay(21 * finalI, () -> { int runs = finalI * batches * parallels; helper.assertTrue(itemIn.getStackInSlot(0).isEmpty(), "Batched LCent didn't complete correct number of recipes, completed [" + - itemIn.getStackInSlot(0).getCount() + "] not [" + runs + "]"); + itemIn.getStackInSlot(0).getCount() + "] not [" + runs + "]\n Current machine state: " + + busHolder.controller.recipeLogic.getStatus() + "\nFailed recipes follow:\n" + + TestUtils.getFailures(busHolder.controller.recipeLogic)); int resultCount = (int) Math.round(itemOut.getTotalContentAmount()); int lowerLimit = runs * 0; int upperLimit = runs * 4; @@ -846,10 +844,10 @@ public static void multiblockLCentRangedItemOutputBatched(GameTestHelper helper) }); } - helper.runAfterDelay(1 + 17 * REPLICAS, () -> { + helper.runAfterDelay(1 + 21 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - int[] rolls = new int[REPLICAS]; + int[] rolls = new int[MULTI_REPLICAS]; rolls[0] = addedRolls[0]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[0], batches, parallels, 1)) { @@ -858,7 +856,7 @@ public static void multiblockLCentRangedItemOutputBatched(GameTestHelper helper) rolls[0] + "] items, a multiple of its Batch * Parallel count (" + batches + "). If this message only appears once, this is likely a false positive."); } - for (int i = 1; i < REPLICAS; i++) { + for (int i = 1; i < MULTI_REPLICAS; i++) { rolls[i] = addedRolls[i] - addedRolls[i - 1]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; @@ -880,9 +878,7 @@ public static void multiblockLCentRangedItemOutputBatched(GameTestHelper helper) // test for multiblock machine with 16x Parallels with ranged item input @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedIngredients", - timeoutTicks = 500, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedItemInput16ParallelBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -904,14 +900,14 @@ public static void multiblockLCentRangedItemInput16ParallelBatched(GameTestHelpe itemIn.setStackInSlot(k, LCENT_IN.copyWithCount(64)); } - // 1t to turn on, 1t per recipe run + // 1t to turn on, 64t per recipe run, 10t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] rolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] rolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(65 * finalI, () -> { + helper.runAfterDelay(75 * finalI, () -> { ItemStack results = itemIn.getStackInSlot(0); int upperLimit = 64 - (batches * parallels * 0); int lowerLimit = 64 - (batches * parallels * 4); @@ -920,8 +916,9 @@ public static void multiblockLCentRangedItemInput16ParallelBatched(GameTestHelpe .copyWithCount((int) Math.round(itemOut.getTotalContentAmount())), STONE.copyWithCount(completed)), "Batched Parallel LCent didn't complete correct number of recipes, completed [" + - ((int) Math.round(itemOut.getTotalContentAmount())) + "] not [" + - completed + "]"); + ((int) Math.round(itemOut.getTotalContentAmount())) + "] not [" + completed + + "]\n Current machine state: " + busHolder.controller.recipeLogic.getStatus() + + "\nFailed recipes follow:\n" + TestUtils.getFailures(busHolder.controller.recipeLogic)); helper.assertTrue(TestUtils.isItemWithinRange(results, lowerLimit, upperLimit), "Batched Parallel LCent didn't consume correct number of items, consumed " + (64 - results.getCount()) + "] not [" + lowerLimit + "-" + upperLimit + "]"); @@ -940,10 +937,10 @@ public static void multiblockLCentRangedItemInput16ParallelBatched(GameTestHelpe }); } - helper.runAfterDelay(1 + 65 * REPLICAS, () -> { + helper.runAfterDelay(1 + 75 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - for (int i = 0; i < REPLICAS; i++) { + for (int i = 0; i < MULTI_REPLICAS; i++) { if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; GTCEu.LOGGER.warn("Batched Parallel LCent ranged item input test iteration " + i + " consumed [" + @@ -964,9 +961,7 @@ public static void multiblockLCentRangedItemInput16ParallelBatched(GameTestHelpe // test for multiblock machine with 16x Parallels with ranged item output @GameTest(template = "large_centrifuge_zpm_batch_parallel16", batch = "RangedIngredients", - timeoutTicks = 500, - requiredSuccesses = 1, - attempts = 10) + timeoutTicks = 2000) public static void multiblockLCentRangedItemOutput16ParallelBatched(GameTestHelper helper) { BusHolderBatchParallel busHolder = getBussesAndFormLCENT(helper); @@ -982,21 +977,24 @@ public static void multiblockLCentRangedItemOutput16ParallelBatched(GameTestHelp itemIn.setStackInSlot(j, LCENT_OUT.copyWithCount(16)); } - // 1t to turn on, 1t per recipe run + // 1t to turn on, 64t per recipe run, 10t buffer for sanity // 16 parallels // check the results of all rolls together - // repeat recipe REPLICAS times - int[] addedRolls = new int[REPLICAS]; - for (int i = 1; i <= REPLICAS; i++) { + // repeat recipe MULTI_REPLICAS times + int[] addedRolls = new int[MULTI_REPLICAS]; + for (int i = 1; i <= MULTI_REPLICAS; i++) { final int finalI = i; // lambda preserve you - helper.runAfterDelay(65 * finalI, () -> { + helper.runAfterDelay(75 * finalI, () -> { int runs = finalI * batches * parallels; helper.assertTrue(itemIn.isEmpty(), "Batched Parallel LCent didn't complete correct number of recipes, completed [" + - itemIn.getTotalContentAmount() + "] not [" + runs + "]"); + (runs - itemIn.getTotalContentAmount()) + "] not [" + runs + + "]\nCurrent machine state: " + + busHolder.controller.recipeLogic.getStatus() + "\nFailed recipes follow:\n" + + TestUtils.getFailures(busHolder.controller.recipeLogic)); int resultCount = (int) Math.round(itemOut.getTotalContentAmount()); - int lowerLimit = runs * 0; - int upperLimit = runs * 4; + int lowerLimit = batches * parallels * 0; + int upperLimit = batches * parallels * 4; helper.assertTrue(TestUtils.isCountWithinRange(resultCount, lowerLimit, upperLimit), "Batched Parallel LCent didn't produce correct number of items, produced [" + resultCount + "] not [" + lowerLimit + "-" + upperLimit + "]"); @@ -1007,13 +1005,17 @@ public static void multiblockLCentRangedItemOutput16ParallelBatched(GameTestHelp for (int j = 0; j < batches; j++) { itemIn.setStackInSlot(j, LCENT_OUT.copyWithCount(16)); } + // Don't overflow the output bus + for (int j = 0; j < itemOut.getSize(); j++) { + itemOut.setStackInSlot(j, ItemStack.EMPTY); + } }); } - helper.runAfterDelay(1 + 65 * REPLICAS, () -> { + helper.runAfterDelay(1 + 75 * MULTI_REPLICAS, () -> { // check if each roll was a multiple of run count boolean sus = false; - int[] rolls = new int[REPLICAS]; + int[] rolls = new int[MULTI_REPLICAS]; rolls[0] = addedRolls[0]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[0], batches, parallels, 1)) { @@ -1022,7 +1024,7 @@ public static void multiblockLCentRangedItemOutput16ParallelBatched(GameTestHelp rolls[0] + "] items, a multiple of its Batch * Parallel count (" + (batches * parallels) + "). If this message only appears once, this is likely a false positive."); } - for (int i = 1; i < REPLICAS; i++) { + for (int i = 1; i < MULTI_REPLICAS; i++) { rolls[i] = addedRolls[i] - addedRolls[i - 1]; if (TestUtils.isStackSizeExactlyEvenMultiple(rolls[i], batches, parallels, 1)) { sus = true; diff --git a/src/test/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineTests.java b/src/test/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineTests.java index 2fb13dd1ca3..a9adbefdfb6 100644 --- a/src/test/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineTests.java +++ b/src/test/java/com/gregtechceu/gtceu/common/machine/multiblock/electric/AssemblyLineTests.java @@ -88,7 +88,7 @@ public static void AsslineRecipeRunsTest(GameTestHelper helper) { TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item didn't craft at the right tick with ok recipe" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); } @@ -104,7 +104,7 @@ public static void AsslineRecipeDoesntRunWhenItemsMovedByOneTest(GameTestHelper TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item crafted with inputs moved" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); TestUtils.succeedAfterTest(helper); } @@ -121,7 +121,7 @@ public static void AsslineRecipeDoesntRunWhenFluidsMovedByOneTest(GameTestHelper TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item crafted with inputs moved" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); TestUtils.succeedAfterTest(helper); } @@ -138,7 +138,7 @@ public static void AsslineRecipeDoesntRunWhenBothMovedByOneTest(GameTestHelper h TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item crafted with inputs moved" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); TestUtils.succeedAfterTest(helper); } @@ -175,7 +175,7 @@ public static void AsslineRecipeRunsAndOnlyConsumesOneTest(GameTestHelper helper TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item didn't craft at the right tick with ok recipe" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); // All 4 inputs had the second one consumed helper.assertTrue( busHolder.inputBus1.getInventory().getStackInSlot(0).isEmpty(), @@ -196,7 +196,7 @@ public static void AsslineRecipeRunsAndOnlyConsumesOneTest(GameTestHelper helper TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE, 2)), "Item didn't craft at the right tick with ok recipe" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); TestUtils.succeedAfterTest(helper); } @@ -213,7 +213,7 @@ public static void AsslineRecipeDoesntRunWhenItemsSwappedTest(GameTestHelper hel TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item crafted with inputs moved" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); TestUtils.succeedAfterTest(helper); } @@ -230,7 +230,7 @@ public static void AsslineRecipeDoesntRunWhenFluidsSwappedTest(GameTestHelper he TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item crafted with inputs moved" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); TestUtils.succeedAfterTest(helper); } @@ -247,7 +247,7 @@ public static void AsslineRecipeDoesntRunWhenBothSwappedTest(GameTestHelper help TestUtils.isItemStackEqual(busHolder.outputBus1.getInventory().getStackInSlot(0), new ItemStack(Blocks.STONE)), "Item crafted with inputs moved" + - busHolder.outputBus1.getInventory().getStackInSlot(0).getDisplayName()); + busHolder.outputBus1.getInventory().getStackInSlot(0).getHoverName().getString()); }); TestUtils.succeedAfterTest(helper); } diff --git a/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java b/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java index 0f33104c6de..1b3481957a9 100644 --- a/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java +++ b/src/test/java/com/gregtechceu/gtceu/gametest/util/TestUtils.java @@ -12,6 +12,7 @@ import com.gregtechceu.gtceu.api.machine.MachineDefinition; import com.gregtechceu.gtceu.api.machine.MetaMachine; import com.gregtechceu.gtceu.api.machine.multiblock.MultiblockControllerMachine; +import com.gregtechceu.gtceu.api.machine.trait.RecipeLogic; import com.gregtechceu.gtceu.api.placeholder.MultiLineComponent; import com.gregtechceu.gtceu.api.recipe.GTRecipeType; import com.gregtechceu.gtceu.api.registry.GTRegistries; @@ -223,6 +224,21 @@ public static GTRecipeType createRecipeType(String name, int maxInputs, int maxO return type; } + /** + * Fetches the set of Failed Recipes and Reasons from a machine's {@link RecipeLogic} + * Returns a newline-separated string of all failed recipes and their failure reasons + */ + public static String getFailures(RecipeLogic recipeLogic) { + var reasons = recipeLogic.getFailureReasonMap(); + StringBuilder failures = new StringBuilder(); + if (!reasons.isEmpty()) { + for (var reason : reasons.entrySet()) { + failures.append(reason.getKey().id).append(" - ").append(reason).append("\n"); + } + } + return failures.toString(); + } + public static CoverBehavior placeCover(GameTestHelper helper, MetaMachine machine, ItemStack stack, Direction direction) { return placeCover(helper, machine, stack, direction, false);