refactor(test): add a common.test module and move the captured payloads into fixtures (#97)
This commit is contained in:
1 parent
6427c3498b
commit
9866c1b0fb
65 files changed
+158
-211
No files matched your search
@@ -4,4 +4,7 @@ plugins {
|
|||||||
id("buildsrc.convention.sonarlint")
|
id("buildsrc.convention.sonarlint")
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies { testImplementation(libs.bundles.kotest) }
|
dependencies {
|
||||||
|
testImplementation(project(":common.test"))
|
||||||
|
testImplementation(libs.bundles.kotest)
|
||||||
|
}
|
||||||
@@ -1,9 +1,9 @@
|
|||||||
package de.fiereu.bytecodec
|
package de.fiereu.bytecodec
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.assertBytesRoundtrip
|
import de.fiereu.openmmo.common.test.assertBytesRoundtrip
|
||||||
import de.fiereu.bytecodec.test.assertValueRoundtrip
|
import de.fiereu.openmmo.common.test.assertValueRoundtrip
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import io.kotest.assertions.throwables.shouldThrow
|
import io.kotest.assertions.throwables.shouldThrow
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
package de.fiereu.bytecodec
|
package de.fiereu.bytecodec
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.assertBytesRoundtrip
|
import de.fiereu.openmmo.common.test.assertBytesRoundtrip
|
||||||
import de.fiereu.bytecodec.test.assertValueRoundtrip
|
import de.fiereu.openmmo.common.test.assertValueRoundtrip
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import io.kotest.assertions.throwables.shouldThrow
|
import io.kotest.assertions.throwables.shouldThrow
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package de.fiereu.bytecodec
|
package de.fiereu.bytecodec
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.assertBytesRoundtrip
|
import de.fiereu.openmmo.common.test.assertBytesRoundtrip
|
||||||
import de.fiereu.bytecodec.test.assertValueRoundtrip
|
import de.fiereu.openmmo.common.test.assertValueRoundtrip
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,13 @@
|
|||||||
|
plugins {
|
||||||
|
id("buildsrc.convention.kotlin-jvm")
|
||||||
|
id("buildsrc.convention.spotless")
|
||||||
|
id("buildsrc.convention.sonarlint")
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
api(project(":bytecodec"))
|
||||||
|
api(project(":common"))
|
||||||
|
api(libs.bundles.kotest)
|
||||||
|
// Only DockerAvailable needs this, so consumers that never touch it stay clear of testcontainers.
|
||||||
|
compileOnly(libs.testcontainers.postgresql)
|
||||||
|
}
|
||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
package de.fiereu.openmmo.server.game.testsupport
|
package de.fiereu.openmmo.common.test
|
||||||
|
|
||||||
import io.kotest.core.annotation.Condition
|
import io.kotest.core.annotation.Condition
|
||||||
import io.kotest.core.spec.Spec
|
import io.kotest.core.spec.Spec
|
||||||
@@ -0,0 +1,16 @@
|
|||||||
|
package de.fiereu.openmmo.common.test
|
||||||
|
|
||||||
|
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
||||||
|
|
||||||
|
private object Fixtures
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a captured payload from a module's `src/test/resources/fixtures`. The path is
|
||||||
|
* `<server>/<direction>/<packet id>/<name>.bin` and the name ends in the client version the capture
|
||||||
|
* came from, when that is known.
|
||||||
|
*/
|
||||||
|
fun fixture(path: String): ByteArray =
|
||||||
|
Fixtures.javaClass.getResourceAsStream("/fixtures/$path")?.readBytes()
|
||||||
|
?: error("no fixture at /fixtures/$path")
|
||||||
|
|
||||||
|
fun fixtureBuffer(path: String): ByteArrayReadBuffer = ByteArrayReadBuffer(fixture(path))
|
||||||
+2
-3
@@ -1,8 +1,9 @@
|
|||||||
package de.fiereu.bytecodec.test
|
package de.fiereu.openmmo.common.test
|
||||||
|
|
||||||
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
||||||
import de.fiereu.bytecodec.Codec
|
import de.fiereu.bytecodec.Codec
|
||||||
import de.fiereu.bytecodec.GrowableWriteBuffer
|
import de.fiereu.bytecodec.GrowableWriteBuffer
|
||||||
|
import de.fiereu.openmmo.common.utils.toHex
|
||||||
|
|
||||||
private fun contentEqual(a: Any?, b: Any?): Boolean =
|
private fun contentEqual(a: Any?, b: Any?): Boolean =
|
||||||
when {
|
when {
|
||||||
@@ -43,5 +44,3 @@ fun <T> Codec<T>.assertBytesRoundtrip(bytes: ByteArray) {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun ByteArray.toHex(): String = joinToString("") { "%02x".format(it.toInt() and 0xFF) }
|
|
||||||
@@ -9,6 +9,7 @@ dependencies {
|
|||||||
api(libs.netty)
|
api(libs.netty)
|
||||||
api(libs.kotlinx.coroutines)
|
api(libs.kotlinx.coroutines)
|
||||||
implementation(libs.kotlin.logging)
|
implementation(libs.kotlin.logging)
|
||||||
|
testImplementation(project(":common.test"))
|
||||||
testImplementation(libs.bundles.kotest)
|
testImplementation(libs.bundles.kotest)
|
||||||
testImplementation(libs.kotlinx.coroutines.test)
|
testImplementation(libs.kotlinx.coroutines.test)
|
||||||
testRuntimeOnly(libs.logback)
|
testRuntimeOnly(libs.logback)
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package de.fiereu.network.handshake
|
package de.fiereu.network.handshake
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.assertValueRoundtrip
|
import de.fiereu.openmmo.common.test.assertValueRoundtrip
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import java.security.interfaces.ECPublicKey
|
import java.security.interfaces.ECPublicKey
|
||||||
|
|||||||
@@ -7,5 +7,6 @@ plugins {
|
|||||||
dependencies {
|
dependencies {
|
||||||
api(project(":network"))
|
api(project(":network"))
|
||||||
api(project(":common"))
|
api(project(":common"))
|
||||||
|
testImplementation(project(":common.test"))
|
||||||
testImplementation(libs.bundles.kotest)
|
testImplementation(libs.bundles.kotest)
|
||||||
}
|
}
|
||||||
+7
-20
@@ -1,8 +1,9 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
|
||||||
import de.fiereu.openmmo.common.enums.BattleAction
|
import de.fiereu.openmmo.common.enums.BattleAction
|
||||||
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleActionSelectPacket
|
import de.fiereu.openmmo.net.game.packets.battle.BattleActionSelectPacket
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleActionSelectPacketCodec
|
import de.fiereu.openmmo.net.game.packets.battle.BattleActionSelectPacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
@@ -11,7 +12,7 @@ import io.kotest.matchers.shouldBe
|
|||||||
class BattleActionSelectPacketTest :
|
class BattleActionSelectPacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("decodes a captured move selection") {
|
test("decodes a captured move selection") {
|
||||||
val bytes = byteArrayOf(0x00, 0x00, 0x2B, 0x00, 0x00)
|
val bytes = fixture("game/c2s/32/move_selection.bin")
|
||||||
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe
|
decoded shouldBe
|
||||||
BattleActionSelectPacket(
|
BattleActionSelectPacket(
|
||||||
@@ -25,21 +26,7 @@ class BattleActionSelectPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("decodes a captured item throw") {
|
test("decodes a captured item throw") {
|
||||||
val bytes =
|
val bytes = fixture("game/c2s/32/item_throw.bin")
|
||||||
byteArrayOf(
|
|
||||||
0x00,
|
|
||||||
0x01,
|
|
||||||
0x8C.toByte(),
|
|
||||||
0x13,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0x00,
|
|
||||||
0xFF.toByte())
|
|
||||||
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe
|
decoded shouldBe
|
||||||
BattleActionSelectPacket(
|
BattleActionSelectPacket(
|
||||||
@@ -53,7 +40,7 @@ class BattleActionSelectPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("decodes a run selection with no tail") {
|
test("decodes a run selection with no tail") {
|
||||||
val bytes = byteArrayOf(0x00, 0x03)
|
val bytes = fixture("game/c2s/32/run.bin")
|
||||||
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe
|
decoded shouldBe
|
||||||
BattleActionSelectPacket(
|
BattleActionSelectPacket(
|
||||||
@@ -67,7 +54,7 @@ class BattleActionSelectPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("decodes a captured switch to a party index") {
|
test("decodes a captured switch to a party index") {
|
||||||
val bytes = byteArrayOf(0x00, 0x02, 0x01, 0x00)
|
val bytes = fixture("game/c2s/32/switch.bin")
|
||||||
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
val decoded = BattleActionSelectPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe
|
decoded shouldBe
|
||||||
BattleActionSelectPacket(
|
BattleActionSelectPacket(
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleActionEvent
|
import de.fiereu.openmmo.net.game.packets.battle.BattleActionEvent
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleEffectTarget
|
import de.fiereu.openmmo.net.game.packets.battle.BattleEffectTarget
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleEntityMoveEventPacket
|
import de.fiereu.openmmo.net.game.packets.battle.BattleEntityMoveEventPacket
|
||||||
|
|||||||
+5
-9
@@ -1,22 +1,18 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleFieldStatePacket
|
import de.fiereu.openmmo.net.game.packets.battle.BattleFieldStatePacket
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleFieldStatePacketCodec
|
import de.fiereu.openmmo.net.game.packets.battle.BattleFieldStatePacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleMonBlock
|
import de.fiereu.openmmo.net.game.packets.battle.BattleMonBlock
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import java.util.Base64
|
|
||||||
|
|
||||||
// A two-monster party wild encounter (Snivy active, Patrat benched), scrubbed of capture data.
|
|
||||||
private const val CAPTURED_TWO_PARTY =
|
|
||||||
"AgAAAAAAAAAAAAAAAP8AAAAAABYAAAD/ACAABlQAZQBzAHQAAAAAAJABAAAAAAD/AAJMAxqsDwADgAGkAAQAAAAAAAECAAABAMABAAAAAADvAQYAAAAAAAAWABYAAAAA/wMBQQAhACsAAAAAAAABAQDAAgAAAAAA+AECAAABAAAADgAOAAAAAP8DATIAIQAAAAAAAAABAADvAQYAAAAAAAAD/wAAAABmZmZmAQYAAAAAAAEBAAABAMADAAAAAAD4AQIAAAEAAAAOAA4AAAAA/wMAAQAA+AECAAAAAAEAA/8AAAAAZmZmZgAAAAA="
|
|
||||||
|
|
||||||
class BattleFieldStatePacketTest :
|
class BattleFieldStatePacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("round-trips a two-party wild field state byte for byte") {
|
test("round-trips a two-party wild field state byte for byte") {
|
||||||
val bytes = Base64.getDecoder().decode(CAPTURED_TWO_PARTY)
|
val bytes = fixture("game/s2c/30/wild_two_party_scrubbed.bin")
|
||||||
val decoded = BattleFieldStatePacketCodec.decodeBytes(bytes)
|
val decoded = BattleFieldStatePacketCodec.decodeBytes(bytes)
|
||||||
decoded.playerName shouldBe "Test"
|
decoded.playerName shouldBe "Test"
|
||||||
decoded.playerParty.size shouldBe 2
|
decoded.playerParty.size shouldBe 2
|
||||||
@@ -25,7 +21,7 @@ class BattleFieldStatePacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("decodes the structured mon fields from the capture") {
|
test("decodes the structured mon fields from the capture") {
|
||||||
val bytes = Base64.getDecoder().decode(CAPTURED_TWO_PARTY)
|
val bytes = fixture("game/s2c/30/wild_two_party_scrubbed.bin")
|
||||||
val decoded = BattleFieldStatePacketCodec.decodeBytes(bytes)
|
val decoded = BattleFieldStatePacketCodec.decodeBytes(bytes)
|
||||||
|
|
||||||
val snivy = decoded.playerParty[0]
|
val snivy = decoded.playerParty[0]
|
||||||
|
|||||||
+4
-3
@@ -1,7 +1,8 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.common.utils.toHex
|
import de.fiereu.openmmo.common.utils.toHex
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleMonBlock
|
import de.fiereu.openmmo.net.game.packets.battle.BattleMonBlock
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.BattleSwitchInPacket
|
import de.fiereu.openmmo.net.game.packets.battle.BattleSwitchInPacket
|
||||||
@@ -48,7 +49,7 @@ class BattleSwitchInPacketTest :
|
|||||||
fullBlock = false,
|
fullBlock = false,
|
||||||
)
|
)
|
||||||
val bytes = BattleSwitchInPacketCodec.encodeToBytes(packet)
|
val bytes = BattleSwitchInPacketCodec.encodeToBytes(packet)
|
||||||
bytes.toHex() shouldBe "000000010000ef010600000000000003ff0000000066666666"
|
bytes.toHex() shouldBe fixture("game/s2c/35/return_switch_in.bin").toHex()
|
||||||
}
|
}
|
||||||
|
|
||||||
// A benched monster coming out carries its full block then its active detail. The block
|
// A benched monster coming out carries its full block then its active detail. The block
|
||||||
|
|||||||
+4
-30
@@ -1,8 +1,7 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
|
||||||
import de.fiereu.bytecodec.U8
|
import de.fiereu.bytecodec.U8
|
||||||
import de.fiereu.openmmo.common.utils.hexToBytes
|
import de.fiereu.openmmo.common.test.fixtureBuffer
|
||||||
import de.fiereu.openmmo.net.game.codecs.CharacterInfoCodecShort
|
import de.fiereu.openmmo.net.game.codecs.CharacterInfoCodecShort
|
||||||
import de.fiereu.openmmo.net.game.codecs.DefaultSkinSetCodec
|
import de.fiereu.openmmo.net.game.codecs.DefaultSkinSetCodec
|
||||||
import de.fiereu.openmmo.net.game.codecs.PokemonCodec
|
import de.fiereu.openmmo.net.game.codecs.PokemonCodec
|
||||||
@@ -10,28 +9,10 @@ import de.fiereu.openmmo.net.game.codecs.SkinSetCodecNoLeading
|
|||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
|
|
||||||
/** A captured character list. Only the second character has a party, and the third one after it. */
|
|
||||||
private const val CAPTURED_LIST_32710 =
|
|
||||||
"03009008849CEFC41A4D0061006300680065007200520069006E0000000000DA02220101280A696A0C0A696A00000000" +
|
|
||||||
"001900000000000000000000000000200001000000000000000000FFFFFFFF0000000000000000000000000200040100" +
|
|
||||||
"06000600020000000000FF0000000000004C030BB80E0003180030029C00000000009088C41C56091861007300740072" +
|
|
||||||
"0069006400650066006F007500720000000000DA02220100EFCD646A36A69C670000000000B05303007C010000000000" +
|
|
||||||
"00000020005C005C030000028D0100028D01000000000000000000000002FF02028E010009000D00000100000000FF00" +
|
|
||||||
"00000000024C031AAC0F00038001A400040000000100C008522BEDAF1A0000009088C41C560918009088C41C56091801" +
|
|
||||||
"0000EF01BA707DDB009088C41C560918610073007400720069006400650066006F007500720000000000000007180000" +
|
|
||||||
"002801000000430021002B0016000000231E19000000000000000000000500000100000000000000040502FFFFFFFF03" +
|
|
||||||
"00EFBDF71E00000020000000000000008686536A0000FFFF00000090882BE6F6C01A4D00610063006800650072004400" +
|
|
||||||
"6500720000000000DA022201002CF9646AEFF8646A00000000003B0000000000000000000000000020003D0002000000" +
|
|
||||||
"0133000201330002000000000000000000000100020133010003000200020100000000FF0000000000034C031E280A00" +
|
|
||||||
"02540070002000000000"
|
|
||||||
|
|
||||||
class CharactersListPacketTest :
|
class CharactersListPacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("a captured client 32710 character list is consumed to the last byte") {
|
test("a captured client 32710 character list is consumed to the last byte") {
|
||||||
val bytes = CAPTURED_LIST_32710.hexToBytes()
|
val buf = fixtureBuffer("game/s2c/02/character_list_32710.bin")
|
||||||
bytes.size shouldBe 538
|
|
||||||
|
|
||||||
val buf = ByteArrayReadBuffer(bytes)
|
|
||||||
val names = mutableListOf<String>()
|
val names = mutableListOf<String>()
|
||||||
val parties = mutableListOf<Int>()
|
val parties = mutableListOf<Int>()
|
||||||
repeat(U8.read(buf)) {
|
repeat(U8.read(buf)) {
|
||||||
@@ -51,15 +32,8 @@ class CharactersListPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a captured client 32710 monster record is consumed to the last byte") {
|
test("a captured client 32710 monster record is consumed to the last byte") {
|
||||||
// One SocialListEntryAdd payload, which is a bare monster record.
|
// A SocialListEntryAdd payload, which is a bare monster record.
|
||||||
val bytes =
|
val buf = fixtureBuffer("game/s2c/14/monster_record_32710.bin")
|
||||||
("00C0885FCC11CB1A00000090484E2A11CB1A0090484E2A11CB1A0100000400184204670090484E2A11CB1A4D00610063" +
|
|
||||||
"006800520052000000000000000513000000870000000032000A002D0021003400232823190000000000000000000000" +
|
|
||||||
"000000000000000000580500FFFFFFFF0300EFBDF71E0000002000000000000000EB516F6A0000FFFF0000")
|
|
||||||
.hexToBytes()
|
|
||||||
bytes.size shouldBe 139
|
|
||||||
|
|
||||||
val buf = ByteArrayReadBuffer(bytes)
|
|
||||||
val mon = PokemonCodec.read(buf)
|
val mon = PokemonCodec.read(buf)
|
||||||
|
|
||||||
mon.dexId shouldBe 4
|
mon.dexId shouldBe 4
|
||||||
|
|||||||
+6
-10
@@ -1,9 +1,9 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
|
||||||
import de.fiereu.openmmo.common.enums.SkinSlot
|
import de.fiereu.openmmo.common.enums.SkinSlot
|
||||||
import de.fiereu.openmmo.common.utils.hexToBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.common.utils.toHex
|
import de.fiereu.openmmo.common.utils.toHex
|
||||||
import de.fiereu.openmmo.net.game.packets.CreateCharacterPacketCodec
|
import de.fiereu.openmmo.net.game.packets.CreateCharacterPacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
@@ -12,9 +12,7 @@ import io.kotest.matchers.shouldBe
|
|||||||
class CreateCharacterPacketTest :
|
class CreateCharacterPacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("decodes the captured female Hoenn character creation") {
|
test("decodes the captured female Hoenn character creation") {
|
||||||
val bytes =
|
val bytes = fixture("game/c2s/03/female_hoenn.bin")
|
||||||
"4c0061006e0061006e0061005400650073007400540077006f0000000101014c0304600f00030800680084"
|
|
||||||
.hexToBytes()
|
|
||||||
|
|
||||||
val packet = CreateCharacterPacketCodec.decodeBytes(bytes)
|
val packet = CreateCharacterPacketCodec.decodeBytes(bytes)
|
||||||
|
|
||||||
@@ -33,8 +31,7 @@ class CreateCharacterPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("roundtrips the new male Hoenn character creation capture") {
|
test("roundtrips the new male Hoenn character creation capture") {
|
||||||
val bytes =
|
val bytes = fixture("game/c2s/03/male_hoenn_32710.bin")
|
||||||
"4d006100630068006500720044006500720000000001034c031e280a00025400700020".hexToBytes()
|
|
||||||
|
|
||||||
val packet = CreateCharacterPacketCodec.decodeBytes(bytes)
|
val packet = CreateCharacterPacketCodec.decodeBytes(bytes)
|
||||||
|
|
||||||
@@ -46,8 +43,7 @@ class CreateCharacterPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("roundtrips the independent female Kanto character creation capture") {
|
test("roundtrips the independent female Kanto character creation capture") {
|
||||||
val bytes =
|
val bytes = fixture("game/c2s/03/female_kanto_32710.bin")
|
||||||
"4d0061006300680065007200520069006e0000000100004c030bb80e0003180030029c".hexToBytes()
|
|
||||||
|
|
||||||
val packet = CreateCharacterPacketCodec.decodeBytes(bytes)
|
val packet = CreateCharacterPacketCodec.decodeBytes(bytes)
|
||||||
|
|
||||||
|
|||||||
+14
-15
@@ -1,8 +1,8 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import de.fiereu.openmmo.common.utils.hexToBytes
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.common.utils.toHex
|
import de.fiereu.openmmo.common.utils.toHex
|
||||||
import de.fiereu.openmmo.net.game.packets.dialog.CreatureDataArg
|
import de.fiereu.openmmo.net.game.packets.dialog.CreatureDataArg
|
||||||
import de.fiereu.openmmo.net.game.packets.dialog.DialogActionPacketCodec
|
import de.fiereu.openmmo.net.game.packets.dialog.DialogActionPacketCodec
|
||||||
@@ -12,26 +12,25 @@ import io.kotest.matchers.shouldBe
|
|||||||
|
|
||||||
class DialogActionPacketTest :
|
class DialogActionPacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
// Every case is a real 0x21 dialog action from the NPC interaction capture.
|
|
||||||
val captures =
|
val captures =
|
||||||
listOf(
|
listOf(
|
||||||
"0c2e0d00b52903e008bf86c4c01ab004000000",
|
"flags_0c_type_2e",
|
||||||
"006400000000ffffffffffffffff0000000000",
|
"flags_00_type_64",
|
||||||
"0e04f90600010ae008bf86c4c01ab004000000",
|
"flags_0e_type_04",
|
||||||
"0d04f80600010ae008bf86c4c01ab004000001000992d00300",
|
"creature_arg",
|
||||||
|
"species_arg",
|
||||||
)
|
)
|
||||||
|
|
||||||
test("round-trips every captured dialog action byte for byte") {
|
test("round-trips every captured dialog action byte for byte") {
|
||||||
captures.forEach { hex ->
|
captures.forEach { name ->
|
||||||
val packet = DialogActionPacketCodec.decodeBytes(hex.hexToBytes())
|
val bytes = fixture("game/s2c/21/$name.bin")
|
||||||
DialogActionPacketCodec.encodeToBytes(packet).toHex() shouldBe hex
|
val packet = DialogActionPacketCodec.decodeBytes(bytes)
|
||||||
|
DialogActionPacketCodec.encodeToBytes(packet).toHex() shouldBe bytes.toHex()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
test("decodes the fields of a dialog action carrying a creature arg") {
|
test("decodes the fields of a dialog action carrying a creature arg") {
|
||||||
val packet =
|
val packet = DialogActionPacketCodec.decodeBytes(fixture("game/s2c/21/creature_arg.bin"))
|
||||||
DialogActionPacketCodec.decodeBytes(
|
|
||||||
"0d04f80600010ae008bf86c4c01ab004000001000992d00300".hexToBytes())
|
|
||||||
packet.flags shouldBe 0x0d.toByte()
|
packet.flags shouldBe 0x0d.toByte()
|
||||||
packet.actionType shouldBe 0x04.toByte()
|
packet.actionType shouldBe 0x04.toByte()
|
||||||
packet.textId shouldBe 0x010006f8
|
packet.textId shouldBe 0x010006f8
|
||||||
@@ -41,7 +40,7 @@ class DialogActionPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("species-name argument uses the captured party slot variable and species order") {
|
test("species-name argument uses the captured party slot variable and species order") {
|
||||||
val bytes = "000400000000ffffffffffffffff0000000001020101ff0000".hexToBytes()
|
val bytes = fixture("game/s2c/21/species_arg.bin")
|
||||||
val packet = DialogActionPacketCodec.decodeBytes(bytes)
|
val packet = DialogActionPacketCodec.decodeBytes(bytes)
|
||||||
|
|
||||||
packet.messageArgs shouldBe listOf(TextPokemonSpeciesArg(1, 1, 255))
|
packet.messageArgs shouldBe listOf(TextPokemonSpeciesArg(1, 1, 255))
|
||||||
|
|||||||
+5
-5
@@ -1,7 +1,8 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.net.game.packets.dialog.DialogActionResponsePacket
|
import de.fiereu.openmmo.net.game.packets.dialog.DialogActionResponsePacket
|
||||||
import de.fiereu.openmmo.net.game.packets.dialog.DialogActionResponsePacketCodec
|
import de.fiereu.openmmo.net.game.packets.dialog.DialogActionResponsePacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
@@ -9,10 +10,9 @@ import io.kotest.matchers.shouldBe
|
|||||||
|
|
||||||
class DialogActionResponsePacketTest :
|
class DialogActionResponsePacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
// The client replies to a 0x21 dialog action with the action id and a response byte. This is
|
// The client replies to a 0x21 dialog action with the action id and a response byte.
|
||||||
// the "0c 00" the capture sends back after the "0c" dialog action.
|
|
||||||
test("round-trips the captured dialog reply") {
|
test("round-trips the captured dialog reply") {
|
||||||
val bytes = byteArrayOf(0x0c, 0x00)
|
val bytes = fixture("game/c2s/21/dialog_reply.bin")
|
||||||
val packet = DialogActionResponsePacketCodec.decodeBytes(bytes)
|
val packet = DialogActionResponsePacketCodec.decodeBytes(bytes)
|
||||||
packet shouldBe DialogActionResponsePacket(id = 0x0c, unk = 0)
|
packet shouldBe DialogActionResponsePacket(id = 0x0c, unk = 0)
|
||||||
DialogActionResponsePacketCodec.encodeToBytes(packet) shouldBe bytes
|
DialogActionResponsePacketCodec.encodeToBytes(packet) shouldBe bytes
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
|
||||||
|
|
||||||
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
|
||||||
|
|
||||||
private object Fixtures
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Reads a captured payload from `src/test/resources/fixtures`. The path is
|
|
||||||
* `<server>/<direction>/<packet id>/<name>.bin` and the name ends in the client version the capture
|
|
||||||
* came from.
|
|
||||||
*/
|
|
||||||
fun fixture(path: String): ByteArrayReadBuffer =
|
|
||||||
ByteArrayReadBuffer(
|
|
||||||
Fixtures.javaClass.getResourceAsStream("/fixtures/$path")?.readBytes()
|
|
||||||
?: error("no fixture at /fixtures/$path"))
|
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import de.fiereu.openmmo.net.game.packets.FriendListEntry
|
import de.fiereu.openmmo.net.game.packets.FriendListEntry
|
||||||
import de.fiereu.openmmo.net.game.packets.FriendListPacket
|
import de.fiereu.openmmo.net.game.packets.FriendListPacket
|
||||||
import de.fiereu.openmmo.net.game.packets.FriendListPacketCodec
|
import de.fiereu.openmmo.net.game.packets.FriendListPacketCodec
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
|
||||||
import de.fiereu.openmmo.common.enums.Direction
|
import de.fiereu.openmmo.common.enums.Direction
|
||||||
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import de.fiereu.openmmo.net.game.packets.DialogStatePacket
|
import de.fiereu.openmmo.net.game.packets.DialogStatePacket
|
||||||
import de.fiereu.openmmo.net.game.packets.DialogStatePacketCodec
|
import de.fiereu.openmmo.net.game.packets.DialogStatePacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.EntityLeavePacket
|
import de.fiereu.openmmo.net.game.packets.EntityLeavePacket
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
|
import de.fiereu.openmmo.common.test.fixtureBuffer
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlListKind
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlListKind
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlListingsPagePacketCodec
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlListingsPagePacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlListingsPageRequestPacketCodec
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlListingsPageRequestPacketCodec
|
||||||
@@ -9,7 +10,7 @@ import io.kotest.matchers.shouldBe
|
|||||||
class GtlListingsPagePacketTest :
|
class GtlListingsPagePacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("a captured price list request round trips") {
|
test("a captured price list request round trips") {
|
||||||
val buf = fixture("game/c2s/e4/price_list_request_31914.bin")
|
val buf = fixtureBuffer("game/c2s/e4/price_list_request_31914.bin")
|
||||||
val request = GtlListingsPageRequestPacketCodec.read(buf)
|
val request = GtlListingsPageRequestPacketCodec.read(buf)
|
||||||
|
|
||||||
request.requestId shouldBe 3.toByte()
|
request.requestId shouldBe 3.toByte()
|
||||||
@@ -20,7 +21,7 @@ class GtlListingsPagePacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a captured price list page is consumed to the last byte") {
|
test("a captured price list page is consumed to the last byte") {
|
||||||
val buf = fixture("game/s2c/fe/price_history_32710.bin")
|
val buf = fixtureBuffer("game/s2c/fe/price_history_32710.bin")
|
||||||
val page = GtlListingsPagePacketCodec.read(buf)
|
val page = GtlListingsPagePacketCodec.read(buf)
|
||||||
|
|
||||||
page.requestId shouldBe 1.toByte()
|
page.requestId shouldBe 1.toByte()
|
||||||
@@ -35,7 +36,7 @@ class GtlListingsPagePacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a later price list page reports which page it answers") {
|
test("a later price list page reports which page it answers") {
|
||||||
val buf = fixture("game/s2c/fe/price_history_page2_31914.bin")
|
val buf = fixtureBuffer("game/s2c/fe/price_history_page2_31914.bin")
|
||||||
val page = GtlListingsPagePacketCodec.read(buf)
|
val page = GtlListingsPagePacketCodec.read(buf)
|
||||||
|
|
||||||
page.requestId shouldBe 3.toByte()
|
page.requestId shouldBe 3.toByte()
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
||||||
|
import de.fiereu.openmmo.common.test.fixtureBuffer
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlMarketListingsPacketCodec
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlMarketListingsPacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlMarketListingsRequestPacketCodec
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlMarketListingsRequestPacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
@@ -15,7 +16,7 @@ class GtlMarketListingsPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a captured board page is consumed to the last byte") {
|
test("a captured board page is consumed to the last byte") {
|
||||||
val buf = fixture("game/s2c/70/board_page_31914.bin")
|
val buf = fixtureBuffer("game/s2c/70/board_page_31914.bin")
|
||||||
val board = GtlMarketListingsPacketCodec.read(buf)
|
val board = GtlMarketListingsPacketCodec.read(buf)
|
||||||
|
|
||||||
board.fullReset shouldBe false
|
board.fullReset shouldBe false
|
||||||
|
|||||||
+4
-7
@@ -1,7 +1,6 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
import de.fiereu.openmmo.common.test.fixtureBuffer
|
||||||
import de.fiereu.openmmo.common.utils.hexToBytes
|
|
||||||
import de.fiereu.openmmo.net.game.packets.CategoryFlagsPacketCodec
|
import de.fiereu.openmmo.net.game.packets.CategoryFlagsPacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlOpenSessionPacketCodec
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlOpenSessionPacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
@@ -10,21 +9,19 @@ import io.kotest.matchers.shouldBe
|
|||||||
class GtlOpenSessionPacketTest :
|
class GtlOpenSessionPacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("the first open carries no timestamp") {
|
test("the first open carries no timestamp") {
|
||||||
val buf = fixture("game/c2s/a5/open_session_first_31914.bin")
|
val buf = fixtureBuffer("game/c2s/a5/open_session_first_31914.bin")
|
||||||
GtlOpenSessionPacketCodec.read(buf).sessionTimestamp shouldBe 0L
|
GtlOpenSessionPacketCodec.read(buf).sessionTimestamp shouldBe 0L
|
||||||
buf.remaining() shouldBe 0
|
buf.remaining() shouldBe 0
|
||||||
}
|
}
|
||||||
|
|
||||||
test("the next open echoes the timestamp the server just sent") {
|
test("the next open echoes the timestamp the server just sent") {
|
||||||
// The flag bytes are opaque, so only the header comes from the capture.
|
val flagBuf = fixtureBuffer("game/s2c/dc/category_flags_31914.bin")
|
||||||
val flagBytes = ("01" + "85C2F6559E010000" + "3603" + "00".repeat(822)).hexToBytes()
|
|
||||||
val flagBuf = ByteArrayReadBuffer(flagBytes)
|
|
||||||
val flags = CategoryFlagsPacketCodec.read(flagBuf)
|
val flags = CategoryFlagsPacketCodec.read(flagBuf)
|
||||||
flags.entryKind shouldBe 1
|
flags.entryKind shouldBe 1
|
||||||
flags.flagBits.size shouldBe 822
|
flags.flagBits.size shouldBe 822
|
||||||
flagBuf.remaining() shouldBe 0
|
flagBuf.remaining() shouldBe 0
|
||||||
|
|
||||||
val reopen = fixture("game/c2s/a5/open_session_reopen_31914.bin")
|
val reopen = fixtureBuffer("game/c2s/a5/open_session_reopen_31914.bin")
|
||||||
GtlOpenSessionPacketCodec.read(reopen).sessionTimestamp shouldBe flags.timestampMillis
|
GtlOpenSessionPacketCodec.read(reopen).sessionTimestamp shouldBe flags.timestampMillis
|
||||||
reopen.remaining() shouldBe 0
|
reopen.remaining() shouldBe 0
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-3
@@ -1,5 +1,6 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
|
import de.fiereu.openmmo.common.test.fixtureBuffer
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlItemListing
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlItemListing
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlListKind
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlListKind
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlPokemonListing
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlPokemonListing
|
||||||
@@ -10,7 +11,7 @@ import io.kotest.matchers.shouldBe
|
|||||||
class GtlSearchPagePacketTest :
|
class GtlSearchPagePacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("a captured item page is consumed to the last byte") {
|
test("a captured item page is consumed to the last byte") {
|
||||||
val buf = fixture("game/s2c/9b/item_page_32710.bin")
|
val buf = fixtureBuffer("game/s2c/9b/item_page_32710.bin")
|
||||||
val page = GtlSearchPagePacketCodec.read(buf)
|
val page = GtlSearchPagePacketCodec.read(buf)
|
||||||
|
|
||||||
page.requestId shouldBe 7.toByte()
|
page.requestId shouldBe 7.toByte()
|
||||||
@@ -30,7 +31,7 @@ class GtlSearchPagePacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a captured monster page is consumed to the last byte") {
|
test("a captured monster page is consumed to the last byte") {
|
||||||
val buf = fixture("game/s2c/9b/monster_page_32710.bin")
|
val buf = fixtureBuffer("game/s2c/9b/monster_page_32710.bin")
|
||||||
val page = GtlSearchPagePacketCodec.read(buf)
|
val page = GtlSearchPagePacketCodec.read(buf)
|
||||||
|
|
||||||
page.requestId shouldBe 1.toByte()
|
page.requestId shouldBe 1.toByte()
|
||||||
@@ -53,7 +54,7 @@ class GtlSearchPagePacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a page that is not an item board carries no quote strip") {
|
test("a page that is not an item board carries no quote strip") {
|
||||||
val buf = fixture("game/s2c/9b/own_listings_page_31914.bin")
|
val buf = fixtureBuffer("game/s2c/9b/own_listings_page_31914.bin")
|
||||||
val page = GtlSearchPagePacketCodec.read(buf)
|
val page = GtlSearchPagePacketCodec.read(buf)
|
||||||
|
|
||||||
page.listKind shouldBe GtlListKind.OWN_LISTINGS
|
page.listKind shouldBe GtlListKind.OWN_LISTINGS
|
||||||
|
|||||||
+5
-4
@@ -1,5 +1,6 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
|
import de.fiereu.openmmo.common.test.fixtureBuffer
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlFilterKind
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlFilterKind
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlListKind
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlListKind
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlSearchPageRequestPacketCodec
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlSearchPageRequestPacketCodec
|
||||||
@@ -10,7 +11,7 @@ import io.kotest.matchers.shouldBe
|
|||||||
class GtlSearchPageRequestPacketTest :
|
class GtlSearchPageRequestPacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("an unfiltered search carries no filters") {
|
test("an unfiltered search carries no filters") {
|
||||||
val buf = fixture("game/c2s/9b/own_listings_request_31914.bin")
|
val buf = fixtureBuffer("game/c2s/9b/own_listings_request_31914.bin")
|
||||||
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
||||||
|
|
||||||
request.requestId shouldBe 3.toByte()
|
request.requestId shouldBe 3.toByte()
|
||||||
@@ -22,7 +23,7 @@ class GtlSearchPageRequestPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a search filtered to one species carries its dex id") {
|
test("a search filtered to one species carries its dex id") {
|
||||||
val buf = fixture("game/c2s/9b/one_species_filter_32710.bin")
|
val buf = fixtureBuffer("game/c2s/9b/one_species_filter_32710.bin")
|
||||||
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
||||||
|
|
||||||
request.requestId shouldBe 4.toByte()
|
request.requestId shouldBe 4.toByte()
|
||||||
@@ -31,7 +32,7 @@ class GtlSearchPageRequestPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a search filtered to thirteen species carries all of them") {
|
test("a search filtered to thirteen species carries all of them") {
|
||||||
val buf = fixture("game/c2s/9b/thirteen_species_filter_32710.bin")
|
val buf = fixtureBuffer("game/c2s/9b/thirteen_species_filter_32710.bin")
|
||||||
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
||||||
|
|
||||||
request.listKind shouldBe GtlListKind.ITEM
|
request.listKind shouldBe GtlListKind.ITEM
|
||||||
@@ -42,7 +43,7 @@ class GtlSearchPageRequestPacketTest :
|
|||||||
}
|
}
|
||||||
|
|
||||||
test("a filtered search carries one entry per filter") {
|
test("a filtered search carries one entry per filter") {
|
||||||
val buf = fixture("game/c2s/9b/eleven_filters_32710.bin")
|
val buf = fixtureBuffer("game/c2s/9b/eleven_filters_32710.bin")
|
||||||
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
val request = GtlSearchPageRequestPacketCodec.read(buf)
|
||||||
|
|
||||||
request.filters.size shouldBe 11
|
request.filters.size shouldBe 11
|
||||||
|
|||||||
+2
-1
@@ -1,6 +1,7 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
import de.fiereu.bytecodec.ByteArrayReadBuffer
|
||||||
|
import de.fiereu.openmmo.common.test.fixtureBuffer
|
||||||
import de.fiereu.openmmo.net.game.packets.SceneObjectStatesPacketCodec
|
import de.fiereu.openmmo.net.game.packets.SceneObjectStatesPacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.gtl.GtlTradeLogRequestPacketCodec
|
import de.fiereu.openmmo.net.game.packets.gtl.GtlTradeLogRequestPacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
@@ -13,7 +14,7 @@ class GtlTradeLogRequestPacketTest :
|
|||||||
GtlTradeLogRequestPacketCodec.read(request)
|
GtlTradeLogRequestPacketCodec.read(request)
|
||||||
request.remaining() shouldBe 0
|
request.remaining() shouldBe 0
|
||||||
|
|
||||||
val reply = fixture("game/s2c/5e/empty_trade_log_31914.bin")
|
val reply = fixtureBuffer("game/s2c/5e/empty_trade_log_31914.bin")
|
||||||
SceneObjectStatesPacketCodec.read(reply).objects shouldBe emptyList()
|
SceneObjectStatesPacketCodec.read(reply).objects shouldBe emptyList()
|
||||||
reply.remaining() shouldBe 0
|
reply.remaining() shouldBe 0
|
||||||
}
|
}
|
||||||
|
|||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import de.fiereu.openmmo.net.game.packets.guild.GuildMembershipPacket
|
import de.fiereu.openmmo.net.game.packets.guild.GuildMembershipPacket
|
||||||
import de.fiereu.openmmo.net.game.packets.guild.GuildMembershipPacketCodec
|
import de.fiereu.openmmo.net.game.packets.guild.GuildMembershipPacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.guild.GuildProfileData
|
import de.fiereu.openmmo.net.game.packets.guild.GuildProfileData
|
||||||
|
|||||||
+2
-2
@@ -1,9 +1,9 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
|
||||||
import de.fiereu.openmmo.common.enums.GuildPermission
|
import de.fiereu.openmmo.common.enums.GuildPermission
|
||||||
import de.fiereu.openmmo.common.enums.GuildRank
|
import de.fiereu.openmmo.common.enums.GuildRank
|
||||||
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import de.fiereu.openmmo.net.game.packets.guild.GuildRankPermissionUpdatePacket
|
import de.fiereu.openmmo.net.game.packets.guild.GuildRankPermissionUpdatePacket
|
||||||
import de.fiereu.openmmo.net.game.packets.guild.GuildRankPermissionUpdatePacketCodec
|
import de.fiereu.openmmo.net.game.packets.guild.GuildRankPermissionUpdatePacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
|
|||||||
@@ -1,7 +1,8 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.moves.MoveLearnPromptPacket
|
import de.fiereu.openmmo.net.game.packets.battle.moves.MoveLearnPromptPacket
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.moves.MoveLearnPromptPacketCodec
|
import de.fiereu.openmmo.net.game.packets.battle.moves.MoveLearnPromptPacketCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.battle.moves.MoveLearnReplyPacket
|
import de.fiereu.openmmo.net.game.packets.battle.moves.MoveLearnReplyPacket
|
||||||
@@ -16,21 +17,17 @@ private const val WATER_GUN: Short = 55
|
|||||||
private const val LEER: Short = 43
|
private const val LEER: Short = 43
|
||||||
private const val UNOVA_MOVE: Short = 526
|
private const val UNOVA_MOVE: Short = 526
|
||||||
|
|
||||||
private fun entityIdBytes() =
|
|
||||||
byteArrayOf(
|
|
||||||
0x00, 0xC0.toByte(), 0xC8.toByte(), 0x2A, 0xEF.toByte(), 0xAD.toByte(), 0xCE.toByte(), 0x1A)
|
|
||||||
|
|
||||||
class MoveLearnPacketsTest :
|
class MoveLearnPacketsTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("decodes a captured prompt for one move") {
|
test("decodes a captured prompt for one move") {
|
||||||
val bytes = entityIdBytes() + byteArrayOf(0x01, 0x9A.toByte(), 0x00)
|
val bytes = fixture("game/s2c/17/prompt_one_move_32710.bin")
|
||||||
val decoded = MoveLearnPromptPacketCodec.decodeBytes(bytes)
|
val decoded = MoveLearnPromptPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe MoveLearnPromptPacket(ENTITY_ID, listOf(FURY_SWIPES))
|
decoded shouldBe MoveLearnPromptPacket(ENTITY_ID, listOf(FURY_SWIPES))
|
||||||
MoveLearnPromptPacketCodec.encodeToBytes(decoded) shouldBe bytes
|
MoveLearnPromptPacketCodec.encodeToBytes(decoded) shouldBe bytes
|
||||||
}
|
}
|
||||||
|
|
||||||
test("decodes a captured prompt for two moves") {
|
test("decodes a captured prompt for two moves") {
|
||||||
val bytes = entityIdBytes() + byteArrayOf(0x02, 0x18, 0x02, 0x59, 0x01)
|
val bytes = fixture("game/s2c/17/prompt_two_moves_32710.bin")
|
||||||
val decoded = MoveLearnPromptPacketCodec.decodeBytes(bytes)
|
val decoded = MoveLearnPromptPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe MoveLearnPromptPacket(ENTITY_ID, listOf(536, 345))
|
decoded shouldBe MoveLearnPromptPacket(ENTITY_ID, listOf(536, 345))
|
||||||
MoveLearnPromptPacketCodec.encodeToBytes(decoded) shouldBe bytes
|
MoveLearnPromptPacketCodec.encodeToBytes(decoded) shouldBe bytes
|
||||||
@@ -38,21 +35,7 @@ class MoveLearnPacketsTest :
|
|||||||
|
|
||||||
// Fury Swipes took the slot Leer held.
|
// Fury Swipes took the slot Leer held.
|
||||||
test("decodes a captured reply that swapped a move in") {
|
test("decodes a captured reply that swapped a move in") {
|
||||||
val bytes =
|
val bytes = fixture("game/c2s/0a/reply_swapped_32710.bin")
|
||||||
entityIdBytes() +
|
|
||||||
byteArrayOf(
|
|
||||||
0x04,
|
|
||||||
0x0E,
|
|
||||||
0x02,
|
|
||||||
0x9A.toByte(),
|
|
||||||
0x00,
|
|
||||||
0x7A,
|
|
||||||
0x00,
|
|
||||||
0x37,
|
|
||||||
0x00,
|
|
||||||
0x01,
|
|
||||||
0x9A.toByte(),
|
|
||||||
0x00)
|
|
||||||
val decoded = MoveLearnReplyPacketCodec.decodeBytes(bytes)
|
val decoded = MoveLearnReplyPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe
|
decoded shouldBe
|
||||||
MoveLearnReplyPacket(
|
MoveLearnReplyPacket(
|
||||||
@@ -65,10 +48,7 @@ class MoveLearnPacketsTest :
|
|||||||
|
|
||||||
// The moveset comes back as it was, so the player kept Leer.
|
// The moveset comes back as it was, so the player kept Leer.
|
||||||
test("decodes a captured reply that declined") {
|
test("decodes a captured reply that declined") {
|
||||||
val bytes =
|
val bytes = fixture("game/c2s/0a/reply_declined_32710.bin")
|
||||||
entityIdBytes() +
|
|
||||||
byteArrayOf(
|
|
||||||
0x04, 0x0E, 0x02, 0x2B, 0x00, 0x7A, 0x00, 0x37, 0x00, 0x01, 0x9A.toByte(), 0x00)
|
|
||||||
val decoded = MoveLearnReplyPacketCodec.decodeBytes(bytes)
|
val decoded = MoveLearnReplyPacketCodec.decodeBytes(bytes)
|
||||||
decoded shouldBe
|
decoded shouldBe
|
||||||
MoveLearnReplyPacket(
|
MoveLearnReplyPacket(
|
||||||
|
|||||||
+5
-8
@@ -1,19 +1,19 @@
|
|||||||
package de.fiereu.openmmo.net.game
|
package de.fiereu.openmmo.net.game
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
|
||||||
import de.fiereu.openmmo.common.Pokemon
|
import de.fiereu.openmmo.common.Pokemon
|
||||||
import de.fiereu.openmmo.common.PokemonMove
|
import de.fiereu.openmmo.common.PokemonMove
|
||||||
import de.fiereu.openmmo.common.enums.EVs
|
import de.fiereu.openmmo.common.enums.EVs
|
||||||
import de.fiereu.openmmo.common.enums.IVs
|
import de.fiereu.openmmo.common.enums.IVs
|
||||||
import de.fiereu.openmmo.common.enums.PokemonContainer
|
import de.fiereu.openmmo.common.enums.PokemonContainer
|
||||||
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
|
import de.fiereu.openmmo.common.test.fixture
|
||||||
import de.fiereu.openmmo.net.game.codecs.PokemonCodec
|
import de.fiereu.openmmo.net.game.codecs.PokemonCodec
|
||||||
import de.fiereu.openmmo.net.game.packets.PokemonContainerPacket
|
import de.fiereu.openmmo.net.game.packets.PokemonContainerPacket
|
||||||
import de.fiereu.openmmo.net.game.packets.PokemonContainerPacketCodec
|
import de.fiereu.openmmo.net.game.packets.PokemonContainerPacketCodec
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
import java.util.Base64
|
|
||||||
|
|
||||||
private fun testMon(id: Long, dex: Int, slot: Short) =
|
private fun testMon(id: Long, dex: Int, slot: Short) =
|
||||||
Pokemon(
|
Pokemon(
|
||||||
@@ -40,13 +40,10 @@ private fun testMon(id: Long, dex: Int, slot: Short) =
|
|||||||
caughtAt = LocalDateTime.of(2026, 1, 1, 0, 0, 0),
|
caughtAt = LocalDateTime.of(2026, 1, 1, 0, 0, 0),
|
||||||
)
|
)
|
||||||
|
|
||||||
private const val CAPTURED_PARTY =
|
|
||||||
"AQEBAMABAAAAAAAAAACQAQAAAAAAAJABAAAAAAABAADvAbpwfdsAkAEAAAAAAFQAZQBzAHQAAAAAAAAABRQAAAClAAAAADIAIQArAAAAAAAjHgAAAAAAAAAAAAAAAAAAAQAAAAAAAAAEBQL/////AwDvvfceAAAAIAAAAAAAAACGhlNqAAD//wAA"
|
|
||||||
|
|
||||||
class PokemonContainerPacketTest :
|
class PokemonContainerPacketTest :
|
||||||
FunSpec({
|
FunSpec({
|
||||||
test("round-trips a captured party container and exposes the monster fields") {
|
test("round-trips a captured party container and exposes the monster fields") {
|
||||||
val bytes = Base64.getDecoder().decode(CAPTURED_PARTY)
|
val bytes = bytes()
|
||||||
val decoded = PokemonContainerPacketCodec.decodeBytes(bytes)
|
val decoded = PokemonContainerPacketCodec.decodeBytes(bytes)
|
||||||
val mon = decoded.pokemon.single()
|
val mon = decoded.pokemon.single()
|
||||||
mon.dexId shouldBe 495
|
mon.dexId shouldBe 495
|
||||||
@@ -125,4 +122,4 @@ class PokemonContainerPacketTest :
|
|||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
private fun bytes(): ByteArray = Base64.getDecoder().decode(CAPTURED_PARTY)
|
private fun bytes(): ByteArray = fixture("game/s2c/13/party_scrubbed.bin")
|
||||||
+2
-2
@@ -1,8 +1,8 @@
|
|||||||
package de.fiereu.openmmo.net.game.codecs
|
package de.fiereu.openmmo.net.game.codecs
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
|
||||||
import de.fiereu.openmmo.common.CharacterInfo
|
import de.fiereu.openmmo.common.CharacterInfo
|
||||||
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
import java.time.LocalDateTime
|
import java.time.LocalDateTime
|
||||||
|
|||||||
@@ -4,11 +4,16 @@ Raw packet payloads from real captures, one file per packet.
|
|||||||
|
|
||||||
<server>/<direction>/<packet id>/<name>_<client version>.bin
|
<server>/<direction>/<packet id>/<name>_<client version>.bin
|
||||||
|
|
||||||
Packet id is lowercase hex without a prefix. The version matters: the wire format changes between
|
Packet id is lowercase hex without a prefix. The version matters, the wire format changes between
|
||||||
clients.
|
clients, so carry it whenever the capture can be traced back to a session. A few older payloads
|
||||||
|
predate that rule and have no suffix. `_scrubbed` means player data was replaced before the payload
|
||||||
|
was committed, so it no longer matches anything in the archive.
|
||||||
|
|
||||||
|
`fixture` gives you the bytes, `fixtureBuffer` wraps them for a codec that reads from a buffer. Both
|
||||||
|
live in the `common.test` module.
|
||||||
|
|
||||||
```kotlin
|
```kotlin
|
||||||
val buf = fixture("game/s2c/9b/monster_page_32710.bin")
|
val buf = fixtureBuffer("game/s2c/9b/monster_page_32710.bin")
|
||||||
GtlSearchPagePacketCodec.read(buf)
|
GtlSearchPagePacketCodec.read(buf)
|
||||||
buf.remaining() shouldBe 0
|
buf.remaining() shouldBe 0
|
||||||
```
|
```
|
||||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -8,5 +8,6 @@ dependencies {
|
|||||||
api(project(":network"))
|
api(project(":network"))
|
||||||
api(project(":common"))
|
api(project(":common"))
|
||||||
api(libs.ineter)
|
api(libs.ineter)
|
||||||
|
testImplementation(project(":common.test"))
|
||||||
testImplementation(libs.bundles.kotest)
|
testImplementation(libs.bundles.kotest)
|
||||||
}
|
}
|
||||||
+2
-2
@@ -1,7 +1,7 @@
|
|||||||
package de.fiereu.openmmo.net.login
|
package de.fiereu.openmmo.net.login
|
||||||
|
|
||||||
import de.fiereu.bytecodec.test.decodeBytes
|
import de.fiereu.openmmo.common.test.decodeBytes
|
||||||
import de.fiereu.bytecodec.test.encodeToBytes
|
import de.fiereu.openmmo.common.test.encodeToBytes
|
||||||
import de.fiereu.openmmo.net.login.packets.JoinGameServerPacket
|
import de.fiereu.openmmo.net.login.packets.JoinGameServerPacket
|
||||||
import de.fiereu.openmmo.net.login.packets.JoinGameServerPacketCodec
|
import de.fiereu.openmmo.net.login.packets.JoinGameServerPacketCodec
|
||||||
import de.fiereu.openmmo.net.login.packets.MfaResponsePacket
|
import de.fiereu.openmmo.net.login.packets.MfaResponsePacket
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ dependencies {
|
|||||||
implementation(libs.logback)
|
implementation(libs.logback)
|
||||||
implementation(libs.kotlinx.serialization.json)
|
implementation(libs.kotlinx.serialization.json)
|
||||||
|
|
||||||
|
testImplementation(project(":common.test"))
|
||||||
testImplementation(libs.bundles.kotest)
|
testImplementation(libs.bundles.kotest)
|
||||||
testImplementation(libs.kotlinx.coroutines.test)
|
testImplementation(libs.kotlinx.coroutines.test)
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -8,9 +8,9 @@ import de.fiereu.openmmo.common.enums.Direction
|
|||||||
import de.fiereu.openmmo.common.enums.EVs
|
import de.fiereu.openmmo.common.enums.EVs
|
||||||
import de.fiereu.openmmo.common.enums.IVs
|
import de.fiereu.openmmo.common.enums.IVs
|
||||||
import de.fiereu.openmmo.common.enums.PokemonContainer
|
import de.fiereu.openmmo.common.enums.PokemonContainer
|
||||||
|
import de.fiereu.openmmo.common.test.DockerAvailable
|
||||||
import de.fiereu.openmmo.db.game.tables.references.CHARACTER_ITEMS
|
import de.fiereu.openmmo.db.game.tables.references.CHARACTER_ITEMS
|
||||||
import de.fiereu.openmmo.db.game.tables.references.POKEMON
|
import de.fiereu.openmmo.db.game.tables.references.POKEMON
|
||||||
import de.fiereu.openmmo.server.game.testsupport.DockerAvailable
|
|
||||||
import io.kotest.assertions.throwables.shouldThrowAny
|
import io.kotest.assertions.throwables.shouldThrowAny
|
||||||
import io.kotest.core.annotation.EnabledIf
|
import io.kotest.core.annotation.EnabledIf
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
|
|||||||
@@ -25,6 +25,7 @@ dependencies {
|
|||||||
implementation(libs.kotlin.logging)
|
implementation(libs.kotlin.logging)
|
||||||
implementation(libs.logback)
|
implementation(libs.logback)
|
||||||
|
|
||||||
|
testImplementation(project(":common.test"))
|
||||||
testImplementation(libs.bundles.kotest)
|
testImplementation(libs.bundles.kotest)
|
||||||
testImplementation(libs.kotlinx.coroutines.test)
|
testImplementation(libs.kotlinx.coroutines.test)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
package de.fiereu.openmmo.server.login.auth
|
package de.fiereu.openmmo.server.login.auth
|
||||||
|
|
||||||
import de.fiereu.openmmo.common.enums.LoginState
|
import de.fiereu.openmmo.common.enums.LoginState
|
||||||
import de.fiereu.openmmo.server.login.testsupport.DockerAvailable
|
import de.fiereu.openmmo.common.test.DockerAvailable
|
||||||
import io.kotest.core.annotation.EnabledIf
|
import io.kotest.core.annotation.EnabledIf
|
||||||
import io.kotest.core.spec.style.FunSpec
|
import io.kotest.core.spec.style.FunSpec
|
||||||
import io.kotest.matchers.shouldBe
|
import io.kotest.matchers.shouldBe
|
||||||
|
|||||||
-12
@@ -1,12 +0,0 @@
|
|||||||
package de.fiereu.openmmo.server.login.testsupport
|
|
||||||
|
|
||||||
import io.kotest.core.annotation.Condition
|
|
||||||
import io.kotest.core.spec.Spec
|
|
||||||
import kotlin.reflect.KClass
|
|
||||||
import org.testcontainers.DockerClientFactory
|
|
||||||
|
|
||||||
/** Gates Testcontainers specs so machines without Docker skip them instead of failing. */
|
|
||||||
class DockerAvailable : Condition {
|
|
||||||
override fun evaluate(kclass: KClass<out Spec>): Boolean =
|
|
||||||
runCatching { DockerClientFactory.instance().isDockerAvailable() }.getOrDefault(false)
|
|
||||||
}
|
|
||||||
@@ -15,6 +15,7 @@ include(":keys")
|
|||||||
include(":patcher")
|
include(":patcher")
|
||||||
include(":common")
|
include(":common")
|
||||||
include(":bytecodec")
|
include(":bytecodec")
|
||||||
|
include(":common.test")
|
||||||
include(":network")
|
include(":network")
|
||||||
include(":protocols.login")
|
include(":protocols.login")
|
||||||
include(":protocols.game")
|
include(":protocols.game")
|
||||||
|
|||||||
Reference in new issue
Block a user