fix(rcon): upsert offline pixel grants

RCON GivePixels previously used an UPDATE for offline users, so users without an existing users_currency type 0 row received no pixels while the command still returned success. Match the GivePoints and housekeeping paths with an upsert and add a contract test that keeps offline pixel grants creating missing currency rows.
This commit is contained in:
simoleo89
2026-06-13 02:14:02 +02:00
parent d7fa02a453
commit aaad94f954
2 changed files with 29 additions and 4 deletions
@@ -0,0 +1,24 @@
package com.eu.habbo.messages.rcon;
import org.junit.jupiter.api.Test;
import java.nio.file.Files;
import java.nio.file.Path;
import static org.junit.jupiter.api.Assertions.assertTrue;
class GivePixelsContractTest {
private static String givePixelsSource() throws Exception {
return Files.readString(Path.of("src/main/java/com/eu/habbo/messages/rcon/GivePixels.java"));
}
@Test
void offlinePixelGrantCreatesMissingCurrencyRow() throws Exception {
String source = givePixelsSource();
assertTrue(source.contains("INSERT INTO users_currency"),
"Offline RCON pixel grants must create the users_currency type 0 row when it is missing");
assertTrue(source.contains("ON DUPLICATE KEY UPDATE"),
"Offline RCON pixel grants should increment existing rows with an upsert");
}
}