mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-02-20 23:23:35 +00:00
RelatedA0 and RelatedB0 have been superceded by RelatedA and RelatedB, respectively, with slots 0-3 for each; SlottedMetaAck has been removed and tests have been changed
This commit is contained in:
parent
adb7738268
commit
68e3377d2e
10 changed files with 211 additions and 131 deletions
|
|
@ -3,24 +3,80 @@ package control
|
|||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.control._
|
||||
import net.psforever.packet.control.RelatedA
|
||||
import scodec.bits._
|
||||
|
||||
class RelatedATest extends Specification {
|
||||
val string0 = hex"00 11 01 04"
|
||||
val string1 = hex"00 12 01 04"
|
||||
val string2 = hex"00 13 01 04"
|
||||
val string3 = hex"00 14 01 04"
|
||||
|
||||
"decode (0)" in {
|
||||
PacketCoding.DecodePacket(string0).require match {
|
||||
case RelatedA0(slot) =>
|
||||
slot mustEqual 260
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 0
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (1)" in {
|
||||
PacketCoding.DecodePacket(string1).require match {
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 1
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (2)" in {
|
||||
PacketCoding.DecodePacket(string2).require match {
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 2
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (3)" in {
|
||||
PacketCoding.DecodePacket(string3).require match {
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 3
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (0)" in {
|
||||
val pkt = RelatedA0(260)
|
||||
val pkt = RelatedA(0, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string0
|
||||
}
|
||||
|
||||
"encode (1)" in {
|
||||
val pkt = RelatedA(1, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string1
|
||||
}
|
||||
|
||||
"encode (2)" in {
|
||||
val pkt = RelatedA(2, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string2
|
||||
}
|
||||
|
||||
"encode (3)" in {
|
||||
val pkt = RelatedA(3, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string3
|
||||
}
|
||||
|
||||
"encode (n)" in {
|
||||
RelatedA(4, 260) must throwA[IllegalArgumentException]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,24 +3,80 @@ package control
|
|||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.control._
|
||||
import net.psforever.packet.control.RelatedB
|
||||
import scodec.bits._
|
||||
|
||||
class RelatedBTest extends Specification {
|
||||
val string0 = hex"00 15 01 04"
|
||||
val string1 = hex"00 16 01 04"
|
||||
val string2 = hex"00 17 01 04"
|
||||
val string3 = hex"00 18 01 04"
|
||||
|
||||
"decode (0)" in {
|
||||
PacketCoding.DecodePacket(string0).require match {
|
||||
case RelatedB0(slot) =>
|
||||
slot mustEqual 260
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 0
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (1)" in {
|
||||
PacketCoding.DecodePacket(string1).require match {
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 1
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (2)" in {
|
||||
PacketCoding.DecodePacket(string2).require match {
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 2
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"decode (3)" in {
|
||||
PacketCoding.DecodePacket(string3).require match {
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 3
|
||||
subslot mustEqual 260
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode (0)" in {
|
||||
val pkt = RelatedB0(260)
|
||||
val pkt = RelatedB(0, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string0
|
||||
}
|
||||
|
||||
"encode (1)" in {
|
||||
val pkt = RelatedB(1, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string1
|
||||
}
|
||||
|
||||
"encode (2)" in {
|
||||
val pkt = RelatedB(2, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string2
|
||||
}
|
||||
|
||||
"encode (3)" in {
|
||||
val pkt = RelatedB(3, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string3
|
||||
}
|
||||
|
||||
"encode (n)" in {
|
||||
RelatedB(4, 260) must throwA[IllegalArgumentException]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,29 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package control
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.control._
|
||||
import scodec.bits._
|
||||
|
||||
class SlottedMetaAckTest extends Specification {
|
||||
val string = hex"00150da4"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case SlottedMetaAck(_, _) =>
|
||||
ko
|
||||
case RelatedB0(subslot) => //important!
|
||||
subslot mustEqual 3492
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
val pkt = SlottedMetaAck(0, 3492)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
|
||||
msg mustEqual string
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue