Comparer les révisions
3
Révisions
| Auteur | SHA1 | Date | ||
|---|---|---|---|---|
| ||||
|
|
44504eca0c | |||
|
|
bbb08a95f8 | |||
|
|
bfc8f5719c | |||
Aucun fichier ne correspond à votre recherche
@@ -0,0 +1,41 @@
|
||||
#!/bin/sh
|
||||
# Autotests GastinelGarde (16/10/2026) : compile et lance les tests dans un conteneur JDK 21 jetable.
|
||||
# Usage (sur cornafserver) : sh ~/staging/garde-cas-limites-1016/autotests.sh
|
||||
# Entrée : ~/staging/garde-cas-limites-1016/garde.tgz (copie du worktree test/cas-limites, sans .git ni build).
|
||||
# Ne touche ni à ~/server-infra ni au conteneur minecraft-neoforge.
|
||||
set -e
|
||||
D="$HOME/staging/garde-cas-limites-1016"
|
||||
cd "$D"
|
||||
rm -rf src-build
|
||||
mkdir src-build
|
||||
tar xzf garde.tgz -C src-build
|
||||
cd src-build
|
||||
sed -i 's/\r$//' gradlew
|
||||
mkdir -p "$HOME/.cache/gastinelclaims-gradle"
|
||||
set +e
|
||||
nice -n 10 docker run --rm --memory 4g --cpus 4 \
|
||||
-u "$(id -u):$(id -g)" \
|
||||
-e GRADLE_USER_HOME=/gradle-home \
|
||||
-v "$HOME/.cache/gastinelclaims-gradle:/gradle-home" \
|
||||
-v "$(pwd):/src" -w /src \
|
||||
eclipse-temurin:21-jdk \
|
||||
sh ./gradlew --no-daemon clean test > "$D/build.log" 2>&1
|
||||
CODE=$?
|
||||
set -e
|
||||
echo "code de sortie gradle : $CODE"
|
||||
grep -E "FAILED|BUILD|error:|tests completed" "$D/build.log" | head -40
|
||||
echo "--- totaux (XML JUnit) ---"
|
||||
T=0; F=0; E=0; S=0
|
||||
for x in build/test-results/test/*.xml; do
|
||||
[ -f "$x" ] || continue
|
||||
l=$(grep -o '<testsuite [^>]*>' "$x" | head -1)
|
||||
t=$(echo "$l" | sed -n 's/.* tests="\([0-9]*\)".*/\1/p'); f=$(echo "$l" | sed -n 's/.* failures="\([0-9]*\)".*/\1/p')
|
||||
e=$(echo "$l" | sed -n 's/.* errors="\([0-9]*\)".*/\1/p'); s=$(echo "$l" | sed -n 's/.* skipped="\([0-9]*\)".*/\1/p')
|
||||
T=$((T+t)); F=$((F+f)); E=$((E+e)); S=$((S+s))
|
||||
case "$x" in *Autotest*) echo "$(basename "$x") tests=$t echecs=$f erreurs=$e ignores=$s";; esac
|
||||
done
|
||||
echo "TOTAL tests=$T echecs=$F erreurs=$E ignores=$S"
|
||||
echo "--- mesures ---"
|
||||
cat build/minecraft-junit/build/autotests-mesures.txt build/autotests-mesures.txt 2>/dev/null || true
|
||||
echo "--- echecs detailles ---"
|
||||
for x in build/test-results/test/*.xml; do grep -A6 '<failure' "$x" 2>/dev/null | head -30; done | head -120
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.gastinelgarde;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNull;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.Map;
|
||||
import net.minecraft.world.entity.Entity;
|
||||
import net.minecraft.world.entity.EntityType;
|
||||
import net.minecraft.world.entity.Marker;
|
||||
import org.junit.jupiter.api.Assumptions;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Autotests du 16/10/2026, nuit : contournement n°3 de la revue de sécurité (table SUIVIES pleine).
|
||||
*
|
||||
* Garde.boitesVues n'ajoute une cible non joueur à la table que si elle compte moins de SUIVIES_MAX entrées ; sinon
|
||||
* elle renvoie null (pas de mesure) et ne la suivra jamais tant que la table reste pleine. La table est commune à
|
||||
* tout le serveur, les joueurs connectés y comptent aussi (sans plafond), une entrée vit 10 s après le dernier coup.
|
||||
*
|
||||
* Le test remplit la table par réflexion avec des identifiants négatifs (jamais attribués) et frappe une entité
|
||||
* « marker » construite sans monde. Si l'environnement de test ne permet pas de construire l'entité, le test est
|
||||
* ignoré (assumption) au lieu d'échouer.
|
||||
*/
|
||||
class AutotestSuiviesTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
void FAILLE_revue3_tablePleineLesNouvellesCiblesNeSontJamaisSuivies() throws Exception {
|
||||
Field fTable = Garde.class.getDeclaredField("SUIVIES");
|
||||
fTable.setAccessible(true);
|
||||
Map<Integer, Object> table = (Map<Integer, Object>) fTable.get(null);
|
||||
Field fMax = Garde.class.getDeclaredField("SUIVIES_MAX");
|
||||
fMax.setAccessible(true);
|
||||
int max = fMax.getInt(null);
|
||||
assertEquals(256, max);
|
||||
|
||||
Entity cible;
|
||||
try {
|
||||
cible = new Marker(EntityType.MARKER, null);
|
||||
} catch (Throwable t) {
|
||||
Assumptions.abort("entité impossible à construire hors jeu : " + t);
|
||||
return;
|
||||
}
|
||||
table.clear();
|
||||
try {
|
||||
// Témoin : table vide, la cible frappée entre dans la table (mesurée au coup suivant).
|
||||
assertNull(Garde.boitesVues(cible, null, 1000), "premier coup : historique incomplet");
|
||||
assertTrue(table.containsKey(cible.getId()), "témoin : la cible est suivie");
|
||||
|
||||
table.clear();
|
||||
for (int i = 0; i < max; i++) table.put(-1 - i, null);
|
||||
for (int k = 0; k < 5; k++) {
|
||||
assertNull(Garde.boitesVues(cible, null, 1000 + 20 * k), "coup " + k + " non mesuré");
|
||||
}
|
||||
assertFalse(table.containsKey(cible.getId()), "prouvé : table pleine, la cible n'est jamais suivie");
|
||||
assertEquals(max, table.size(), "aucune éviction");
|
||||
} finally {
|
||||
table.clear();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,363 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Autotests du 16/10/2026, nuit : cas limites d'un joueur HONNÊTE (fins d'élytres, bords de blocs, échelles, eau,
|
||||
* slime, miel, montures, téléportations, Create / Aeronautics, riptide, lag).
|
||||
*
|
||||
* Un test {@code honnete_…} vérifie qu'aucun point n'est donné. Un test {@code FAUX_POSITIF_…} montre un cas honnête
|
||||
* (ou plausible, à confirmer en jeu) qui est puni aujourd'hui : il passe tant que le défaut existe.
|
||||
*
|
||||
* Les drapeaux « milieu spécial », « au sol serveur », exemptions… sont calculés par l'adaptateur (Garde.java) à partir
|
||||
* du monde : ici on suppose qu'il les calcule bien. Ce qui dépend de la détection elle-même (bloc de miel trouvé,
|
||||
* contraption vue) n'est pas testable hors jeu.
|
||||
*/
|
||||
class AutotestCasLimitesTest {
|
||||
|
||||
private GardeConfig cfg;
|
||||
private Moteur moteur;
|
||||
private final UUID joueur = UUID.randomUUID();
|
||||
private long tick;
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
cfg = new GardeConfig();
|
||||
cfg.mode(Controle.VOL, Mode.ENFORCE);
|
||||
cfg.mode(Controle.VITESSE, Mode.OFF);
|
||||
cfg.mode(Controle.NO_FALL, Mode.OBSERVE);
|
||||
moteur = new Moteur(cfg);
|
||||
tick = 5000;
|
||||
}
|
||||
|
||||
private static EtatMouvement m(double dxz, double dy, int ticks, boolean sol, boolean milieu) {
|
||||
return new EtatMouvement(dxz, dy, ticks, sol, sol, false, false, false, 0, 0, milieu, false);
|
||||
}
|
||||
|
||||
private static EtatMouvement air(double dy) {
|
||||
return m(0.1, dy, 1, false, false);
|
||||
}
|
||||
|
||||
private static EtatMouvement sol() {
|
||||
return m(0.1, 0, 1, true, false);
|
||||
}
|
||||
|
||||
private static double points(List<Verdict> vs, Controle c) {
|
||||
double p = 0;
|
||||
for (Verdict v : vs) if (v.controle() == c) p += v.points();
|
||||
return p;
|
||||
}
|
||||
|
||||
private double paquet(EtatJoueur e, EtatMouvement mv) {
|
||||
tick += Math.max(1, mv.ticks());
|
||||
List<Verdict> vs = moteur.mouvement(joueur, tick * 50L, e, mv);
|
||||
return points(vs, Controle.VOL) + points(vs, Controle.NO_FALL) + points(vs, Controle.VITESSE);
|
||||
}
|
||||
|
||||
/** Chute vanilla depuis la vitesse v, n ticks. */
|
||||
private double chute(EtatJoueur e, double v, int n) {
|
||||
double total = 0;
|
||||
for (int i = 0; i < n; i++) {
|
||||
total += paquet(e, air(v));
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
private void auSol(int n) {
|
||||
for (int i = 0; i < n; i++) paquet(EtatJoueur.normal(), sol());
|
||||
}
|
||||
|
||||
// --- Élytres -----------------------------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void honnete_atterrissageEnElytresPuisMarche() {
|
||||
auSol(3);
|
||||
EtatJoueur el = EtatJoueur.builder().elytres(true).build();
|
||||
double total = 0;
|
||||
for (int i = 0; i < 100; i++) total += paquet(el, m(1.2, -0.4, 1, false, false));
|
||||
total += paquet(el, m(0.8, -0.3, 1, true, false)); // touche le sol, drapeau encore là
|
||||
for (int i = 0; i < 20; i++) total += paquet(EtatJoueur.normal(), sol());
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_finDElytresVitesseHorizontaleQuiDecroit() {
|
||||
cfg.mode(Controle.VITESSE, Mode.OBSERVE);
|
||||
auSol(3);
|
||||
EtatJoueur el = EtatJoueur.builder().elytres(true).build();
|
||||
for (int i = 0; i < 40; i++) paquet(el, m(1.5, -0.3, 1, false, false));
|
||||
double total = 0, dxz = 1.5, v = -0.3;
|
||||
for (int i = 0; i < 40; i++) { // drapeau tombé, le joueur tombe vraiment : traînée 0,91 et gravité
|
||||
dxz *= VitesseHorizontale.TRAINEE_AIR;
|
||||
total += paquet(EtatJoueur.normal(), m(dxz, v, 1, false, false));
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_finDElytresPlaneQuiContinueCoteClientPuniAussiParVitesse() {
|
||||
cfg.mode(Controle.VOL, Mode.OFF);
|
||||
cfg.mode(Controle.VITESSE, Mode.OBSERVE);
|
||||
auSol(3);
|
||||
EtatJoueur el = EtatJoueur.builder().elytres(true).build();
|
||||
for (int i = 0; i < 40; i++) paquet(el, m(1.0, -0.1, 1, false, false));
|
||||
double total = 0;
|
||||
for (int i = 0; i < 20; i++) total += paquet(EtatJoueur.normal(), m(1.0, -0.1, 1, false, false));
|
||||
// Même famille que C1 et que l'alerte vitesse de totoche10 du 15/10 : l'élan hérité ne couvre que 3 ticks.
|
||||
assertTrue(total > 0, "plané continu après la chute du drapeau : puni par vitesse");
|
||||
}
|
||||
|
||||
// --- Bords de blocs ----------------------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void honnete_glissadeAuBordDUnBlocLaTrancheBalayeeTrouveLeBloc() {
|
||||
// Bloc plein x dans [9 ; 10]. Avant : boîte [9,5 ; 10,1] (sur le bloc). Après un pas de 0,6 : [10,1 ; 10,7].
|
||||
double[] t = NoFall.trancheBalayee(10.1, 64.0, 0.2, 10.7, 0.8, 0.6, 0);
|
||||
assertTrue(t[0] < 10.0 && t[3] > 9.0, "la tranche couvre encore le bloc");
|
||||
assertEquals(63.95, t[1], 1e-9);
|
||||
// Avec le bloc trouvé, « au sol serveur » est vrai : aucun point no-fall.
|
||||
assertEquals(0, NoFall.points(m(0.6, -0.5, 1, true, true)), 1e-9);
|
||||
// Sans la tranche (ancien calcul), le même paquet donnait 0,5 point.
|
||||
assertEquals(0.5, NoFall.points(new EtatMouvement(0.6, -0.5, 1, true, false, false, false, false, 0, 0,
|
||||
false, false)), 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_tomberDUnBordEtSautSousUnPlafond() {
|
||||
auSol(3);
|
||||
double total = chute(EtatJoueur.normal(), -0.0784, 30); // marche au-delà du bord
|
||||
auSol(3);
|
||||
// Saut sous un plafond à 1,25 bloc : +0,42, puis tête cognée (vitesse remise à 0), puis gravité.
|
||||
total += paquet(EtatJoueur.normal(), air(0.42));
|
||||
total += paquet(EtatJoueur.normal(), air(0.05));
|
||||
total += chute(EtatJoueur.normal(), (0 - VolVertical.GRAVITE) * VolVertical.TRAINEE, 6);
|
||||
auSol(3);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
// --- Échelles, eau, slime, miel ------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void honnete_echelleMonteeArretAccroupiEtSortieEnHaut() {
|
||||
auSol(3);
|
||||
double total = 0;
|
||||
for (int i = 0; i < 40; i++) total += paquet(EtatJoueur.normal(), m(0, 0.2, 1, false, true));
|
||||
for (int i = 0; i < 40; i++) total += paquet(EtatJoueur.normal(), m(0, 0, 1, false, true)); // accroupi
|
||||
total += chute(EtatJoueur.normal(), (0.2 - VolVertical.GRAVITE) * VolVertical.TRAINEE, 15); // lâche en haut
|
||||
auSol(3);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_nageEtSortieDeLEauAvecImpulsion() {
|
||||
auSol(3);
|
||||
double total = 0;
|
||||
for (int i = 0; i < 40; i++) total += paquet(EtatJoueur.normal(), m(0.1, 0.1, 1, false, true));
|
||||
// Sortie : impulsion de 0,3 (jumpOutOfFluid) au tick où l'eau n'est plus vue [À VÉRIFIER en jeu].
|
||||
total += chute(EtatJoueur.normal(), 0.3, 20);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_rebondsSurSlime() {
|
||||
auSol(3);
|
||||
double total = chute(EtatJoueur.normal(), -0.0784, 25); // chute de ~10 blocs
|
||||
double v = 1.0;
|
||||
for (int r = 0; r < 4; r++) {
|
||||
total += paquet(EtatJoueur.normal(), m(0.1, 0, 1, true, true)); // contact slime
|
||||
total += chute(EtatJoueur.normal(), v, 30);
|
||||
v *= 0.8;
|
||||
}
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_glissadeLeLongDUnBlocDeMielPuisChute() {
|
||||
auSol(3);
|
||||
double total = chute(EtatJoueur.normal(), 0.42, 3);
|
||||
for (int i = 0; i < 80; i++) total += paquet(EtatJoueur.normal(), m(0, -0.05, 1, false, true));
|
||||
total += chute(EtatJoueur.normal(), (-0.05 - VolVertical.GRAVITE) * VolVertical.TRAINEE, 10);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_mielNonDetecteLaGlissadeEstPriseCommeUnPlane() {
|
||||
// Si l'adaptateur ne voit pas le miel (bloc à plus de 0,1 bloc de la boîte, bloc de mod collant…), la descente
|
||||
// à -0,05 bloc/tick est un plané : la détection elle-même n'est pas testable hors jeu.
|
||||
auSol(3);
|
||||
double total = chute(EtatJoueur.normal(), 0.42, 3);
|
||||
for (int i = 0; i < 30; i++) total += paquet(EtatJoueur.normal(), air(-0.05));
|
||||
assertTrue(total > 0);
|
||||
}
|
||||
|
||||
// --- Montures et véhicules -------------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void honnete_descendreDeChevalEnPleinSaut() {
|
||||
auSol(3);
|
||||
EtatJoueur monte = EtatJoueur.builder().enVehicule(true).build();
|
||||
double total = 0;
|
||||
for (int i = 0; i < 10; i++) total += paquet(monte, air(0.3));
|
||||
total += chute(EtatJoueur.normal(), 0.1, 25);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_sautDeChevalEtBateauQuiTombeDUneFalaise() {
|
||||
UUID j = UUID.randomUUID();
|
||||
double total = 0;
|
||||
double v = 0.9;
|
||||
for (int i = 0; i < 30; i++) { // saut de cheval (force 0,9) : ~25 ticks en l'air
|
||||
EtatVehicule e = new EtatVehicule(EtatVehicule.Type.MONTURE, 0.5, v, 1, false, false, false, 0.3, false);
|
||||
total += points(moteur.vehicule(j, (100 + i) * 50L, EtatJoueur.normal(), e), Controle.VEHICULE_VOL);
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
moteur.nouveauVehicule(j);
|
||||
v = 0;
|
||||
for (int i = 0; i < 80; i++) { // bateau : -0,04 par tick, sans traînée verticale
|
||||
v -= 0.04;
|
||||
EtatVehicule e = new EtatVehicule(EtatVehicule.Type.BATEAU, 0.3, v, 1, false, false, false, 0, false);
|
||||
total += points(moteur.vehicule(j, (200 + i) * 50L, EtatJoueur.normal(), e), Controle.VEHICULE_VOL);
|
||||
}
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
// --- Téléportations ----------------------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void honnete_teleportationEnLAirPuisChute() {
|
||||
auSol(3);
|
||||
double total = 0;
|
||||
for (int t = 0; t <= cfg.graceTeleportTicks; t++) {
|
||||
total += paquet(EtatJoueur.builder().ticksDepuisTeleport(t).build(), air(-0.0784 * Math.min(t, 5)));
|
||||
}
|
||||
total += chute(EtatJoueur.normal(), -0.5, 40);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_teleportationLenteLeJoueurResteFigeApresLaGrace() {
|
||||
// /rtp, /tpa vers des tronçons non chargés : si le client reste figé (dy = 0) plus de 2 s après la
|
||||
// téléportation, la grâce (40 ticks) est finie et l'immobilité en l'air est un plané [À VÉRIFIER en jeu].
|
||||
auSol(3);
|
||||
double total = 0;
|
||||
for (int t = 0; t <= cfg.graceTeleportTicks; t++) {
|
||||
total += paquet(EtatJoueur.builder().ticksDepuisTeleport(t).build(), air(0));
|
||||
}
|
||||
assertEquals(0, total, 1e-9, "pendant la grâce : rien");
|
||||
for (int i = 0; i < 20; i++) total += paquet(EtatJoueur.normal(), air(0));
|
||||
assertTrue(total > 0, "figé 1 s de plus après la grâce : puni");
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_C2_reapparitionPendantUnSetbackNonOuverte() {
|
||||
// Rappel : GraceTeleport n'ouvre pas de grâce pour SETBACK ni pour un renvoi de SETBACK.
|
||||
GraceTeleport g = new GraceTeleport();
|
||||
g.annoncer(GraceTeleport.Origine.SETBACK);
|
||||
assertFalse(g.teleport());
|
||||
g.annoncer(GraceTeleport.Origine.RENVOI);
|
||||
assertFalse(g.teleport(), "renvoi d'un setback non confirmé : pas de grâce non plus");
|
||||
assertTrue(g.teleport(), "une téléportation externe ouvre la grâce");
|
||||
}
|
||||
|
||||
// --- Create / Aeronautics -------------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void honnete_surUnVaisseauQuiMontePuisSautEnBas() {
|
||||
auSol(3);
|
||||
EtatJoueur poche = EtatJoueur.builder().pocheContraption(true).build();
|
||||
double total = 0;
|
||||
for (int i = 0; i < 200; i++) total += paquet(poche, air(0.1)); // le pont monte, le serveur n'y voit pas de sol
|
||||
total += chute(EtatJoueur.normal(), 0.1, 40);
|
||||
assertEquals(0, total, 1e-9);
|
||||
assertTrue(DetectionContraption.dansLaGrace(140, 100, 40));
|
||||
assertFalse(DetectionContraption.dansLaGrace(141, 100, 40));
|
||||
assertFalse(DetectionContraption.dansLaGrace(90, 100, 40), "horloge revenue en arrière : pas de grâce");
|
||||
// Véhicule de mod (dirigeable, train Create) : jamais contrôlé en vol.
|
||||
EtatVehicule dirigeable = new EtatVehicule(EtatVehicule.Type.AUTRE, 0.5, 0.0, 1, false, false, false, 0, false);
|
||||
for (int i = 0; i < 100; i++) {
|
||||
assertEquals(0, points(moteur.vehicule(joueur, (9000 + i) * 50L, EtatJoueur.normal(), dirigeable),
|
||||
Controle.VEHICULE_VOL), 1e-9);
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_vaisseauNonDetecteLeJoueurSurLePontEstPrisPourUnVoleur() {
|
||||
// Dépendance totale à la détection (DetectionContraption / SableAcces), non testable hors jeu : si le pont
|
||||
// d'un grand vaisseau n'est pas vu (distanceContraption trop courte, classe de mod inconnue), punition.
|
||||
auSol(3);
|
||||
double total = 0;
|
||||
for (int i = 0; i < 30; i++) total += paquet(EtatJoueur.normal(), air(0.1));
|
||||
assertTrue(total > 0);
|
||||
}
|
||||
|
||||
// --- Riptide -------------------------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void honnete_vrilleRiptidePuisArcBalistique() {
|
||||
auSol(3);
|
||||
EtatJoueur vrille = EtatJoueur.builder().riptide(true).build();
|
||||
double total = 0;
|
||||
for (int i = 0; i < 20; i++) total += paquet(vrille, m(2.5, 1.5, 1, false, false));
|
||||
total += chute(EtatJoueur.normal(), 1.2, 60);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
// --- Lag ---------------------------------------------------------------------------------------------------------
|
||||
|
||||
/**
|
||||
* Longue chute (80 paquets, un tick client chacun) reçue avec une gigue réseau régulière : {@code motif} donne
|
||||
* les ticks serveur écoulés avant chaque paquet (ex. 3, 0, 0 : trois paquets arrivés ensemble toutes les 3 ticks).
|
||||
*/
|
||||
private double chuteAvecGigue(int[] motif) {
|
||||
auSol(3);
|
||||
double total = 0, v = 0;
|
||||
for (int p = 0; p < 80; p++) {
|
||||
total += paquet(EtatJoueur.normal(), m(0.1, v, motif[p % motif.length], false, false));
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_lagRafalesDeDeuxEtDeCinqPaquets() {
|
||||
assertEquals(0, chuteAvecGigue(new int[] {2, 0}), 1e-9);
|
||||
assertEquals(0, chuteAvecGigue(new int[] {5, 0, 0, 0, 0}), 1e-9);
|
||||
assertEquals(0, chuteAvecGigue(new int[] {4, 0, 0, 0}), 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_lagRafalesDeTroisPaquetsPendantUneLongueChute() {
|
||||
// Un paquet d'UN tick client arrivé après 3 ticks serveur n'est comparé qu'à 2 ou 3 ticks de gravité, et la
|
||||
// vitesse retenue est alors dy / 3 : le paquet suivant est faux aussi. Motif 3, 0, 0 : +1 anomalie par rafale,
|
||||
// premier point après ~31 paquets (1,5 s de chute, ~12 blocs). Simulé, à confirmer avec une trace réelle.
|
||||
double total = chuteAvecGigue(new int[] {3, 0, 0});
|
||||
assertTrue(total > 0);
|
||||
Mesures.noter("Lag 3,0,0 : " + total + " points de vol sur une chute de 80 paquets");
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_gelDuServeurDeTroisSecondesEnPleineChute() {
|
||||
auSol(3);
|
||||
double total = chute(EtatJoueur.normal(), 0.42, 8);
|
||||
total += paquet(EtatJoueur.normal(), m(0.1, -12.0, 60, false, false)); // 60 ticks : vitesse oubliée
|
||||
total += chute(EtatJoueur.normal(), -2.5, 20);
|
||||
assertEquals(0, total, 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_tpsBasLeVolNUtilisePasLeFacteurDeLagMaisLaChuteResteJuste() {
|
||||
EtatJoueur lent = EtatJoueur.builder().tps(12).build();
|
||||
auSol(3);
|
||||
assertEquals(0, chute(lent, 0.42, 60), 1e-9);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,259 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Autotests du 16/10/2026, nuit : contournements signalés par la revue de sécurité automatique des commits 7a5a1c9 /
|
||||
* 937d43d (contrôle coups-hors-boite) et constats C13, C15 de l'autocritique.
|
||||
*
|
||||
* Un test {@code FAILLE_…} passe tant que le contournement marche ; il échouera quand il sera corrigé (inverser
|
||||
* alors l'assertion). Chaque faille a un test « témoin » qui montre que, sans le contournement, la triche est vue.
|
||||
* Le contournement n°3 (table SUIVIES pleine) dépend de Minecraft : voir {@code com.gastinelgarde.AutotestSuiviesTest}.
|
||||
*/
|
||||
class AutotestContournementsTest {
|
||||
|
||||
private static final double V = 0.28; // cible qui sprinte, blocs/tick
|
||||
private GardeConfig cfg;
|
||||
private Moteur moteur;
|
||||
private final UUID joueur = UUID.randomUUID();
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
cfg = new GardeConfig();
|
||||
moteur = new Moteur(cfg);
|
||||
}
|
||||
|
||||
private static double[] boite(double x) {
|
||||
return new double[] {x - 0.3, 0, -0.3, x + 0.3, 1.8, 0.3};
|
||||
}
|
||||
|
||||
/** Boîtes vues : cible qui avance de V par tick en x, arrivée en xNow (comme Garde92Test). */
|
||||
private static double[][] vues(double xNow, int fenetre) {
|
||||
double[][] b = new double[fenetre + 2][];
|
||||
for (int i = 0; i < b.length; i++) b[i] = boite(xNow - V * (b.length - 1 - i));
|
||||
return b;
|
||||
}
|
||||
|
||||
private static double[] vers(double[] de, double x, double y, double z) {
|
||||
return new double[] {x - de[0], y - de[1], z - de[2]};
|
||||
}
|
||||
|
||||
private static double points(List<Verdict> vs, Controle c) {
|
||||
double p = 0;
|
||||
for (Verdict v : vs) if (v.controle() == c) p += v.points();
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Coup mesuré par coups-hors-boite, puis paquet de mouvement suivant (œil et regard « suivants »). */
|
||||
private List<Verdict> coup(long t, EtatJoueur etat, double[] oeil, double[] regard, double[] oeilSuivant,
|
||||
double[] regardSuivant, double xCible, double[][] vues) {
|
||||
List<Verdict> vs = new ArrayList<>(moteur.coupDiffere(joueur, t, etat, oeil, regard, boite(xCible), 3.0,
|
||||
V, true, false, oeil, vues));
|
||||
vs.addAll(moteur.regardPorteeHitbox(joueur, t + 50, oeilSuivant, regardSuivant));
|
||||
return vs;
|
||||
}
|
||||
|
||||
// --- Revue n°1 : ping gonflé au-delà de seriePingMaxMs = coup exempté -----------------------------------------
|
||||
|
||||
private double serieHitboxAvecPing(int ping) {
|
||||
moteur = new Moteur(cfg);
|
||||
EtatJoueur etat = EtatJoueur.builder().pingMs(ping).build();
|
||||
int fenetre = PorteeHitbox.ticksFenetre(ping, cfg);
|
||||
double total = 0;
|
||||
for (int k = 0; k < 10; k++) {
|
||||
double x = 5 * k;
|
||||
double[] oeil = {x, 1.62, -3.0};
|
||||
double[] regard = vers(oeil, x + 0.75, 1.2, 0); // client « hitbox » : 0,45 bloc devant la cible
|
||||
total += points(coup(k * 600L, etat, oeil, regard, oeil, regard, x, vues(x, fenetre)),
|
||||
Controle.COUPS_HORS_BOITE);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_revue1_pingDeclareAuDessusDe500msExempteTotalementLesCoups() {
|
||||
assertTrue(serieHitboxAvecPing(cfg.seriePingMaxMs) > 0, "témoin : à 500 ms, la série est vue");
|
||||
assertEquals(0, serieHitboxAvecPing(cfg.seriePingMaxMs + 1), 1e-9,
|
||||
"prouvé : à 501 ms (ping falsifiable, F07), aucun coup n'est mesuré");
|
||||
}
|
||||
|
||||
// --- Revue n°2 / C13 : regard et œil du paquet SUIVANT acceptés sans borne --------------------------------------
|
||||
|
||||
@Test
|
||||
void FAILLE_revue2_regardSuivantRameneSurLaCibleEffaceLeCoupHorsBoite() {
|
||||
int fenetre = PorteeHitbox.ticksFenetre(30, cfg);
|
||||
double temoin = 0, triche = 0;
|
||||
for (int k = 0; k < 10; k++) {
|
||||
double x = 5 * k;
|
||||
double[] oeil = {x, 1.62, -3.0};
|
||||
double[] hors = {0, 0, -1}; // regard tourné à 180° de la cible au moment du coup
|
||||
double[] surCible = vers(oeil, x, 1.2, 0);
|
||||
triche += points(coup(k * 600L, EtatJoueur.normal(), oeil, hors, oeil, surCible, x, vues(x, fenetre)),
|
||||
Controle.COUPS_HORS_BOITE);
|
||||
}
|
||||
moteur = new Moteur(cfg);
|
||||
for (int k = 0; k < 10; k++) {
|
||||
double x = 5 * k;
|
||||
double[] oeil = {x, 1.62, -3.0};
|
||||
double[] hors = {0, 0, -1};
|
||||
temoin += points(coup(k * 600L, EtatJoueur.normal(), oeil, hors, oeil, hors, x, vues(x, fenetre)),
|
||||
Controle.COUPS_HORS_BOITE);
|
||||
}
|
||||
assertTrue(temoin > 0, "témoin : le même regard gardé au paquet suivant est vu");
|
||||
assertEquals(0, triche, 1e-9, "prouvé : un demi-tour du regard au paquet suivant efface tout (aucune borne d'angle)");
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_revue2_oeilSuivantAvanceDe09BlocEffaceLaPorteeAllongee() {
|
||||
int fenetre = PorteeHitbox.ticksFenetre(30, cfg);
|
||||
double temoin = 0, triche = 0;
|
||||
for (int k = 0; k < 10; k++) {
|
||||
double x = 5 * k;
|
||||
double[] loin = {x, 1.62, -3.9}; // 3,6 blocs de la boîte : reach
|
||||
double[] proche = {x, 1.62, -3.0}; // 0,9 bloc plus près au paquet suivant (sprint : 0,28 bloc/tick)
|
||||
double[] regard = vers(loin, x, 1.2, 0);
|
||||
triche += points(coup(k * 600L, EtatJoueur.normal(), loin, regard, proche, vers(proche, x, 1.2, 0), x,
|
||||
vues(x, fenetre)), Controle.COUPS_HORS_BOITE);
|
||||
}
|
||||
moteur = new Moteur(cfg);
|
||||
for (int k = 0; k < 10; k++) {
|
||||
double x = 5 * k;
|
||||
double[] loin = {x, 1.62, -3.9};
|
||||
double[] regard = vers(loin, x, 1.2, 0);
|
||||
temoin += points(coup(k * 600L, EtatJoueur.normal(), loin, regard, loin, regard, x, vues(x, fenetre)),
|
||||
Controle.COUPS_HORS_BOITE);
|
||||
}
|
||||
assertTrue(temoin > 0);
|
||||
assertEquals(0, triche, 1e-9, "prouvé : l'œil suivant n'est pas borné à un déplacement légal");
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_C13_porteeEtHitboxGardentLeMinimumAvecLePaquetSuivant() {
|
||||
cfg.mode(Controle.COUPS_HORS_BOITE, Mode.OFF);
|
||||
double[] b = boite(0);
|
||||
double[] loin = {0, 1.62, -4.3}; // 4,0 blocs de la boîte : refus vanilla à la limite
|
||||
double[] proche = {0, 1.62, -3.5}; // 3,2 blocs au paquet suivant
|
||||
double[] regard = vers(loin, 0, 1.0, 0);
|
||||
// Témoin : paquet suivant identique.
|
||||
List<Verdict> t = new ArrayList<>(moteur.coupDiffere(joueur, 0, EtatJoueur.normal(), loin, regard, b, 3.0, 0,
|
||||
true, false));
|
||||
t.addAll(moteur.regardPorteeHitbox(joueur, 50, loin, regard));
|
||||
assertTrue(points(t, Controle.PORTEE) > 0, "témoin : 4,0 blocs sur cible immobile est vu");
|
||||
|
||||
moteur = new Moteur(cfg);
|
||||
List<Verdict> v = new ArrayList<>(moteur.coupDiffere(joueur, 0, EtatJoueur.normal(), loin, regard, b, 3.0, 0,
|
||||
true, false));
|
||||
v.addAll(moteur.regardPorteeHitbox(joueur, 50, proche, vers(proche, 0, 1.0, 0)));
|
||||
assertEquals(0, points(v, Controle.PORTEE), 1e-9, "prouvé : s'avancer au paquet suivant efface la portée");
|
||||
|
||||
// Angle killaura : regard à 180° au coup, sur la cible au paquet suivant.
|
||||
cfg.mode(Controle.PORTEE, Mode.OFF);
|
||||
cfg.mode(Controle.HITBOX, Mode.OFF);
|
||||
moteur = new Moteur(cfg);
|
||||
double[] oeil = {0, 1.62, -2.5};
|
||||
List<Verdict> a = new ArrayList<>(moteur.coupDiffere(joueur, 0, EtatJoueur.normal(), oeil, new double[] {0, 0, -1},
|
||||
b, 3.0, 0, false, true));
|
||||
a.addAll(moteur.regardPorteeHitbox(joueur, 50, oeil, vers(oeil, 0, 1.0, 0)));
|
||||
assertEquals(0, points(a, Controle.KILLAURA_ANGLE), 1e-9, "prouvé : rotation silencieuse effacée");
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_C13_reachDe33SurCibleImmobileEtDe40SurCibleQuiSprinteSousLeSeuilPortee() {
|
||||
cfg.mode(Controle.COUPS_HORS_BOITE, Mode.OFF);
|
||||
double[] b = boite(0);
|
||||
double[] oeil33 = {0, 1.62, -3.59}; // 3,29 blocs
|
||||
List<Verdict> v = new ArrayList<>(moteur.coupDiffere(joueur, 0, EtatJoueur.normal(), oeil33,
|
||||
vers(oeil33, 0, 1.0, 0), b, 3.0, 0, true, false));
|
||||
v.addAll(moteur.terminerCoup(joueur));
|
||||
assertEquals(0, points(v, Controle.PORTEE), 1e-9, "3,29 blocs sur cible immobile : rien");
|
||||
|
||||
moteur = new Moteur(cfg);
|
||||
double[] oeil40 = {0, 1.62, -4.29}; // 3,99 blocs, cible qui sprinte
|
||||
v = new ArrayList<>(moteur.coupDiffere(joueur, 0, EtatJoueur.normal(), oeil40, vers(oeil40, 0, 1.0, 0), b, 3.0,
|
||||
V, true, false));
|
||||
v.addAll(moteur.terminerCoup(joueur));
|
||||
assertEquals(0, points(v, Controle.PORTEE), 1e-9, "3,99 blocs sur cible qui sprinte : rien pour portee");
|
||||
}
|
||||
|
||||
// --- Revue n°4 : la fenêtre d'historique grandit avec le ping déclaré ------------------------------------------
|
||||
|
||||
private double serieDerriereLaCible(int ping) {
|
||||
moteur = new Moteur(cfg);
|
||||
EtatJoueur etat = EtatJoueur.builder().pingMs(ping).build();
|
||||
int fenetre = PorteeHitbox.ticksFenetre(ping, cfg); // ce que Garde.boitesVues calcule depuis latency()
|
||||
double total = 0;
|
||||
for (int k = 0; k < 10; k++) {
|
||||
double x = 10 * k;
|
||||
double[] oeil = {x - 1.5, 1.62, -2.5};
|
||||
// Client « hitbox » : touche 3,3 blocs DERRIÈRE le centre de la cible (là où elle était il y a ~12 ticks).
|
||||
double[] regard = vers(oeil, x - 3.6, 1.2, 0);
|
||||
total += points(coup(k * 600L, etat, oeil, regard, oeil, regard, x, vues(x, fenetre)),
|
||||
Controle.COUPS_HORS_BOITE);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_revue4_pingDeclareA450msElargitLaFenetreEtCacheLaTriche() {
|
||||
assertEquals(8, PorteeHitbox.ticksFenetre(30, cfg));
|
||||
assertEquals(16, PorteeHitbox.ticksFenetre(450, cfg));
|
||||
assertEquals(17, PorteeHitbox.ticksFenetre(500, cfg));
|
||||
assertTrue(serieDerriereLaCible(30) > 0, "témoin : à 30 ms, la série est vue");
|
||||
assertEquals(0, serieDerriereLaCible(450), 1e-9,
|
||||
"prouvé : le même client qui annonce 450 ms de ping n'est plus vu (fenêtre 16 ticks au lieu de 8)");
|
||||
}
|
||||
|
||||
// --- C15 : vitesse 0,40 en l'air et Timer 1,09 non vus ---------------------------------------------------------
|
||||
|
||||
private static EtatMouvement pas(double dxz, boolean sol) {
|
||||
return new EtatMouvement(dxz, 0, 1, sol, sol, true, false, false, 0, 0, false, false);
|
||||
}
|
||||
|
||||
private double vitesse(double dxzAir, double dxzSol, int cycle, int ticks) {
|
||||
cfg.mode(Controle.VOL, Mode.OFF);
|
||||
cfg.mode(Controle.NO_FALL, Mode.OFF);
|
||||
moteur = new Moteur(cfg);
|
||||
double total = 0;
|
||||
for (int i = 0; i < ticks; i++) {
|
||||
boolean sol = cycle > 0 && i % cycle == 0;
|
||||
total += points(moteur.mouvement(joueur, i * 50L, EtatJoueur.normal(), pas(sol ? dxzSol : dxzAir, sol)),
|
||||
Controle.VITESSE);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_C15_bhopA040BlocParTickNestJamaisVu() {
|
||||
// 1 tick au sol, 11 en l'air, à 0,40 bloc/tick (un sprint-saut honnête fait en moyenne ~0,28 à 0,33).
|
||||
assertEquals(0, vitesse(0.40, 0.40, 12, 400), 1e-9);
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_C15_speedAuSolA037BlocParTickNestJamaisVu() {
|
||||
assertTrue(vitesse(0.45, 0.45, 1, 200) > 0, "témoin : 0,45 au sol (+50 %) est vu");
|
||||
// 0,37 au sol : +23 % sur le sprint (0,30), l'excès (0,06/tick) reste sous le tampon de 1,5 bloc / 20 ticks.
|
||||
assertEquals(0, vitesse(0.37, 0.37, 1, 400), 1e-9);
|
||||
}
|
||||
|
||||
private double timer(long intervalleMs, int secondes) {
|
||||
moteur = new Moteur(cfg);
|
||||
double total = 0;
|
||||
for (long t = 0; t < secondes * 1000L; t += intervalleMs) {
|
||||
total += points(moteur.paquetMouvement(joueur, 10_000 + t, EtatJoueur.normal()), Controle.TIMER);
|
||||
}
|
||||
return total;
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_C15_timerA109NestJamaisVu() {
|
||||
assertTrue(timer(40, 10) > 0, "témoin : 25 paquets/s (timer 1,25) est vu");
|
||||
assertEquals(0, timer(46, 30), 1e-9, "prouvé : 21,7 paquets/s (timer 1,09) pendant 30 s, aucun point");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,272 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
/**
|
||||
* Autotests du 16/10/2026, nuit : incident VOL de Rednixxu (15/10, 17:31) et constats C1 à C5, C10 de l'autocritique.
|
||||
*
|
||||
* Ces tests DOCUMENTENT le comportement actuel, ils ne corrigent rien : un test nommé {@code FAILLE_…} ou
|
||||
* {@code FAUX_POSITIF_…} passe tant que le défaut existe. Quand le défaut sera corrigé, il échouera : il faudra alors
|
||||
* inverser son assertion (c'est voulu, pour que la correction soit vue).
|
||||
*
|
||||
* Ce qui se passe dans l'adaptateur (Garde.java, qui dépend de Minecraft) est rejoué ici par un petit modèle écrit
|
||||
* d'après le code : position mémorisée après un paquet sans verdict (Garde.apresMouvement), paquet suivant un
|
||||
* teleport() non mesuré (Garde.teleportVanilla remet mouvementTick à zéro).
|
||||
*/
|
||||
class AutotestVolIncidentTest {
|
||||
|
||||
private static final double Y_SOL = 110.875;
|
||||
|
||||
private GardeConfig cfg;
|
||||
private Moteur moteur;
|
||||
private final UUID joueur = UUID.randomUUID();
|
||||
private int tick;
|
||||
private double y;
|
||||
/** Modèle de Garde.apresMouvement : dernière position mémorisée (y) et si elle était au sol serveur. */
|
||||
private double yRetour;
|
||||
private boolean retourAuSol;
|
||||
|
||||
@BeforeEach
|
||||
void init() {
|
||||
cfg = new GardeConfig();
|
||||
cfg.mode(Controle.VOL, Mode.ENFORCE); // mode en production le 15/10 (rapport des journaux)
|
||||
cfg.mode(Controle.VITESSE, Mode.OFF);
|
||||
cfg.mode(Controle.NO_FALL, Mode.OFF);
|
||||
moteur = new Moteur(cfg);
|
||||
tick = 37_000;
|
||||
y = Y_SOL;
|
||||
yRetour = Y_SOL;
|
||||
retourAuSol = true;
|
||||
}
|
||||
|
||||
static EtatMouvement air(double dy) {
|
||||
return new EtatMouvement(0.1, dy, 1, false, false, false, false, false, 0, 0, false, false);
|
||||
}
|
||||
|
||||
static EtatMouvement sol() {
|
||||
return new EtatMouvement(0.1, 0, 1, true, true, false, false, false, 0, 0, false, false);
|
||||
}
|
||||
|
||||
static double points(List<Verdict> vs, Controle c) {
|
||||
double p = 0;
|
||||
for (Verdict v : vs) if (v.controle() == c) p += v.points();
|
||||
return p;
|
||||
}
|
||||
|
||||
/** Un paquet accepté, avec le modèle de mémorisation de la position de retour. */
|
||||
private List<Verdict> paquet(EtatJoueur e, EtatMouvement m) {
|
||||
tick++;
|
||||
y += m.dy();
|
||||
List<Verdict> vs = moteur.mouvement(joueur, tick * 50L, e, m);
|
||||
if (vs.isEmpty()) { // Garde.apresMouvement : m.dernierVerdictTick != tick
|
||||
yRetour = y;
|
||||
retourAuSol = m.auSolServeur();
|
||||
}
|
||||
return vs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Trace de Rednixxu (rapport des journaux, ticks 37 589 à 37 614) : au sol à y = 110,875, saut, drapeau élytres
|
||||
* pendant 7 ticks, drapeau retombé alors que le client plane encore (accélération ~0,02 bloc/tick² au lieu de 0,08).
|
||||
*
|
||||
* @return verdicts de chaque paquet de plané sans drapeau
|
||||
*/
|
||||
private List<List<Verdict>> sautPuisPlaneSansDrapeau(int ticksPlane) {
|
||||
for (int i = 0; i < 5; i++) paquet(EtatJoueur.normal(), sol());
|
||||
double v = 0.42;
|
||||
for (int i = 0; i < 5; i++) { // saut normal
|
||||
paquet(EtatJoueur.normal(), air(v));
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
EtatJoueur elytres = EtatJoueur.builder().elytres(true).build();
|
||||
for (int i = 0; i < 7; i++) paquet(elytres, air(-0.05)); // drapeau 16 : exempté
|
||||
List<List<Verdict>> sortie = new ArrayList<>();
|
||||
for (int k = 1; k <= ticksPlane; k++) sortie.add(paquet(EtatJoueur.normal(), air(-0.02 * k)));
|
||||
return sortie;
|
||||
}
|
||||
|
||||
// --- C1 : pas de grâce de sortie d'élytres pour le vol ----------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_C1_planeDElytresDontLeDrapeauTombeEstPrisPourDuVol() {
|
||||
List<List<Verdict>> vs = sautPuisPlaneSansDrapeau(19);
|
||||
int premier = -1;
|
||||
double total = 0;
|
||||
for (int k = 0; k < vs.size(); k++) {
|
||||
double p = points(vs.get(k), Controle.VOL);
|
||||
if (p > 0 && premier < 0) premier = k + 1;
|
||||
total += p;
|
||||
}
|
||||
// Prouvé : le 1er paquet après l'exemption sert de référence, les suivants sont tous « anormaux » ; le 12e tick
|
||||
// de plané sans drapeau donne le premier point (journal réel : 13 ticks après la chute du drapeau, vl=1.1).
|
||||
assertEquals(12, premier, "premier tick de plané puni");
|
||||
assertEquals(1.1, points(vs.get(11), Controle.VOL), 1e-9);
|
||||
assertTrue(total > cfg.seuilSetback, "19 ticks de plané suffisent à dépasser le seuil de setback");
|
||||
Mesures.noter("C1 premier point au tick " + premier + " de plane sans drapeau ; total 19 ticks = " + total);
|
||||
}
|
||||
|
||||
@Test
|
||||
void honnete_finDElytresSuivieDUneVraieChuteNeDonneRien() {
|
||||
for (int i = 0; i < 5; i++) paquet(EtatJoueur.normal(), sol());
|
||||
EtatJoueur elytres = EtatJoueur.builder().elytres(true).build();
|
||||
for (int i = 0; i < 40; i++) paquet(elytres, air(-0.5));
|
||||
double v = -0.5, total = 0;
|
||||
for (int i = 0; i < 60; i++) {
|
||||
total += points(paquet(EtatJoueur.normal(), air(v)), Controle.VOL);
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
assertEquals(0, total, 1e-9, "réfuté : une fin d'élytres suivie d'une chute vanilla ne donne rien");
|
||||
}
|
||||
|
||||
// --- C3 : point de retour mémorisé en l'air -----------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_C3_pointDeRetourMemoriseEnLAirSousLaPlateforme() {
|
||||
List<List<Verdict>> vs = sautPuisPlaneSansDrapeau(12);
|
||||
assertTrue(points(vs.get(11), Controle.VOL) > 0);
|
||||
assertFalse(retourAuSol, "la position de retour vient d'un paquet en l'air");
|
||||
assertTrue(yRetour < Y_SOL, "et elle est sous la plateforme d'où il a sauté : " + yRetour);
|
||||
Mesures.noter(String.format(java.util.Locale.ROOT,
|
||||
"C3 retour en l'air a y=%.3f (sol %.3f, ecart %.3f ; journal reel : 109,685, ecart 1,19)",
|
||||
yRetour, Y_SOL, Y_SOL - yRetour));
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_C3_unVolDeDixTicksGardeLAltitudeGagneeDansLePointDeRetour() {
|
||||
for (int i = 0; i < 5; i++) paquet(EtatJoueur.normal(), sol());
|
||||
int premier = -1;
|
||||
for (int k = 1; k <= 15 && premier < 0; k++) {
|
||||
if (points(paquet(EtatJoueur.normal(), air(0.1)), Controle.VOL) > 0) premier = k;
|
||||
}
|
||||
assertTrue(premier > 10, "le vol n'est vu qu'après 10 ticks anormaux");
|
||||
assertFalse(retourAuSol);
|
||||
assertTrue(yRetour - Y_SOL >= 0.9, "le setback ramène à l'altitude gagnée en volant : +" + (yRetour - Y_SOL));
|
||||
Mesures.noter(String.format(java.util.Locale.ROOT, "C3 tricheur : retour a +%.2f bloc au-dessus du sol",
|
||||
yRetour - Y_SOL));
|
||||
}
|
||||
|
||||
// --- C2, C5, C4 : setback sans remise à zéro, escalade en moins d'une seconde, expulsion répétée ------------------
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_C2_setbackNOuvreAucuneGraceEtNeRemetPasLeVolAZero() {
|
||||
GraceTeleport g = new GraceTeleport();
|
||||
g.annoncer(GraceTeleport.Origine.SETBACK);
|
||||
assertFalse(g.teleport(), "le setback n'ouvre pas la grâce de téléportation");
|
||||
|
||||
List<List<Verdict>> vs = sautPuisPlaneSansDrapeau(19);
|
||||
int k = 0;
|
||||
while (Verdict.pire(vs.get(k)) != Sanction.SETBACK) k++; // premier SETBACK
|
||||
// Modèle de l'adaptateur : teleport() vers le point de retour ; le paquet suivant n'est pas mesuré.
|
||||
tick++;
|
||||
y = yRetour;
|
||||
// Joueur gelé en l'air au point de retour (dy = 0, gravité absente tant que la téléportation n'est pas
|
||||
// confirmée : « kicked for floating too long » x302 dans le journal du 15/10).
|
||||
for (int i = 0; i < 5; i++) {
|
||||
List<Verdict> v = paquet(EtatJoueur.normal(), air(0));
|
||||
assertTrue(points(v, Controle.VOL) > 0, "paquet gelé " + i + " après le setback encore puni");
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAUX_POSITIF_C5_C4_cinqSetbacksPuisExpulsionEnMoinsDUneSecondeEtExpulsionRepetee() {
|
||||
for (int i = 0; i < 5; i++) paquet(EtatJoueur.normal(), sol());
|
||||
double v = 0.42;
|
||||
for (int i = 0; i < 5; i++) {
|
||||
paquet(EtatJoueur.normal(), air(v));
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
EtatJoueur elytres = EtatJoueur.builder().elytres(true).build();
|
||||
for (int i = 0; i < 7; i++) paquet(elytres, air(-0.05));
|
||||
|
||||
int premierPointTick = -1, setbacks = 0, expulsionTick = -1;
|
||||
double dyPlane = 0;
|
||||
boolean gele = false;
|
||||
for (int n = 0; n < 200 && expulsionTick < 0; n++) {
|
||||
EtatMouvement m;
|
||||
if (gele) {
|
||||
m = air(0);
|
||||
} else {
|
||||
dyPlane -= 0.02;
|
||||
m = air(dyPlane);
|
||||
}
|
||||
List<Verdict> vs = paquet(EtatJoueur.normal(), m);
|
||||
if (points(vs, Controle.VOL) > 0 && premierPointTick < 0) premierPointTick = tick;
|
||||
Sanction s = Verdict.pire(vs);
|
||||
if (s == Sanction.SETBACK) {
|
||||
setbacks++;
|
||||
gele = true;
|
||||
tick++; // teleport() : le paquet suivant n'est pas mesuré (Garde.teleportVanilla)
|
||||
y = yRetour;
|
||||
} else if (s == Sanction.EXPULSION) {
|
||||
expulsionTick = tick;
|
||||
}
|
||||
}
|
||||
assertTrue(expulsionTick > 0, "expulsion atteinte");
|
||||
int duree = expulsionTick - premierPointTick;
|
||||
Mesures.noter("C5 premier point -> expulsion : " + duree + " ticks (" + duree * 50 + " ms), " + setbacks
|
||||
+ " setbacks (journal reel : 5 setbacks, expulsion a la 1re seconde)");
|
||||
assertTrue(duree < 20, "moins d'une seconde entre le premier point et l'expulsion : " + duree + " ticks");
|
||||
assertTrue(setbacks >= 3 && setbacks <= 6, "quelques setbacks seulement : " + setbacks);
|
||||
|
||||
// C4 (partie moteur) : rien ne retient « déjà expulsé » ; chaque paquet suivant redonne une EXPULSION.
|
||||
int expulsionsSuivantes = 0;
|
||||
for (int i = 0; i < 20; i++) {
|
||||
if (Verdict.pire(paquet(EtatJoueur.normal(), air(0))) == Sanction.EXPULSION) expulsionsSuivantes++;
|
||||
}
|
||||
assertEquals(20, expulsionsSuivantes, "chaque paquet après l'expulsion rend encore EXPULSION");
|
||||
}
|
||||
|
||||
@Test
|
||||
void referenceEnObserveLeMemeIncidentNeToucheJamaisLeJoueur() {
|
||||
cfg.mode(Controle.VOL, Mode.OBSERVE);
|
||||
List<List<Verdict>> vs = sautPuisPlaneSansDrapeau(40);
|
||||
for (List<Verdict> v : vs) {
|
||||
assertNotEquals(Sanction.SETBACK, Verdict.pire(v));
|
||||
assertNotEquals(Sanction.EXPULSION, Verdict.pire(v));
|
||||
}
|
||||
}
|
||||
|
||||
// --- C10 : sauts en l'air espacés --------------------------------------------------------------------------------
|
||||
|
||||
@Test
|
||||
void FAILLE_C10_unSautEnLAirTousLesDixTicksMonteSansFinSansAucunPoint() {
|
||||
for (int i = 0; i < 5; i++) paquet(EtatJoueur.normal(), sol());
|
||||
double total = 0;
|
||||
double depart = y;
|
||||
for (int cycle = 0; cycle < 30; cycle++) {
|
||||
double v = 0.42; // « saut » en plein air
|
||||
for (int i = 0; i < 10; i++) {
|
||||
total += points(paquet(EtatJoueur.normal(), air(v)), Controle.VOL);
|
||||
v = (v - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
}
|
||||
}
|
||||
assertEquals(0, total, 1e-9, "prouvé : aucun point");
|
||||
// ~0,5 bloc gagné par cycle de 10 ticks : ~15 blocs en 15 s, sans limite.
|
||||
assertTrue(y - depart > 10, "et le tricheur a gagné " + (y - depart) + " blocs en 15 s");
|
||||
Mesures.noter(String.format(java.util.Locale.ROOT, "C10 : +%.1f blocs en 300 ticks, 0 point", y - depart));
|
||||
}
|
||||
|
||||
@Test
|
||||
void FAILLE_C10_alternerUnTickAnormalEtUnTickNormalPlaneSansPoint() {
|
||||
for (int i = 0; i < 5; i++) paquet(EtatJoueur.normal(), sol());
|
||||
double total = 0;
|
||||
double depart = y;
|
||||
for (int i = 0; i < 200; i++) {
|
||||
// tick pair : plané (dy = -0,02, anormal) ; tick impair : la vraie gravité depuis ce plané (normal)
|
||||
double dy = i % 2 == 0 ? -0.02 : (-0.02 - VolVertical.GRAVITE) * VolVertical.TRAINEE;
|
||||
total += points(paquet(EtatJoueur.normal(), air(dy)), Controle.VOL);
|
||||
}
|
||||
assertEquals(0, total, 1e-9);
|
||||
// 200 ticks de chute vanilla depuis l'arrêt : plus de 200 blocs. Ici : ~6 blocs.
|
||||
assertTrue(depart - y < 15, "descente de " + (depart - y) + " blocs en 10 s (chute lente illimitée)");
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
package com.gastinelgarde.core;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.StandardOpenOption;
|
||||
|
||||
/**
|
||||
* Autotests du 16/10/2026 : note les valeurs mesurées par les tests (nombre de paquets avant expulsion, altitude du
|
||||
* point de retour…) dans build/autotests-mesures.txt, pour le rapport. N'influence aucun résultat.
|
||||
*/
|
||||
final class Mesures {
|
||||
|
||||
private Mesures() { }
|
||||
|
||||
static void noter(String ligne) {
|
||||
try {
|
||||
Path p = Path.of("build", "autotests-mesures.txt");
|
||||
Files.createDirectories(p.getParent());
|
||||
Files.writeString(p, ligne + System.lineSeparator(), StandardCharsets.UTF_8,
|
||||
StandardOpenOption.CREATE, StandardOpenOption.APPEND);
|
||||
} catch (IOException | RuntimeException ignored) {
|
||||
// mesure facultative
|
||||
}
|
||||
}
|
||||
}
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur