mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-25 23:09:08 +00:00
initial packet work and tests for: DataChallengeMessage, DataChallengeMessageResp, SimDataChallenge, and SimDataChallengeResp
This commit is contained in:
parent
181fdb9c84
commit
111fa1b574
10 changed files with 245 additions and 4 deletions
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class DataChallengeMessageRespTest extends Specification {
|
||||
val string = hex"948673616d706c6501000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case DataChallengeMessageResp(attribute, value) =>
|
||||
attribute mustEqual "sample"
|
||||
value mustEqual 1L
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = DataChallengeMessageResp("sample", 1L)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
28
common/src/test/scala/game/DataChallengeMessageTest.scala
Normal file
28
common/src/test/scala/game/DataChallengeMessageTest.scala
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class DataChallengeMessageTest extends Specification {
|
||||
val string = hex"938673616d706c6501000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case DataChallengeMessage(attribute, value) =>
|
||||
attribute mustEqual "sample"
|
||||
value mustEqual 1L
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = DataChallengeMessage("sample", 1L)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
33
common/src/test/scala/game/SimDataChallengeRespTest.scala
Normal file
33
common/src/test/scala/game/SimDataChallengeRespTest.scala
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class SimDataChallengeRespTest extends Specification {
|
||||
val string = hex"97050067030000e9030000e1040000000100006502000005003b3388faa52df48fb27971e7c3a9d0c109d5b03f00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case SimDataChallengeResp(u1, u2, u3) =>
|
||||
u1 mustEqual List(871L, 1001L, 1249L, 256L, 613L)
|
||||
u2 mustEqual List(4203230011L, 2415144357L, 3882973618L, 3251677635L, 1068553481L)
|
||||
u3 mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = SimDataChallengeResp(
|
||||
List(871L, 1001L, 1249L, 256L, 613L),
|
||||
List(4203230011L, 2415144357L, 3882973618L, 3251677635L, 1068553481L),
|
||||
false
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
31
common/src/test/scala/game/SimDataChallengeTest.scala
Normal file
31
common/src/test/scala/game/SimDataChallengeTest.scala
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
// Copyright (c) 2020 PSForever
|
||||
package game
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.game._
|
||||
import scodec.bits._
|
||||
|
||||
class SimDataChallengeTest extends Specification {
|
||||
val string = hex"96050067030000e9030000e10400000001000065020000808000000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case SimDataChallenge(u1, u2, u3, u4, u5) =>
|
||||
u1 mustEqual List(871L, 1001L, 1249L, 256L, 613L)
|
||||
u2 mustEqual true
|
||||
u3 mustEqual 1
|
||||
u4 mustEqual 0L
|
||||
u5 mustEqual false
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val msg = SimDataChallenge(List(871L, 1001L, 1249L, 256L, 613L), true, 1, 0, false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue