test(adventure): await exported camp receipt before shutdown
Release / release (push) Failing after 10m14s

This commit is contained in:
dmg committed 2026-09-27 09:51:34 -04:00
1 parent a57b59f4f1
commit 9bb56f3a1c
1 file changed
+17
@@ -393,6 +393,7 @@ class AdventureQuestNativeTest {
await(restarted,()->!fishing.trophies(carrier).isEmpty());
assertEquals(finalEnemy.toString(),fishing.trophies(carrier).getFirst().audit()
.get("final_enemy_id"));
awaitCampExport(restarted,data,receiptId);
restarted.plugin.setEnabled(false);
}
var earned=exportedCampEvents(data).stream().filter(event->event.get("type").getAsString()
@@ -779,6 +780,22 @@ class AdventureQuestNativeTest {
}
}
private static void awaitCampExport(FantasyStickLifecycleNativeTest.Fixture fixture,Path root,
UUID receipt)throws Exception{
for(int attempt=0;attempt<200;attempt++){
if(hasExportedCampReceipt(root,receipt))return;
var task=fixture.tasks.poll(25,java.util.concurrent.TimeUnit.MILLISECONDS);
if(task!=null)task.run();
}
assertTrue(hasExportedCampReceipt(root,receipt),
"Committed camp receipt "+receipt+" did not reach exported JSONL before shutdown");
}
private static boolean hasExportedCampReceipt(Path root,UUID receipt){
try{return exportedCampEvents(root).stream().anyMatch(event->event.get("type").getAsString()
.endsWith("adventure.trophy_earned")&&event.getAsJsonObject("data")
.get("receipt_id").getAsString().equals(receipt.toString()));}
catch(Exception transientExport){return false;}
}
private static List<com.google.gson.JsonObject> exportedCampEvents(Path root)throws Exception{
try(var files=java.nio.file.Files.walk(root.resolve("events"))){
return files.filter(path->path.toString().endsWith(".jsonl"))