Skip to content

Commit 08b6855

Browse files
committed
Fix fuzzing tests sometimes hanging
1 parent ffe7274 commit 08b6855

2 files changed

Lines changed: 11 additions & 2 deletions

File tree

src/integrationtest/java/org/cyclops/integrateddynamics/gametest/GameTestsFuzzing.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
import net.minecraft.nbt.CompoundTag;
1010
import net.minecraft.nbt.NbtIo;
1111
import net.minecraft.world.level.levelgen.structure.templatesystem.StructureTemplate;
12+
import net.neoforged.neoforge.common.NeoForge;
13+
import net.neoforged.neoforge.event.CommandEvent;
1214
import net.neoforged.neoforge.gametest.GameTestHolder;
1315
import net.neoforged.neoforge.gametest.PrefixGameTestTemplate;
1416
import org.apache.commons.compress.utils.Lists;
@@ -72,6 +74,13 @@ public Collection<TestFunction> testsFuzzedNetwork() {
7274
int fuzzingIterations = getFuzzingIterations();
7375
if (fuzzingIterations == 0) {
7476
IntegratedDynamics.clog(Level.INFO, "[Fuzzing] Disabled (FUZZING_ITERATIONS not set to a number)");
77+
} else {
78+
// TODO: check if this hack can be removed in the next MC update.
79+
NeoForge.EVENT_BUS.addListener((CommandEvent event) -> {
80+
// Block all commands, as the `test runclosest` command is being invoked for some reason,
81+
// which causes GameTestTicker#clear to be invoked, which deadlocks the game test runner.
82+
event.setCanceled(true);
83+
});
7584
}
7685
for (int i = 0; i < fuzzingIterations; i++) {
7786
int finalI = i;

src/integrationtest/java/org/cyclops/integrateddynamics/gametest/fuzzing/NetworkFuzzer.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -746,8 +746,8 @@ private void placeDryingBasinWithFluid(BlockPos pos) {
746746
private void placeRandomBlock(BlockPos pos) {
747747
// Filter to only minecraft namespace blocks and get a random one
748748
var minecraftBlocks = BuiltInRegistries.BLOCK.stream()
749-
.filter(block -> BuiltInRegistries.BLOCK.getKey(block)
750-
.getNamespace().equals("minecraft"))
749+
.filter(block -> BuiltInRegistries.BLOCK.getKey(block).getNamespace().equals("minecraft"))
750+
.filter(block -> !BuiltInRegistries.BLOCK.getKey(block).getPath().equals("command_block"))
751751
.toList();
752752

753753
if (!minecraftBlocks.isEmpty()) {

0 commit comments

Comments
 (0)