mirror of
https://github.com/2revoemag/PSF-BotServer.git
synced 2026-03-18 11:30:38 +00:00
Networking
The game uses a UDP-based protocol. Unlike TCP, UDP does not guarantee that packets arrive, or that they arrive in the correct order. For this reason, the game protocol implements those features using the following: * All packets have a sequence number that is utilized for reordering * Important packets are wrapped in a SlottedMetaPacket with a subslot number * RelatedA packets ae used to request lost packets using the subslot number * RelatedB packets are used to confirm received SlottedMetaPackets All of these go both ways, server <-> client. We used to only partially implement these features: Outgoing packet bundles used SMPs and could be resent, but not all packets were bundled and there was no logic for requesting lost packets from the client and there was no packet reordering, which resulted in dire consequences in the case of packet loss (zoning failures, crashes and many other odd bugs). This patch addresses all of these issues. * Packet bundling: Packets are now automatically bundled and sent as SlottedMetaPackets using a recurring timer. All manual bundling functionality was removed. * Packet reordering: Incoming packets, if received out of order, are stashed and reordered. The maximum wait time for reordering is 20ms. * Packet requesting: Missing SlottedMetaPackets are requested from the client. * PacketCoding refactor: Dropped confusing packet container types. Fixes #5. * Crypto rewrite: PSCrypto is based on a ancient buggy version of cryptopp. Updating to a current version was not possible because it removed the MD5-MAC algorithm. For more details, see Md5Mac.scala. This patch replaces PSCrypto with native Scala code. * Added two new actors: * SocketActor: A simple typed UDP socket actor * MiddlewareActor: The old session pipeline greatly simplified into a typed actor that does most of the things mentioned above. * Begun work on a headless client * Fixed anniversary gun breaking stamina regen * Resolved a few sentry errors
This commit is contained in:
parent
5827204b10
commit
407429ee21
232 changed files with 2906 additions and 4385 deletions
|
|
@ -1,136 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.crypto.CryptoInterface
|
||||
import net.psforever.crypto.CryptoInterface.CryptoDHState
|
||||
import scodec.bits._
|
||||
|
||||
class CryptoInterfaceTest extends Specification {
|
||||
args(stopOnFail = true)
|
||||
"Crypto interface" should {
|
||||
"correctly initialize" in {
|
||||
CryptoInterface.initialize()
|
||||
ok
|
||||
}
|
||||
|
||||
"encrypt and decrypt" in {
|
||||
val key = hex"41414141"
|
||||
val plaintext = ByteVector.fill(16)(0x42)
|
||||
|
||||
val crypto = new CryptoInterface.CryptoState(key, key)
|
||||
|
||||
val ciphertext = crypto.encrypt(plaintext)
|
||||
val decrypted = crypto.decrypt(ciphertext)
|
||||
|
||||
crypto.close
|
||||
decrypted mustEqual plaintext
|
||||
ciphertext mustNotEqual plaintext
|
||||
}
|
||||
|
||||
"encrypt and decrypt must handle no bytes" in {
|
||||
val key = hex"41414141"
|
||||
val empty = ByteVector.empty
|
||||
|
||||
val crypto = new CryptoInterface.CryptoState(key, key)
|
||||
|
||||
val ciphertext = crypto.encrypt(empty)
|
||||
val decrypted = crypto.decrypt(ciphertext)
|
||||
|
||||
crypto.close
|
||||
|
||||
ciphertext mustEqual empty
|
||||
decrypted mustEqual empty
|
||||
}
|
||||
|
||||
"encrypt and decrypt must only accept block aligned inputs" in {
|
||||
val key = hex"41414141"
|
||||
val badPad = ByteVector.fill(CryptoInterface.RC5_BLOCK_SIZE - 1)('a')
|
||||
|
||||
val crypto = new CryptoInterface.CryptoState(key, key)
|
||||
|
||||
crypto.encrypt(badPad) must throwA[IllegalArgumentException]
|
||||
crypto.decrypt(badPad) must throwA[IllegalArgumentException]
|
||||
|
||||
crypto.close
|
||||
ok
|
||||
}
|
||||
|
||||
"arrive at a shared secret" in {
|
||||
val server = new CryptoInterface.CryptoDHState()
|
||||
val client = new CryptoInterface.CryptoDHState()
|
||||
|
||||
// 1. Client generates p, g, and its key pair
|
||||
client.start()
|
||||
|
||||
// 2. Client sends p and g to server who then generates a key pair as well
|
||||
server.start(client.getModulus, client.getGenerator)
|
||||
|
||||
// 3. Both parties come to a shared secret
|
||||
val clientAgreed = client.agree(server.getPublicKey)
|
||||
val serverAgreed = server.agree(client.getPublicKey)
|
||||
|
||||
// Free resources
|
||||
server.close
|
||||
client.close
|
||||
|
||||
clientAgreed mustEqual serverAgreed
|
||||
}
|
||||
|
||||
"must fail to agree on a secret with a bad public key" in {
|
||||
val server = new CryptoInterface.CryptoDHState()
|
||||
val client = new CryptoInterface.CryptoDHState()
|
||||
|
||||
// 1. Client generates p, g, and its key pair
|
||||
client.start()
|
||||
|
||||
// 2. Client sends p and g to server who then generates a key pair as well
|
||||
server.start(client.getModulus, client.getGenerator)
|
||||
|
||||
// 3. Client agrees with a bad public key, so it must fail
|
||||
val clientAgreed = client.agree(client.getPublicKey)
|
||||
val serverAgreed = server.agree(client.getPublicKey)
|
||||
|
||||
// Free resources
|
||||
server.close
|
||||
client.close
|
||||
|
||||
clientAgreed mustNotEqual serverAgreed
|
||||
}
|
||||
|
||||
"MD5MAC correctly" in {
|
||||
val key = hex"377b60f8790f91b35a9da82945743da9"
|
||||
val message = ByteVector(Array[Byte]('m', 'a', 's', 't', 'e', 'r', ' ', 's', 'e', 'c', 'r', 'e', 't')) ++
|
||||
hex"b4aea1559444a20b6112a2892de40eac00000000c8aea155b53d187076b79abab59001b600000000"
|
||||
val expected = hex"5aa15de41f5220cf5cca489155e1438c5aa15de4"
|
||||
|
||||
val output = CryptoInterface.MD5MAC(key, message, expected.length.toInt)
|
||||
|
||||
output mustEqual expected
|
||||
}
|
||||
|
||||
"safely handle multiple starts" in {
|
||||
val dontCare = ByteVector.fill(16)(0x42)
|
||||
val dh = new CryptoDHState()
|
||||
|
||||
dh.start()
|
||||
dh.start() must throwA[IllegalStateException]
|
||||
dh.close
|
||||
|
||||
ok
|
||||
}
|
||||
|
||||
"prevent function calls before initialization" in {
|
||||
val dontCare = ByteVector.fill(16)(0x42)
|
||||
val dh = new CryptoDHState()
|
||||
|
||||
dh.getGenerator must throwA[IllegalStateException]
|
||||
dh.getModulus must throwA[IllegalStateException]
|
||||
dh.getPrivateKey must throwA[IllegalStateException]
|
||||
dh.getPublicKey must throwA[IllegalStateException]
|
||||
dh.agree(dontCare) must throwA[IllegalStateException]
|
||||
dh.close
|
||||
|
||||
ok
|
||||
}
|
||||
}
|
||||
}
|
||||
106
src/test/scala/CryptoTest.scala
Normal file
106
src/test/scala/CryptoTest.scala
Normal file
|
|
@ -0,0 +1,106 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
|
||||
import java.security.{SecureRandom, Security}
|
||||
|
||||
import javax.crypto.spec.SecretKeySpec
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet.PacketCoding
|
||||
import net.psforever.packet.PacketCoding.CryptoCoding
|
||||
import net.psforever.packet.control.{HandleGamePacket, SlottedMetaPacket}
|
||||
import net.psforever.packet.game.PlanetsideAttributeMessage
|
||||
import net.psforever.types.PlanetSideGUID
|
||||
import net.psforever.util.{DiffieHellman, Md5Mac}
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider
|
||||
import scodec.Attempt.Failure
|
||||
import scodec.Err
|
||||
import scodec.bits._
|
||||
|
||||
class CryptoTest extends Specification {
|
||||
Security.addProvider(new BouncyCastleProvider)
|
||||
|
||||
args(stopOnFail = true)
|
||||
"Crypto" should {
|
||||
"encrypt and decrypt" in {
|
||||
val key = hex"41414141414141414141414141414141"
|
||||
val keySpec = new SecretKeySpec(key.take(20).toArray, "RC5")
|
||||
val plaintext = ByteVector.fill(32)(0x42)
|
||||
|
||||
val crypto = CryptoCoding(keySpec, keySpec, key, key)
|
||||
|
||||
val ciphertext = crypto.encrypt(plaintext).require
|
||||
val decrypted = crypto.decrypt(ciphertext).require
|
||||
|
||||
decrypted mustEqual plaintext
|
||||
ciphertext mustNotEqual plaintext
|
||||
|
||||
}
|
||||
|
||||
"encrypt and decrypt must only accept block aligned inputs" in {
|
||||
val key = hex"41414141414141414141414141414141"
|
||||
val keySpec = new SecretKeySpec(key.take(20).toArray, "RC5")
|
||||
val badPad = ByteVector.fill(PacketCoding.RC5_BLOCK_SIZE - 1)('a')
|
||||
|
||||
val crypto = CryptoCoding(keySpec, keySpec, key, key)
|
||||
|
||||
//crypto.encrypt(badPad) must throwA[javax.crypto.IllegalBlockSizeException]
|
||||
crypto.decrypt(badPad) mustEqual Failure(Err("data not block size aligned"))
|
||||
}
|
||||
|
||||
"encrypt and decrypt packet" in {
|
||||
val key = hex"41414141414141414141414141414141"
|
||||
val keySpec = new SecretKeySpec(key.take(20).toArray, "RC5")
|
||||
val crypto = CryptoCoding(keySpec, keySpec, key, key)
|
||||
|
||||
val packet =
|
||||
SlottedMetaPacket(
|
||||
0,
|
||||
5,
|
||||
PacketCoding
|
||||
.encodePacket(
|
||||
HandleGamePacket(
|
||||
PacketCoding.encodePacket(PlanetsideAttributeMessage(PlanetSideGUID(0), 0, 0L)).require.toByteVector
|
||||
)
|
||||
)
|
||||
.require
|
||||
.bytes
|
||||
)
|
||||
|
||||
val encrypted = PacketCoding.marshalPacket(packet, Some(10), Some(crypto)).require
|
||||
println(s"encrypted ${encrypted}")
|
||||
val (decryptedPacket, sequence) = PacketCoding.unmarshalPacket(encrypted.bytes, Some(crypto)).require
|
||||
|
||||
decryptedPacket mustEqual packet
|
||||
sequence must beSome(10)
|
||||
}
|
||||
|
||||
"MD5MAC" in {
|
||||
val key = hex"377b60f8790f91b35a9da82945743da9"
|
||||
val message = ByteVector(Array[Byte]('m', 'a', 's', 't', 'e', 'r', ' ', 's', 'e', 'c', 'r', 'e', 't')) ++
|
||||
hex"b4aea1559444a20b6112a2892de40eac00000000c8aea155b53d187076b79abab59001b600000000"
|
||||
val message2 = ByteVector.view((0 until 64).map(_.toByte).toArray)
|
||||
val expected = hex"5aa15de41f5220cf5cca489155e1438c5aa15de4"
|
||||
|
||||
val mac = new Md5Mac(key)
|
||||
mac.update(message)
|
||||
mac.doFinal(20) mustEqual expected
|
||||
|
||||
val mac2 = new Md5Mac(key)
|
||||
mac2.update(message2)
|
||||
mac.update(message2)
|
||||
mac.doFinal() mustEqual mac2.doFinal()
|
||||
|
||||
(0 to 20).map(_ => mac.updateFinal(message, 20) mustEqual expected)
|
||||
}
|
||||
|
||||
"DH" in {
|
||||
val p = BigInt(128, new SecureRandom()).toByteArray
|
||||
val g = Array(1.toByte)
|
||||
|
||||
val bob = new DiffieHellman(p, g)
|
||||
val alice = new DiffieHellman(p, g)
|
||||
|
||||
bob.agree(alice.publicKey) mustEqual alice.agree(bob.publicKey)
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
@ -1,6 +1,6 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet._
|
||||
import net.psforever.packet.{PlanetSideControlPacket, _}
|
||||
import net.psforever.packet.control.{ClientStart, ServerStart}
|
||||
import scodec.bits._
|
||||
|
||||
|
|
@ -18,13 +18,13 @@ class PacketCodingTest extends Specification {
|
|||
|
||||
"Packet coding" should {
|
||||
"correctly decode control packets" in {
|
||||
val packet = PacketCoding.UnmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
|
||||
val (packet, _) = PacketCoding.unmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
|
||||
|
||||
packet.isInstanceOf[ControlPacket] mustEqual true
|
||||
packet.isInstanceOf[PlanetSideControlPacket] mustEqual true
|
||||
|
||||
val controlPacket = packet.asInstanceOf[ControlPacket]
|
||||
val controlPacket = packet.asInstanceOf[PlanetSideControlPacket]
|
||||
controlPacket.opcode mustEqual ControlPacketOpcode.ClientStart
|
||||
controlPacket.packet mustEqual ClientStart(656287232)
|
||||
controlPacket mustEqual ClientStart(656287232)
|
||||
}
|
||||
|
||||
"encode and decode to identical packets" in {
|
||||
|
|
@ -32,37 +32,37 @@ class PacketCodingTest extends Specification {
|
|||
val serverNonce = 848483
|
||||
|
||||
val packetUnderTest = ServerStart(clientNonce, serverNonce)
|
||||
val pkt = PacketCoding.MarshalPacket(ControlPacket(packetUnderTest.opcode, packetUnderTest)).require
|
||||
val pkt = PacketCoding.marshalPacket(packetUnderTest).require
|
||||
|
||||
val decoded = PacketCoding.UnmarshalPacket(pkt.toByteVector).require.asInstanceOf[ControlPacket]
|
||||
val recvPkt = decoded.packet.asInstanceOf[ServerStart]
|
||||
val decoded = PacketCoding.unmarshalPacket(pkt.toByteVector).require._1.asInstanceOf[PlanetSideControlPacket]
|
||||
val recvPkt = decoded.asInstanceOf[ServerStart]
|
||||
|
||||
packetUnderTest mustEqual recvPkt
|
||||
}
|
||||
|
||||
"reject corrupted control packets" in {
|
||||
val packet = PacketCoding.UnmarshalPacket(hex"0001 00001002 00261e27 004101f0")
|
||||
val packet = PacketCoding.unmarshalPacket(hex"0001 00001002 00261e27 004101f0")
|
||||
|
||||
packet.isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"correctly decode crypto packets" in {
|
||||
val packet = PacketCoding.UnmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
|
||||
val (packet, _) = PacketCoding.unmarshalPacket(hex"0001 00000002 00261e27 000001f0").require
|
||||
|
||||
packet.isInstanceOf[ControlPacket] mustEqual true
|
||||
packet.isInstanceOf[PlanetSideControlPacket] mustEqual true
|
||||
|
||||
val controlPacket = packet.asInstanceOf[ControlPacket]
|
||||
val controlPacket = packet.asInstanceOf[PlanetSideControlPacket]
|
||||
controlPacket.opcode mustEqual ControlPacketOpcode.ClientStart
|
||||
controlPacket.packet mustEqual ClientStart(656287232)
|
||||
controlPacket mustEqual ClientStart(656287232)
|
||||
}
|
||||
|
||||
"reject bad packet types" in {
|
||||
PacketCoding.UnmarshalPacket(hex"ff414141").isFailure mustEqual true
|
||||
PacketCoding.unmarshalPacket(hex"ff414141").isFailure mustEqual true
|
||||
}
|
||||
|
||||
"reject small packets" in {
|
||||
PacketCoding.UnmarshalPacket(hex"00").isFailure mustEqual true
|
||||
PacketCoding.UnmarshalPacket(hex"").isFailure mustEqual true
|
||||
PacketCoding.unmarshalPacket(hex"00").isFailure mustEqual true
|
||||
PacketCoding.unmarshalPacket(hex"").isFailure mustEqual true
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ClientStartTest extends Specification {
|
|||
val string = hex"0001 00000002 00261e27 000001f0"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ClientStart(nonce) =>
|
||||
nonce mustEqual 656287232
|
||||
case _ =>
|
||||
|
|
@ -20,7 +20,7 @@ class ClientStartTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ClientStart(656287232)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ConnectionCloseTest extends Specification {
|
|||
val string = hex"001D"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ConnectionClose() =>
|
||||
ok
|
||||
case _ =>
|
||||
|
|
@ -20,7 +20,7 @@ class ConnectionCloseTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ConnectionClose()
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ControlSyncRespTest extends Specification {
|
|||
val string = hex"0008 5268 21392D92 0000000000000276 0000000000000275 0000000000000275 0000000000000276"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ControlSyncResp(a, b, c, d, e, f) =>
|
||||
a mustEqual 21096
|
||||
|
||||
|
|
@ -25,7 +25,7 @@ class ControlSyncRespTest extends Specification {
|
|||
}
|
||||
|
||||
"encode" in {
|
||||
val encoded = PacketCoding.EncodePacket(ControlSyncResp(21096, 0x21392d92, 0x276, 0x275, 0x275, 0x276)).require
|
||||
val encoded = PacketCoding.encodePacket(ControlSyncResp(21096, 0x21392d92, 0x276, 0x275, 0x275, 0x276)).require
|
||||
|
||||
encoded.toByteVector mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ControlSyncTest extends Specification {
|
|||
val string = hex"0007 5268 0000004D 00000052 0000004D 0000007C 0000004D 0000000000000276 0000000000000275"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ControlSync(a, b, c, d, e, f, g, h) =>
|
||||
a mustEqual 21096
|
||||
b mustEqual 0x4d
|
||||
|
|
@ -26,7 +26,7 @@ class ControlSyncTest extends Specification {
|
|||
}
|
||||
|
||||
"encode" in {
|
||||
val encoded = PacketCoding.EncodePacket(ControlSync(21096, 0x4d, 0x52, 0x4d, 0x7c, 0x4d, 0x276, 0x275)).require
|
||||
val encoded = PacketCoding.encodePacket(ControlSync(21096, 0x4d, 0x52, 0x4d, 0x7c, 0x4d, 0x276, 0x275)).require
|
||||
encoded.toByteVector mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class HandleGamePacketTest extends Specification {
|
|||
val string = hex"00 00 01 CB" ++ base
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case HandleGamePacket(len, data, extra) =>
|
||||
len mustEqual 459
|
||||
data mustEqual base
|
||||
|
|
@ -25,7 +25,7 @@ class HandleGamePacketTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val pkt = HandleGamePacket(base)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
val msg = PacketCoding.encodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,199 +0,0 @@
|
|||
// Copyright (c) 2017 PSForever
|
||||
package control
|
||||
|
||||
import org.specs2.mutable._
|
||||
import net.psforever.packet.control.{ControlSync, MultiPacketBundle, MultiPacketCollector}
|
||||
import net.psforever.packet.crypto.{ClientFinished, ServerFinished}
|
||||
import net.psforever.packet.game.ObjectDeleteMessage
|
||||
import net.psforever.types.PlanetSideGUID
|
||||
|
||||
class MultiPacketCollectorTest extends Specification {
|
||||
val packet1 = ObjectDeleteMessage(PlanetSideGUID(1103), 2)
|
||||
|
||||
"MultiPacketBundle" should {
|
||||
import scodec.bits._
|
||||
val packet2 = ControlSync(21096, 0x4d, 0x52, 0x4d, 0x7c, 0x4d, 0x276, 0x275)
|
||||
|
||||
"construct" in {
|
||||
MultiPacketBundle(List(packet1))
|
||||
ok
|
||||
}
|
||||
|
||||
"fail to construct if not initialized with PlanetSidePackets" in {
|
||||
MultiPacketBundle(Nil) must throwA[IllegalArgumentException]
|
||||
}
|
||||
|
||||
"concatenate bundles into a new bundle" in {
|
||||
val obj1 = MultiPacketBundle(List(packet1))
|
||||
val obj2 = MultiPacketBundle(List(packet2))
|
||||
val obj3 = obj1 + obj2
|
||||
obj3 match {
|
||||
case MultiPacketBundle(list) =>
|
||||
list.size mustEqual 2
|
||||
list.head mustEqual packet1
|
||||
list(1) mustEqual packet2
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"accept PlanetSideGamePackets and PlanetSideControlPackets" in {
|
||||
MultiPacketBundle(List(packet2, packet1)) match {
|
||||
case MultiPacketBundle(list) =>
|
||||
list.size mustEqual 2
|
||||
list.head mustEqual packet2
|
||||
list(1) mustEqual packet1
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"ignore other types of PlanetSideContainerPackets" in {
|
||||
val param = List(packet2, ClientFinished(hex"", hex""), packet1, ServerFinished(hex""))
|
||||
MultiPacketBundle(param) match { //warning message will display in log
|
||||
case MultiPacketBundle(list) =>
|
||||
list.size mustEqual 2
|
||||
list.head mustEqual param.head
|
||||
list(1) mustEqual param(2)
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
"MultiPacketCollector" should {
|
||||
val packet2 = ObjectDeleteMessage(PlanetSideGUID(1105), 2)
|
||||
val packet3 = ObjectDeleteMessage(PlanetSideGUID(1107), 2)
|
||||
|
||||
"construct" in {
|
||||
new MultiPacketCollector()
|
||||
ok
|
||||
}
|
||||
|
||||
"construct with initial packets" in {
|
||||
MultiPacketCollector(List(packet1, packet2))
|
||||
ok
|
||||
}
|
||||
|
||||
"can retrieve a bundle packets" in {
|
||||
val obj = MultiPacketCollector(List(packet1, packet2))
|
||||
obj.Bundle match {
|
||||
case Some(MultiPacketBundle(list)) =>
|
||||
list.size mustEqual 2
|
||||
list.head mustEqual packet1
|
||||
list(1) mustEqual packet2
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"can retrieve a bundle of potential packets" in {
|
||||
val obj1 = new MultiPacketCollector()
|
||||
obj1.Bundle match {
|
||||
case Some(_) =>
|
||||
ko
|
||||
case _ => ;
|
||||
}
|
||||
|
||||
val obj2 = MultiPacketCollector(List(packet1, packet2))
|
||||
obj2.Bundle match {
|
||||
case None =>
|
||||
ko
|
||||
case Some(MultiPacketBundle(list)) =>
|
||||
list.size mustEqual 2
|
||||
list.head mustEqual packet1
|
||||
list(1) mustEqual packet2
|
||||
}
|
||||
}
|
||||
|
||||
"clear packets after being asked to bundle" in {
|
||||
val list = List(packet1, packet2)
|
||||
val obj = MultiPacketCollector(list)
|
||||
|
||||
obj.Bundle match {
|
||||
case Some(MultiPacketBundle(bundle)) =>
|
||||
bundle mustEqual list
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
obj.Bundle match {
|
||||
case Some(MultiPacketBundle(_)) =>
|
||||
ko
|
||||
case _ =>
|
||||
ok
|
||||
}
|
||||
}
|
||||
|
||||
"add a packet" in {
|
||||
val obj = new MultiPacketCollector()
|
||||
obj.Add(packet1)
|
||||
obj.Bundle match {
|
||||
case Some(MultiPacketBundle(list)) =>
|
||||
list.size mustEqual 1
|
||||
list.head mustEqual packet1
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"add packets" in {
|
||||
val obj = new MultiPacketCollector()
|
||||
obj.Add(List(packet1, packet2))
|
||||
obj.Bundle match {
|
||||
case Some(MultiPacketBundle(list)) =>
|
||||
list.size mustEqual 2
|
||||
list.head mustEqual packet1
|
||||
list(1) mustEqual packet2
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
}
|
||||
|
||||
"concatenate bundles (1)" in {
|
||||
|
||||
val obj1 = new MultiPacketCollector()
|
||||
obj1.Add(List(packet1, packet2))
|
||||
obj1.Bundle match {
|
||||
case Some(MultiPacketBundle(bundle1)) =>
|
||||
val obj2 = MultiPacketCollector(bundle1)
|
||||
obj2.Add(packet3)
|
||||
obj2.Bundle match {
|
||||
case Some(MultiPacketBundle(list)) =>
|
||||
list.size mustEqual 3
|
||||
list.head mustEqual packet1
|
||||
list(1) mustEqual packet2
|
||||
list(2) mustEqual packet3
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
"concatenate bundles (2)" in {
|
||||
val obj1 = new MultiPacketCollector()
|
||||
obj1.Add(List(packet1, packet2))
|
||||
obj1.Bundle match {
|
||||
case Some(MultiPacketBundle(bundle1)) =>
|
||||
val obj2 = new MultiPacketCollector()
|
||||
obj2.Add(packet3)
|
||||
obj2.Add(bundle1)
|
||||
obj2.Bundle match {
|
||||
case Some(MultiPacketBundle(list)) =>
|
||||
list.size mustEqual 3
|
||||
list.head mustEqual packet3
|
||||
list(1) mustEqual packet1
|
||||
list(2) mustEqual packet2
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
case _ =>
|
||||
ko
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -11,7 +11,7 @@ class MultiPacketTest extends Specification {
|
|||
hex"00 03 04 00 15 13 23 3A 00 09 03 E3 00 19 16 6D 56 05 68 05 40 A0 EF 45 00 15 0E 44 00 A0 A2 41 00 00 0F 88 00 06 E4 C0 60 00 00 00 15 E4 32 40 74 72 61 69 6E 69 6E 67 5F 77 65 61 70 6F 6E 73 30 31 13 BD 68 05 53 F6 EF 90 D1 6E 03 14 FE 78 8C 20 1C C0 00 00 1F 00 09 03 E4 6D 56 05 68 05 40 A0 EF 45 00 15 0E 44 30 89 A1 41 00 00 0F 8A 01 00 04 18 EF 80"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case MultiPacket(data) =>
|
||||
data.size mustEqual 4
|
||||
data(0) mustEqual hex"00151323"
|
||||
|
|
@ -34,7 +34,7 @@ class MultiPacketTest extends Specification {
|
|||
hex"000903e46d5605680540a0ef4500150e443089a14100000f8a01000418ef80"
|
||||
)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class RelatedATest extends Specification {
|
|||
val string3 = hex"00 14 01 04"
|
||||
|
||||
"decode (0)" in {
|
||||
PacketCoding.DecodePacket(string0).require match {
|
||||
PacketCoding.decodePacket(string0).require match {
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 0
|
||||
subslot mustEqual 260
|
||||
|
|
@ -23,7 +23,7 @@ class RelatedATest extends Specification {
|
|||
}
|
||||
|
||||
"decode (1)" in {
|
||||
PacketCoding.DecodePacket(string1).require match {
|
||||
PacketCoding.decodePacket(string1).require match {
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 1
|
||||
subslot mustEqual 260
|
||||
|
|
@ -33,7 +33,7 @@ class RelatedATest extends Specification {
|
|||
}
|
||||
|
||||
"decode (2)" in {
|
||||
PacketCoding.DecodePacket(string2).require match {
|
||||
PacketCoding.decodePacket(string2).require match {
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 2
|
||||
subslot mustEqual 260
|
||||
|
|
@ -43,7 +43,7 @@ class RelatedATest extends Specification {
|
|||
}
|
||||
|
||||
"decode (3)" in {
|
||||
PacketCoding.DecodePacket(string3).require match {
|
||||
PacketCoding.decodePacket(string3).require match {
|
||||
case RelatedA(slot, subslot) =>
|
||||
slot mustEqual 3
|
||||
subslot mustEqual 260
|
||||
|
|
@ -54,25 +54,25 @@ class RelatedATest extends Specification {
|
|||
|
||||
"encode (0)" in {
|
||||
val pkt = RelatedA(0, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
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
|
||||
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
|
||||
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
|
||||
val msg = PacketCoding.encodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string3
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class RelatedBTest extends Specification {
|
|||
val string3 = hex"00 18 01 04"
|
||||
|
||||
"decode (0)" in {
|
||||
PacketCoding.DecodePacket(string0).require match {
|
||||
PacketCoding.decodePacket(string0).require match {
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 0
|
||||
subslot mustEqual 260
|
||||
|
|
@ -23,7 +23,7 @@ class RelatedBTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (1)" in {
|
||||
PacketCoding.DecodePacket(string1).require match {
|
||||
PacketCoding.decodePacket(string1).require match {
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 1
|
||||
subslot mustEqual 260
|
||||
|
|
@ -33,7 +33,7 @@ class RelatedBTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (2)" in {
|
||||
PacketCoding.DecodePacket(string2).require match {
|
||||
PacketCoding.decodePacket(string2).require match {
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 2
|
||||
subslot mustEqual 260
|
||||
|
|
@ -43,7 +43,7 @@ class RelatedBTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (3)" in {
|
||||
PacketCoding.DecodePacket(string3).require match {
|
||||
PacketCoding.decodePacket(string3).require match {
|
||||
case RelatedB(slot, subslot) =>
|
||||
slot mustEqual 3
|
||||
subslot mustEqual 260
|
||||
|
|
@ -54,25 +54,25 @@ class RelatedBTest extends Specification {
|
|||
|
||||
"encode (0)" in {
|
||||
val pkt = RelatedB(0, 260)
|
||||
val msg = PacketCoding.EncodePacket(pkt).require.toByteVector
|
||||
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
|
||||
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
|
||||
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
|
||||
val msg = PacketCoding.encodePacket(pkt).require.toByteVector
|
||||
msg mustEqual string3
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -29,7 +29,7 @@ class SlottedMetaPacketTest extends Specification {
|
|||
.toByteVector ++ uint16.encode(subslot).require.toByteVector ++ rest
|
||||
|
||||
"decode as the base slot and subslot" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case SlottedMetaPacket(slot, subslot, rest) =>
|
||||
slot mustEqual 0
|
||||
subslot mustEqual 0
|
||||
|
|
@ -48,7 +48,7 @@ class SlottedMetaPacketTest extends Specification {
|
|||
val subslot = 12323
|
||||
val pkt = createMetaPacket(i, subslot, ByteVector.empty)
|
||||
|
||||
PacketCoding.DecodePacket(pkt).require match {
|
||||
PacketCoding.decodePacket(pkt).require match {
|
||||
case SlottedMetaPacket(slot, subslotDecoded, rest) =>
|
||||
// XXX: there isn't a simple solution to Slot0 and Slot4 be aliases of each other structurally
|
||||
// This is probably best left to higher layers
|
||||
|
|
@ -64,16 +64,16 @@ class SlottedMetaPacketTest extends Specification {
|
|||
}
|
||||
|
||||
"encode" in {
|
||||
val encoded = PacketCoding.EncodePacket(SlottedMetaPacket(0, 0x1000, ByteVector.empty)).require
|
||||
val encoded2 = PacketCoding.EncodePacket(SlottedMetaPacket(3, 0xffff, hex"414243")).require
|
||||
val encoded3 = PacketCoding.EncodePacket(SlottedMetaPacket(7, 0, hex"00")).require
|
||||
val encoded = PacketCoding.encodePacket(SlottedMetaPacket(0, 0x1000, ByteVector.empty)).require
|
||||
val encoded2 = PacketCoding.encodePacket(SlottedMetaPacket(3, 0xffff, hex"414243")).require
|
||||
val encoded3 = PacketCoding.encodePacket(SlottedMetaPacket(7, 0, hex"00")).require
|
||||
|
||||
encoded.toByteVector mustEqual createMetaPacket(0, 0x1000, ByteVector.empty)
|
||||
encoded2.toByteVector mustEqual createMetaPacket(3, 0xffff, hex"414243")
|
||||
encoded3.toByteVector mustEqual createMetaPacket(7, 0, hex"00")
|
||||
|
||||
PacketCoding.EncodePacket(SlottedMetaPacket(8, 0, hex"00")).require must throwA[AssertionError]
|
||||
PacketCoding.EncodePacket(SlottedMetaPacket(-1, 0, hex"00")).require must throwA[AssertionError]
|
||||
PacketCoding.EncodePacket(SlottedMetaPacket(0, 0x10000, hex"00")).require must throwA[IllegalArgumentException]
|
||||
PacketCoding.encodePacket(SlottedMetaPacket(8, 0, hex"00")).require must throwA[AssertionError]
|
||||
PacketCoding.encodePacket(SlottedMetaPacket(-1, 0, hex"00")).require must throwA[AssertionError]
|
||||
PacketCoding.encodePacket(SlottedMetaPacket(0, 0x10000, hex"00")).require must throwA[IllegalArgumentException]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class TeardownConnectionTest extends Specification {
|
|||
val string = hex"00 05 02 4F 57 17 00 06"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case TeardownConnection(nonce) =>
|
||||
nonce mustEqual 391597826
|
||||
case _ =>
|
||||
|
|
@ -19,7 +19,7 @@ class TeardownConnectionTest extends Specification {
|
|||
}
|
||||
|
||||
"encode" in {
|
||||
val encoded = PacketCoding.EncodePacket(TeardownConnection(391597826)).require
|
||||
val encoded = PacketCoding.encodePacket(TeardownConnection(391597826)).require
|
||||
|
||||
encoded.toByteVector mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ActionCancelMessageTest extends Specification {
|
|||
val string = hex"22 201ee01a10"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ActionCancelMessage(player_guid, object_guid, unk) =>
|
||||
player_guid mustEqual PlanetSideGUID(7712)
|
||||
object_guid mustEqual PlanetSideGUID(6880)
|
||||
|
|
@ -23,7 +23,7 @@ class ActionCancelMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ActionCancelMessage(PlanetSideGUID(7712), PlanetSideGUID(6880), 1)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ActionProgressMessageTest extends Specification {
|
|||
val string = hex"216000000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ActionProgressMessage(unk1, unk2) =>
|
||||
unk1 mustEqual 6
|
||||
unk2 mustEqual 0
|
||||
|
|
@ -21,7 +21,7 @@ class ActionProgressMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ActionProgressMessage(6, 0L)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ActionResultMessageTest extends Specification {
|
|||
val string_fail = hex"1f 0080000000"
|
||||
|
||||
"decode (pass)" in {
|
||||
PacketCoding.DecodePacket(string_pass).require match {
|
||||
PacketCoding.decodePacket(string_pass).require match {
|
||||
case ActionResultMessage(okay, code) =>
|
||||
okay mustEqual true
|
||||
code mustEqual None
|
||||
|
|
@ -21,7 +21,7 @@ class ActionResultMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (fail)" in {
|
||||
PacketCoding.DecodePacket(string_fail).require match {
|
||||
PacketCoding.decodePacket(string_fail).require match {
|
||||
case ActionResultMessage(okay, code) =>
|
||||
okay mustEqual false
|
||||
code mustEqual Some(1)
|
||||
|
|
@ -32,28 +32,28 @@ class ActionResultMessageTest extends Specification {
|
|||
|
||||
"encode (pass, full)" in {
|
||||
val msg = ActionResultMessage(true, None)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_pass
|
||||
}
|
||||
|
||||
"encode (pass, minimal)" in {
|
||||
val msg = ActionResultMessage.Pass
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_pass
|
||||
}
|
||||
|
||||
"encode (fail, full)" in {
|
||||
val msg = ActionResultMessage(false, Some(1))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_fail
|
||||
}
|
||||
|
||||
"encode (fail, minimal)" in {
|
||||
val msg = ActionResultMessage.Fail(1)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_fail
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@ class AggravatedDamageMessageTest extends Specification {
|
|||
val string = hex"6a350a0e000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
case AggravatedDamageMessage(guid,unk) =>
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AggravatedDamageMessage(guid, unk) =>
|
||||
guid mustEqual PlanetSideGUID(2613)
|
||||
unk mustEqual 14
|
||||
case _ =>
|
||||
|
|
@ -22,7 +22,7 @@ class AggravatedDamageMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = AggravatedDamageMessage(PlanetSideGUID(2613), 14)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ArmorChangedMessageTest extends Specification {
|
|||
val string = hex"3E 11 01 4C"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ArmorChangedMessage(player_guid, armor, subtype) =>
|
||||
player_guid mustEqual PlanetSideGUID(273)
|
||||
armor mustEqual ExoSuitType.MAX
|
||||
|
|
@ -23,7 +23,7 @@ class ArmorChangedMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ArmorChangedMessage(PlanetSideGUID(273), ExoSuitType.MAX, 3)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class AvatarDeadStateMessageTest extends Specification {
|
|||
val string_invalid = hex"ad3c1260801c12608009f99861fb0741e0400000F0"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AvatarDeadStateMessage(unk1, unk2, unk3, pos, unk4, unk5) =>
|
||||
unk1 mustEqual DeadState.Dead
|
||||
unk2 mustEqual 300000
|
||||
|
|
@ -26,7 +26,7 @@ class AvatarDeadStateMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (failure)" in {
|
||||
PacketCoding.DecodePacket(string_invalid).isFailure mustEqual true
|
||||
PacketCoding.decodePacket(string_invalid).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"encode" in {
|
||||
|
|
@ -38,7 +38,7 @@ class AvatarDeadStateMessageTest extends Specification {
|
|||
PlanetSideEmpire.VS,
|
||||
true
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class AvatarFirstTimeEventMessageTest extends Specification {
|
|||
val string = hex"69 4b00 c000 01000000 9e 766973697465645f63657274696669636174696f6e5f7465726d696e616c"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AvatarFirstTimeEventMessage(avatar_guid, object_guid, unk1, event_name) =>
|
||||
avatar_guid mustEqual PlanetSideGUID(75)
|
||||
object_guid mustEqual PlanetSideGUID(192)
|
||||
|
|
@ -24,7 +24,7 @@ class AvatarFirstTimeEventMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = AvatarFirstTimeEventMessage(PlanetSideGUID(75), PlanetSideGUID(192), 1, "visited_certification_terminal")
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class AvatarGrenadeStateMessageTest extends Specification {
|
|||
val string = hex"A9 DA11 01"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AvatarGrenadeStateMessage(player_guid, state) =>
|
||||
player_guid mustEqual PlanetSideGUID(4570)
|
||||
state mustEqual GrenadeState.Primed
|
||||
|
|
@ -22,7 +22,7 @@ class AvatarGrenadeStateMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = AvatarGrenadeStateMessage(PlanetSideGUID(4570), GrenadeState.Primed)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class AvatarImplantMessageTest extends Specification {
|
|||
val string = hex"58 630C 68 80"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AvatarImplantMessage(player_guid, unk1, unk2, implant) =>
|
||||
player_guid mustEqual PlanetSideGUID(3171)
|
||||
unk1 mustEqual ImplantAction.Activation
|
||||
|
|
@ -24,7 +24,7 @@ class AvatarImplantMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = AvatarImplantMessage(PlanetSideGUID(3171), ImplantAction.Activation, 1, 1)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class AvatarJumpMessageTest extends Specification {
|
|||
val string = hex"35 80"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AvatarJumpMessage(state) =>
|
||||
state mustEqual true
|
||||
case _ =>
|
||||
|
|
@ -20,7 +20,7 @@ class AvatarJumpMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = AvatarJumpMessage(true)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class AvatarSearchCriteriaMessageTest extends Specification {
|
|||
val string = hex"64 C604 00 00 00 00 00 00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AvatarSearchCriteriaMessage(unk1, unk2) =>
|
||||
unk1 mustEqual PlanetSideGUID(1222)
|
||||
unk2.length mustEqual 6
|
||||
|
|
@ -28,23 +28,23 @@ class AvatarSearchCriteriaMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0, 0, 0, 0, 0, 0))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
||||
"encode (failure; wrong number of list entries)" in {
|
||||
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
PacketCoding.encodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too big)" in {
|
||||
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0, 0, 0, 0, 0, 256))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
PacketCoding.encodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too small)" in {
|
||||
val msg = AvatarSearchCriteriaMessage(PlanetSideGUID(1222), List(0, 0, 0, -1, 0, 0))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
PacketCoding.encodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class AvatarStatisticsMessageTest extends Specification {
|
|||
hex"7F 01 3C 40 20 00 00 00 C0 00 00 00 00 00 00 00 20 00 00 00 20 00 00 00 40 00 00 00 00 00 00 00 00 00 00 00"
|
||||
|
||||
"decode (long)" in {
|
||||
PacketCoding.DecodePacket(string_long).require match {
|
||||
PacketCoding.decodePacket(string_long).require match {
|
||||
case AvatarStatisticsMessage(unk, stats) =>
|
||||
unk mustEqual 2
|
||||
stats.unk1 mustEqual None
|
||||
|
|
@ -25,7 +25,7 @@ class AvatarStatisticsMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (complex)" in {
|
||||
PacketCoding.DecodePacket(string_complex).require match {
|
||||
PacketCoding.decodePacket(string_complex).require match {
|
||||
case AvatarStatisticsMessage(unk, stats) =>
|
||||
unk mustEqual 0
|
||||
stats.unk1 mustEqual Some(1)
|
||||
|
|
@ -46,35 +46,35 @@ class AvatarStatisticsMessageTest extends Specification {
|
|||
|
||||
"encode (long)" in {
|
||||
val msg = AvatarStatisticsMessage(2, Statistics(0L))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_long
|
||||
}
|
||||
|
||||
"encode (complex)" in {
|
||||
val msg = AvatarStatisticsMessage(0, Statistics(1, 572, List[Long](1, 6, 0, 1, 1, 2, 0, 0)))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_complex
|
||||
}
|
||||
|
||||
"encode (failure; long; missing value)" in {
|
||||
val msg = AvatarStatisticsMessage(0, Statistics(None, None, List(0L)))
|
||||
PacketCoding.EncodePacket(msg).isFailure mustEqual true
|
||||
PacketCoding.encodePacket(msg).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"encode (failure; complex; missing value (5-bit))" in {
|
||||
val msg = AvatarStatisticsMessage(0, Statistics(None, Some(572), List[Long](1, 6, 0, 1, 1, 2, 0, 0)))
|
||||
PacketCoding.EncodePacket(msg).isFailure mustEqual true
|
||||
PacketCoding.encodePacket(msg).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"encode (failure; complex; missing value (11-bit))" in {
|
||||
val msg = AvatarStatisticsMessage(0, Statistics(Some(1), None, List[Long](1, 6, 0, 1, 1, 2, 0, 0)))
|
||||
PacketCoding.EncodePacket(msg).isFailure mustEqual true
|
||||
PacketCoding.encodePacket(msg).isFailure mustEqual true
|
||||
}
|
||||
|
||||
"encode (failure; complex; wrong number of list entries)" in {
|
||||
val msg = AvatarStatisticsMessage(0, Statistics(Some(1), None, List[Long](1, 6, 0, 1)))
|
||||
PacketCoding.EncodePacket(msg).isFailure mustEqual true
|
||||
PacketCoding.encodePacket(msg).isFailure mustEqual true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class AvatarVehicleTimerMessageTest extends Specification {
|
|||
val string2 = hex"57971b84667572794800000080"
|
||||
|
||||
"decode medkit" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case AvatarVehicleTimerMessage(player_guid, text, time, u1) =>
|
||||
player_guid mustEqual PlanetSideGUID(5821)
|
||||
text mustEqual "medkit"
|
||||
|
|
@ -23,7 +23,7 @@ class AvatarVehicleTimerMessageTest extends Specification {
|
|||
}
|
||||
}
|
||||
"decode fury" in {
|
||||
PacketCoding.DecodePacket(string2).require match {
|
||||
PacketCoding.decodePacket(string2).require match {
|
||||
case AvatarVehicleTimerMessage(player_guid, text, time, u1) =>
|
||||
player_guid mustEqual PlanetSideGUID(7063)
|
||||
text mustEqual "fury"
|
||||
|
|
@ -36,13 +36,13 @@ class AvatarVehicleTimerMessageTest extends Specification {
|
|||
|
||||
"encode medkit" in {
|
||||
val msg = AvatarVehicleTimerMessage(PlanetSideGUID(5821), "medkit", 5, false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
"encode fury" in {
|
||||
val msg = AvatarVehicleTimerMessage(PlanetSideGUID(7063), "fury", 72, true)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string2
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class BattleExperienceMessageTest extends Specification {
|
|||
val string = hex"B4 8A0A E7030000 00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case BattleExperienceMessage(player_guid, experience, unk) =>
|
||||
player_guid mustEqual PlanetSideGUID(2698)
|
||||
experience mustEqual 999
|
||||
|
|
@ -23,7 +23,7 @@ class BattleExperienceMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = BattleExperienceMessage(PlanetSideGUID(2698), 999, 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ class BattleplanMessageTest extends Specification {
|
|||
//0xb3856477028c4f0075007400730074006100620075006c006f00750073000a000130
|
||||
|
||||
"decode (start)" in {
|
||||
PacketCoding.DecodePacket(string_start).require match {
|
||||
PacketCoding.decodePacket(string_start).require match {
|
||||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41490746
|
||||
player_name mustEqual "YetAnotherFailureAlt"
|
||||
|
|
@ -34,7 +34,7 @@ class BattleplanMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (end)" in {
|
||||
PacketCoding.DecodePacket(string_stop).require match {
|
||||
PacketCoding.decodePacket(string_stop).require match {
|
||||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41490746
|
||||
player_name mustEqual "YetAnotherFailureAlt"
|
||||
|
|
@ -49,7 +49,7 @@ class BattleplanMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (stop)" in {
|
||||
PacketCoding.DecodePacket(string_line).require match {
|
||||
PacketCoding.decodePacket(string_line).require match {
|
||||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41378949
|
||||
player_name mustEqual "Outstabulous"
|
||||
|
|
@ -191,7 +191,7 @@ class BattleplanMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (style)" in {
|
||||
PacketCoding.DecodePacket(string_style).require match {
|
||||
PacketCoding.decodePacket(string_style).require match {
|
||||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41378949
|
||||
player_name mustEqual "Outstabulous"
|
||||
|
|
@ -217,7 +217,7 @@ class BattleplanMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (message)" in {
|
||||
PacketCoding.DecodePacket(string_message).require match {
|
||||
PacketCoding.decodePacket(string_message).require match {
|
||||
case BattleplanMessage(char_id, player_name, zone_id, diagrams) =>
|
||||
char_id mustEqual 41378949
|
||||
player_name mustEqual "Outstabulous"
|
||||
|
|
@ -245,7 +245,7 @@ class BattleplanMessageTest extends Specification {
|
|||
BattleDiagramAction(DiagramActionCode.StartDrawing) ::
|
||||
Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_start
|
||||
}
|
||||
|
|
@ -258,7 +258,7 @@ class BattleplanMessageTest extends Specification {
|
|||
BattleDiagramAction(DiagramActionCode.StopDrawing) ::
|
||||
Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_stop
|
||||
}
|
||||
|
|
@ -302,7 +302,7 @@ class BattleplanMessageTest extends Specification {
|
|||
BattleDiagramAction.vertex(7536.0f, 6632.0f) ::
|
||||
Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_line
|
||||
}
|
||||
|
|
@ -317,7 +317,7 @@ class BattleplanMessageTest extends Specification {
|
|||
BattleDiagramAction.vertex(7512.0f, 6344.0f) ::
|
||||
Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_style
|
||||
}
|
||||
|
|
@ -329,7 +329,7 @@ class BattleplanMessageTest extends Specification {
|
|||
10,
|
||||
BattleDiagramAction.drawString(7512.0f, 6312.0f, 2, 0, "Hello Auraxis!") :: Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_message
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class BeginZoningMessageTest extends Specification {
|
|||
val string = hex"43" //yes, just the opcode
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case BeginZoningMessage() =>
|
||||
ok
|
||||
case _ =>
|
||||
|
|
@ -20,7 +20,7 @@ class BeginZoningMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = BeginZoningMessage()
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class BindPlayerMessageTest extends Specification {
|
|||
val string_akkan = hex"16048440616d7388100000001400000214e171a8e33024"
|
||||
|
||||
"decode (standard)" in {
|
||||
PacketCoding.DecodePacket(string_standard).require match {
|
||||
PacketCoding.decodePacket(string_standard).require match {
|
||||
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
|
||||
action mustEqual BindStatus.Unbind
|
||||
bindDesc mustEqual ""
|
||||
|
|
@ -30,7 +30,7 @@ class BindPlayerMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (ams)" in {
|
||||
PacketCoding.DecodePacket(string_ams).require match {
|
||||
PacketCoding.decodePacket(string_ams).require match {
|
||||
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
|
||||
action mustEqual BindStatus.Unavailable
|
||||
bindDesc mustEqual "@ams"
|
||||
|
|
@ -46,7 +46,7 @@ class BindPlayerMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (tech)" in {
|
||||
PacketCoding.DecodePacket(string_tech).require match {
|
||||
PacketCoding.decodePacket(string_tech).require match {
|
||||
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
|
||||
action mustEqual BindStatus.Bind
|
||||
bindDesc mustEqual "@tech_plant"
|
||||
|
|
@ -62,7 +62,7 @@ class BindPlayerMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (akkan)" in {
|
||||
PacketCoding.DecodePacket(string_akkan).require match {
|
||||
PacketCoding.decodePacket(string_akkan).require match {
|
||||
case BindPlayerMessage(action, bindDesc, unk1, logging, unk2, unk3, unk4, pos) =>
|
||||
action mustEqual BindStatus.Available
|
||||
bindDesc mustEqual "@ams"
|
||||
|
|
@ -79,14 +79,14 @@ class BindPlayerMessageTest extends Specification {
|
|||
|
||||
"encode (standard)" in {
|
||||
val msg = BindPlayerMessage.Standard
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_standard
|
||||
}
|
||||
|
||||
"encode (ams)" in {
|
||||
val msg = BindPlayerMessage(BindStatus.Unavailable, "@ams", false, false, SpawnGroup.AMS, 10, 0, Vector3.Zero)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_ams
|
||||
}
|
||||
|
|
@ -102,7 +102,7 @@ class BindPlayerMessageTest extends Specification {
|
|||
14,
|
||||
Vector3(4610.0f, 6292, 69.625f)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_tech
|
||||
}
|
||||
|
|
@ -118,7 +118,7 @@ class BindPlayerMessageTest extends Specification {
|
|||
5,
|
||||
Vector3(2673.039f, 4423.547f, 39.1875f)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_akkan
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class BroadcastWarpgateUpdateMessageTest extends Specification {
|
|||
val string = hex"D9 0D 00 01 00 20"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case BroadcastWarpgateUpdateMessage(continent_guid, building_guid, state1, state2, state3) =>
|
||||
continent_guid mustEqual 13
|
||||
building_guid mustEqual 1
|
||||
|
|
@ -24,7 +24,7 @@ class BroadcastWarpgateUpdateMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = BroadcastWarpgateUpdateMessage(13, 1, false, false, true)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class BugReportMessageTest extends Specification {
|
|||
hex"89 03000000 0F000000 8B4465632020322032303039 1 1 0 19 6C511 656B1 7A11 830610062006300 843100320033003400"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case BugReportMessage(major, minor, date, btype, repeat, unk, zone, loc, summary, desc) =>
|
||||
major mustEqual 3
|
||||
minor mustEqual 15
|
||||
|
|
@ -43,7 +43,7 @@ class BugReportMessageTest extends Specification {
|
|||
"abc",
|
||||
"1234"
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class BuildingInfoUpdateMessageTest extends Specification {
|
|||
val string = hex"a0 04 00 09 00 16 00 00 00 00 80 00 00 00 17 00 00 00 00 00 00 40"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case BuildingInfoUpdateMessage(
|
||||
continent_guid,
|
||||
building_guid,
|
||||
|
|
@ -86,7 +86,7 @@ class BuildingInfoUpdateMessageTest extends Specification {
|
|||
false,
|
||||
false
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ChainLashMessageTest extends Specification {
|
|||
val string2 = hex"c5 5282e910100000093050"
|
||||
|
||||
"decode (1)" in {
|
||||
PacketCoding.DecodePacket(string1).require match {
|
||||
PacketCoding.decodePacket(string1).require match {
|
||||
case ChainLashMessage(u1a, u1b, u2, u3) =>
|
||||
u1a.isEmpty mustEqual true
|
||||
u1b.contains(Vector3(7673.164f, 544.1328f, 14.984375f)) mustEqual true
|
||||
|
|
@ -24,7 +24,7 @@ class ChainLashMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (2)" in {
|
||||
PacketCoding.DecodePacket(string2).require match {
|
||||
PacketCoding.decodePacket(string2).require match {
|
||||
case ChainLashMessage(u1a, u1b, u2, u3) =>
|
||||
u1a.contains(PlanetSideGUID(1445)) mustEqual true
|
||||
u1b.isEmpty mustEqual true
|
||||
|
|
@ -37,14 +37,14 @@ class ChainLashMessageTest extends Specification {
|
|||
|
||||
"encode (1)" in {
|
||||
val msg = ChainLashMessage(Vector3(7673.164f, 544.1328f, 14.984375f), 466, List(PlanetSideGUID(1603)))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string1
|
||||
}
|
||||
|
||||
"encode (2)" in {
|
||||
val msg = ChainLashMessage(PlanetSideGUID(1445), 466, List(PlanetSideGUID(1427)))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string2
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ChangeAmmoMessageTest extends Specification {
|
|||
val string = hex"47 4E00 00000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ChangeAmmoMessage(item_guid, unk1) =>
|
||||
item_guid mustEqual PlanetSideGUID(78)
|
||||
unk1 mustEqual 0
|
||||
|
|
@ -22,7 +22,7 @@ class ChangeAmmoMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ChangeAmmoMessage(PlanetSideGUID(78), 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ChangeFireModeMessageTest extends Specification {
|
|||
val string = hex"46 4C0020"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ChangeFireModeMessage(item_guid, fire_mode) =>
|
||||
item_guid mustEqual PlanetSideGUID(76)
|
||||
fire_mode mustEqual 1
|
||||
|
|
@ -22,7 +22,7 @@ class ChangeFireModeMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ChangeFireModeMessage(PlanetSideGUID(76), 1)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ChangeFireStateMessage_StartTest extends Specification {
|
|||
val string = hex"39 4C00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ChangeFireStateMessage_Start(item_guid) =>
|
||||
item_guid mustEqual PlanetSideGUID(76)
|
||||
case _ =>
|
||||
|
|
@ -21,7 +21,7 @@ class ChangeFireStateMessage_StartTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ChangeFireStateMessage_Start(PlanetSideGUID(76))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ChangeFireStateMessage_StopTest extends Specification {
|
|||
val string = hex"3A 4C00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ChangeFireStateMessage_Stop(item_guid) =>
|
||||
item_guid mustEqual PlanetSideGUID(76)
|
||||
case _ =>
|
||||
|
|
@ -21,7 +21,7 @@ class ChangeFireStateMessage_StopTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ChangeFireStateMessage_Stop(PlanetSideGUID(76))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ChangeShortcutBankMessageTest extends Specification {
|
|||
val string = hex"29 4B00 20"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ChangeShortcutBankMessage(player_guid, bank) =>
|
||||
player_guid mustEqual PlanetSideGUID(75)
|
||||
bank mustEqual 2
|
||||
|
|
@ -22,7 +22,7 @@ class ChangeShortcutBankMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ChangeShortcutBankMessage(PlanetSideGUID(75), 2)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class CharacterCreateRequestMessageTest extends Specification {
|
|||
val string = hex"2f 88 54006500730074004300680061007200 320590"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case CharacterCreateRequestMessage(name, head, voice, gender, faction) =>
|
||||
name mustEqual "TestChar"
|
||||
head mustEqual 50
|
||||
|
|
@ -26,7 +26,7 @@ class CharacterCreateRequestMessageTest extends Specification {
|
|||
"encode" in {
|
||||
val msg =
|
||||
CharacterCreateRequestMessage("TestChar", 50, CharacterVoice.Voice5, CharacterGender.Female, PlanetSideEmpire.NC)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class CharacterInfoMessageTest extends Specification {
|
|||
val string = hex"14 0F000000 10270000C1D87A024B00265CB08000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case CharacterInfoMessage(unk, zone, charId, guid, finished, last) =>
|
||||
unk mustEqual 15L
|
||||
zone mustEqual PlanetSideZoneID(10000)
|
||||
|
|
@ -26,7 +26,7 @@ class CharacterInfoMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = CharacterInfoMessage(15L, PlanetSideZoneID(10000), 41605313L, PlanetSideGUID(75), false, 6404428L)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class CharacterKnowledgeMessageTest extends Specification {
|
|||
val string = hex"ec cc637a02 45804600720061006e006b0065006e00740061006e006b0003c022dc0008f01800"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case CharacterKnowledgeMessage(char_id, Some(info)) =>
|
||||
char_id mustEqual 41575372L
|
||||
info mustEqual CharacterKnowledgeInfo(
|
||||
|
|
@ -64,7 +64,7 @@ class CharacterKnowledgeMessageTest extends Specification {
|
|||
PlanetSideGUID(12)
|
||||
)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class CharacterNoRecordMessageTest extends Specification {
|
|||
val string = hex"13 00400000" //we have no record of this packet, so here's something fake that works
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case CharacterNoRecordMessage(unk) =>
|
||||
unk mustEqual 16384
|
||||
case _ =>
|
||||
|
|
@ -20,7 +20,7 @@ class CharacterNoRecordMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = CharacterNoRecordMessage(16384)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class CharacterRequestMessageTest extends Specification {
|
|||
val string = hex"30 c1d87a02 00000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case CharacterRequestMessage(charId, action) =>
|
||||
charId mustEqual 41605313L
|
||||
action mustEqual CharacterRequestAction.Select
|
||||
|
|
@ -21,7 +21,7 @@ class CharacterRequestMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = CharacterRequestMessage(41605313L, CharacterRequestAction.Select)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ChatMsgTest extends Specification {
|
|||
val string_tell = hex"12 20 C180640065006600 83610062006300"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_local).require match {
|
||||
PacketCoding.decodePacket(string_local).require match {
|
||||
case ChatMsg(messagetype, has_wide_contents, recipient, contents, note_contents) =>
|
||||
messagetype mustEqual ChatMessageType.CMT_OPEN
|
||||
has_wide_contents mustEqual true
|
||||
|
|
@ -23,7 +23,7 @@ class ChatMsgTest extends Specification {
|
|||
ko
|
||||
}
|
||||
|
||||
PacketCoding.DecodePacket(string_tell).require match {
|
||||
PacketCoding.decodePacket(string_tell).require match {
|
||||
case ChatMsg(messagetype, has_wide_contents, recipient, contents, note_contents) =>
|
||||
messagetype mustEqual ChatMessageType.CMT_TELL
|
||||
has_wide_contents mustEqual true
|
||||
|
|
@ -37,12 +37,12 @@ class ChatMsgTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg_local = ChatMsg(ChatMessageType.CMT_OPEN, true, "", "abc", None)
|
||||
val pkt_local = PacketCoding.EncodePacket(msg_local).require.toByteVector
|
||||
val pkt_local = PacketCoding.encodePacket(msg_local).require.toByteVector
|
||||
|
||||
pkt_local mustEqual string_local
|
||||
|
||||
val msg_tell = ChatMsg(ChatMessageType.CMT_TELL, true, "def", "abc", None)
|
||||
val pkt_tell = PacketCoding.EncodePacket(msg_tell).require.toByteVector
|
||||
val pkt_tell = PacketCoding.encodePacket(msg_tell).require.toByteVector
|
||||
|
||||
pkt_tell mustEqual string_tell
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ChildObjectStateMessageTest extends Specification {
|
|||
val string = hex"1E 640B 06 47"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ChildObjectStateMessage(object_guid, pitch, yaw) =>
|
||||
object_guid mustEqual PlanetSideGUID(2916)
|
||||
pitch mustEqual 343.125f
|
||||
|
|
@ -23,7 +23,7 @@ class ChildObjectStateMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ChildObjectStateMessage(PlanetSideGUID(2916), 343.125f, 160.3125f)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ConnectToWorldMessageTest extends Specification {
|
|||
val string = hex"04 8667656D696E69 8C36342E33372E3135382E36393C75"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ConnectToWorldMessage(serverName, serverIp, serverPort) =>
|
||||
serverName mustEqual "gemini"
|
||||
serverIp mustEqual "64.37.158.69"
|
||||
|
|
@ -22,7 +22,7 @@ class ConnectToWorldMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ConnectToWorldMessage("gemini", "64.37.158.69", 30012)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ConnectToWorldRequestMessageTest extends Specification {
|
|||
hex"03 8667656D696E69 0000000000000000 00000000 00000000 00000000 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 80 00 00 "
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ConnectToWorldRequestMessage(serverName, token, majorVersion, minorVersion, revision, buildDate, unk) =>
|
||||
serverName mustEqual "gemini"
|
||||
token mustEqual ""
|
||||
|
|
@ -27,7 +27,7 @@ class ConnectToWorldRequestMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ConnectToWorldRequestMessage("gemini", "", 0, 0, 0, "", 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ContinentalLockUpdateMessageTest extends Specification {
|
|||
val string = hex"A8 16 00 40"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ContinentalLockUpdateMessage(continent_guid, empire) =>
|
||||
continent_guid mustEqual 22
|
||||
empire mustEqual PlanetSideEmpire.NC
|
||||
|
|
@ -22,7 +22,7 @@ class ContinentalLockUpdateMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ContinentalLockUpdateMessage(22, PlanetSideEmpire.NC)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ class CreateShortcutMessageTest extends Specification {
|
|||
val stringRemove = hex"28 4C05 01 00 00"
|
||||
|
||||
"decode (medkit)" in {
|
||||
PacketCoding.DecodePacket(stringMedkit).require match {
|
||||
PacketCoding.decodePacket(stringMedkit).require match {
|
||||
case CreateShortcutMessage(player_guid, slot, unk, addShortcut, shortcut) =>
|
||||
player_guid mustEqual PlanetSideGUID(4210)
|
||||
slot mustEqual 1
|
||||
|
|
@ -31,7 +31,7 @@ class CreateShortcutMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (macro)" in {
|
||||
PacketCoding.DecodePacket(stringMacro).require match {
|
||||
PacketCoding.decodePacket(stringMacro).require match {
|
||||
case CreateShortcutMessage(player_guid, slot, unk, addShortcut, shortcut) =>
|
||||
player_guid mustEqual PlanetSideGUID(1356)
|
||||
slot mustEqual 8
|
||||
|
|
@ -48,7 +48,7 @@ class CreateShortcutMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (remove)" in {
|
||||
PacketCoding.DecodePacket(stringRemove).require match {
|
||||
PacketCoding.decodePacket(stringRemove).require match {
|
||||
case CreateShortcutMessage(player_guid, slot, unk, addShortcut, shortcut) =>
|
||||
player_guid mustEqual PlanetSideGUID(1356)
|
||||
slot mustEqual 1
|
||||
|
|
@ -62,7 +62,7 @@ class CreateShortcutMessageTest extends Specification {
|
|||
|
||||
"encode (medkit)" in {
|
||||
val msg = CreateShortcutMessage(PlanetSideGUID(4210), 1, 0, true, Some(Shortcut(0, "medkit")))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringMedkit
|
||||
}
|
||||
|
|
@ -75,14 +75,14 @@ class CreateShortcutMessageTest extends Specification {
|
|||
true,
|
||||
Some(Shortcut(1, "shortcut_macro", "NTU", "/platoon Incoming NTU spam!"))
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringMacro
|
||||
}
|
||||
|
||||
"encode (remove)" in {
|
||||
val msg = CreateShortcutMessage(PlanetSideGUID(1356), 1, 0, false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringRemove
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class DamageFeedbackMessageTest extends Specification {
|
|||
val string_2 = hex"7B 5E5826D8001DC0400000"
|
||||
|
||||
"decode (string 1)" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DamageFeedbackMessage(unk1, unk2, unk2a, unk2b, unk2c, unk3, unk3a, unk3b, unk3c, unk3d, unk4, unk5, unk6) =>
|
||||
unk1 mustEqual 3
|
||||
unk2 mustEqual true
|
||||
|
|
@ -33,7 +33,7 @@ class DamageFeedbackMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (string 2)" in {
|
||||
PacketCoding.DecodePacket(string_2).require match {
|
||||
PacketCoding.decodePacket(string_2).require match {
|
||||
case DamageFeedbackMessage(unk1, unk2, unk2a, unk2b, unk2c, unk3, unk3a, unk3b, unk3c, unk3d, unk4, unk5, unk6) =>
|
||||
unk1 mustEqual 5
|
||||
unk2 mustEqual true
|
||||
|
|
@ -69,7 +69,7 @@ class DamageFeedbackMessageTest extends Specification {
|
|||
2,
|
||||
0
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
@ -90,7 +90,7 @@ class DamageFeedbackMessageTest extends Specification {
|
|||
750,
|
||||
0
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_2
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DamageMessageTest extends Specification {
|
|||
val string = hex"0b610b02610b00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DamageMessage(guid1, unk1, guid2, unk2) =>
|
||||
guid1 mustEqual PlanetSideGUID(2913)
|
||||
unk1 mustEqual 2
|
||||
|
|
@ -24,7 +24,7 @@ class DamageMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DamageMessage(PlanetSideGUID(2913), 2, PlanetSideGUID(2913), false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DamageWithPositionMessageTest extends Specification {
|
|||
val string = hex"A6 11 6C2D7 65535 CA16"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DamageWithPositionMessage(unk, pos) =>
|
||||
unk mustEqual 17
|
||||
pos.x mustEqual 3674.8438f
|
||||
|
|
@ -24,7 +24,7 @@ class DamageWithPositionMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DamageWithPositionMessage(17, Vector3(3674.8438f, 2726.789f, 91.15625f))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class DataChallengeMessageRespTest extends Specification {
|
|||
val string = hex"948673616d706c6501000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DataChallengeMessageResp(attribute, value) =>
|
||||
attribute mustEqual "sample"
|
||||
value mustEqual 1L
|
||||
|
|
@ -21,7 +21,7 @@ class DataChallengeMessageRespTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DataChallengeMessageResp("sample", 1L)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class DataChallengeMessageTest extends Specification {
|
|||
val string = hex"938673616d706c6501000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DataChallengeMessage(attribute, value) =>
|
||||
attribute mustEqual "sample"
|
||||
value mustEqual 1L
|
||||
|
|
@ -21,7 +21,7 @@ class DataChallengeMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DataChallengeMessage("sample", 1L)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DelayedPathMountMsgTest extends Specification {
|
|||
val string = hex"5a f50583044680"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DelayedPathMountMsg(player_guid, vehicle_guid, u3, u4) =>
|
||||
player_guid mustEqual PlanetSideGUID(1525)
|
||||
vehicle_guid mustEqual PlanetSideGUID(1155)
|
||||
|
|
@ -24,7 +24,7 @@ class DelayedPathMountMsgTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DelayedPathMountMsg(PlanetSideGUID(1525), PlanetSideGUID(1155), 70, true)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class DensityLevelUpdateMessageTest extends Specification {
|
|||
val string = hex"cd 0100 1f4e 000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DensityLevelUpdateMessage(zone_id, building_id, unk) =>
|
||||
zone_id mustEqual 1
|
||||
building_id mustEqual 19999
|
||||
|
|
@ -30,23 +30,23 @@ class DensityLevelUpdateMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, 0, 0, 0))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
||||
"encode (failure; wrong number of list entries)" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
PacketCoding.encodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too big)" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, 0, 0, 8))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
PacketCoding.encodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
|
||||
"encode (failure; list number too small)" in {
|
||||
val msg = DensityLevelUpdateMessage(1, 19999, List(0, 0, 0, 0, 0, -1, 0, 0))
|
||||
PacketCoding.EncodePacket(msg).isSuccessful mustEqual false
|
||||
PacketCoding.encodePacket(msg).isSuccessful mustEqual false
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DeployObjectMessageTest extends Specification {
|
|||
val string = hex"5d 740b e8030000 a644b 6e3c6 7e18 00 00 3f 01000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DeployObjectMessage(guid, unk1, pos, orient, unk2) =>
|
||||
guid mustEqual PlanetSideGUID(2932)
|
||||
unk1 mustEqual 1000L
|
||||
|
|
@ -31,7 +31,7 @@ class DeployObjectMessageTest extends Specification {
|
|||
Vector3.z(272.8125f),
|
||||
1L
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DeployRequestMessageTest extends Specification {
|
|||
val string = hex"4b 4b00 7c01 40 0cf73b52aa6a9300"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DeployRequestMessage(player_guid, vehicle_guid, deploy_state, unk2, unk3, pos) =>
|
||||
player_guid mustEqual PlanetSideGUID(75)
|
||||
vehicle_guid mustEqual PlanetSideGUID(380)
|
||||
|
|
@ -35,7 +35,7 @@ class DeployRequestMessageTest extends Specification {
|
|||
false,
|
||||
Vector3(4060.1953f, 2218.8281f, 155.32812f)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DeployableObjectsInfoMessageTest extends Specification {
|
|||
val string = hex"76 00 80 00 00 31 85 41 CF D3 7E B3 34 00 E6 30 48" //this was a TRAP @ Ogma, Forseral
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DeployableObjectsInfoMessage(action, list) =>
|
||||
action mustEqual DeploymentAction.Dismiss
|
||||
list.size mustEqual 1
|
||||
|
|
@ -37,7 +37,7 @@ class DeployableObjectsInfoMessageTest extends Specification {
|
|||
PlanetSideGUID(2502)
|
||||
)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class DestroyDisplayMessageTest extends Specification {
|
|||
hex"81 87 41006E00670065006C006C006F00 35BCD801 8 F201 9207 0A 0 48004D00460049004300 B18ED901 00" // Angello-VS (???) HMFIC-TR
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DestroyDisplayMessage(
|
||||
killer,
|
||||
killer_charId,
|
||||
|
|
@ -53,7 +53,7 @@ class DestroyDisplayMessageTest extends Specification {
|
|||
PlanetSideEmpire.TR,
|
||||
false
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class DestroyMessageTest extends Specification {
|
|||
|
||||
"DestroyMessage" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DestroyMessage(unk1, unk2, unk3, pos) =>
|
||||
unk1 mustEqual PlanetSideGUID(2420)
|
||||
unk2 mustEqual PlanetSideGUID(2420)
|
||||
|
|
@ -30,7 +30,7 @@ class DestroyMessageTest extends Specification {
|
|||
PlanetSideGUID(0),
|
||||
Vector3(1642.0469f, 4091.6172f, 32.59375f)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class DisconnectMessageTest extends Specification {
|
|||
val string = hex"B7 85 46 69 72 73 74 86 53 65 63 6F 6E 64 8E 46 69 72 73 74 20 26 20 73 65 63 6F 6E 64"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DisconnectMessage(unk1, unk2, unk3) =>
|
||||
unk1 mustEqual "First"
|
||||
unk2 mustEqual "Second"
|
||||
|
|
@ -22,7 +22,7 @@ class DisconnectMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DisconnectMessage("First", "Second", "First & second")
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DismountBuildingMsgTest extends Specification {
|
|||
val string = hex"7C 4B00 2E00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DismountBuildingMsg(player_guid, building_guid) =>
|
||||
player_guid mustEqual PlanetSideGUID(75)
|
||||
building_guid mustEqual PlanetSideGUID(46)
|
||||
|
|
@ -22,7 +22,7 @@ class DismountBuildingMsgTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DismountBuildingMsg(PlanetSideGUID(75), PlanetSideGUID(46))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DismountVehicleMsgTest extends Specification {
|
|||
val string = hex"0F C609 00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DismountVehicleMsg(player_guid, bailType, wasKickedByDriver) =>
|
||||
player_guid mustEqual PlanetSideGUID(2502)
|
||||
bailType mustEqual BailType.Normal
|
||||
|
|
@ -23,7 +23,7 @@ class DismountVehicleMsgTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DismountVehicleMsg(PlanetSideGUID(2502), BailType.Normal, false)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DisplayedAwardMessageTest extends Specification {
|
|||
val string = hex"D1 9F06 A6010000 3 0"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DisplayedAwardMessage(player_guid, ribbon, bar) =>
|
||||
player_guid mustEqual PlanetSideGUID(1695)
|
||||
ribbon mustEqual MeritCommendation.TwoYearVS
|
||||
|
|
@ -23,7 +23,7 @@ class DisplayedAwardMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DisplayedAwardMessage(PlanetSideGUID(1695), MeritCommendation.TwoYearVS, RibbonBarsSlot.TermOfService)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class DropItemMessageTest extends Specification {
|
|||
val string = hex"37 4C00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DropItemMessage(item_guid) =>
|
||||
item_guid mustEqual PlanetSideGUID(76)
|
||||
case _ =>
|
||||
|
|
@ -21,7 +21,7 @@ class DropItemMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = DropItemMessage(PlanetSideGUID(76))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class DroppodFreefallingMessageTest extends Specification {
|
|||
|
||||
"DroppodFreefallingMessage" should {
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case DroppodFreefallingMessage(guid, pos, vel, pos2, orientation1, orientation2) =>
|
||||
guid mustEqual PlanetSideGUID(3618)
|
||||
pos mustEqual Vector3(5724, 3612, 1085)
|
||||
|
|
@ -35,7 +35,7 @@ class DroppodFreefallingMessageTest extends Specification {
|
|||
Vector3(0, 70.3125f, 272.8125f),
|
||||
Vector3(0, 0, 272.8125f)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class EmoteMsgTest extends Specification {
|
|||
val string = hex"25 4B00 15"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case EmoteMsg(avatar_guid, emote) =>
|
||||
avatar_guid mustEqual PlanetSideGUID(75)
|
||||
emote mustEqual EmoteType.Thumbsdown
|
||||
|
|
@ -22,7 +22,7 @@ class EmoteMsgTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = EmoteMsg(PlanetSideGUID(75), EmoteType.Thumbsdown)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ExperienceAddedMessageTest extends Specification {
|
|||
val string = hex"B8 04 03"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ExperienceAddedMessage(exp, unk) =>
|
||||
exp mustEqual 260 //0x104
|
||||
unk mustEqual true
|
||||
|
|
@ -21,7 +21,7 @@ class ExperienceAddedMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ExperienceAddedMessage(260)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class FacilityBenefitShieldChargeRequestMessageTest extends Specification {
|
|||
val string = hex"C2 4C00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case FacilityBenefitShieldChargeRequestMessage(guid) =>
|
||||
guid mustEqual PlanetSideGUID(76)
|
||||
case _ =>
|
||||
|
|
@ -21,7 +21,7 @@ class FacilityBenefitShieldChargeRequestMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = FacilityBenefitShieldChargeRequestMessage(PlanetSideGUID(76))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class FavoritesMessageTest extends Specification {
|
|||
val stringInfantry = hex"60 2C 03 82 34 4100 6700 6900 6C00 6500 2000 2800 6200 6100 7300 6900 6300 2900 20"
|
||||
|
||||
"decode (for infantry)" in {
|
||||
PacketCoding.DecodePacket(stringInfantry).require match {
|
||||
PacketCoding.decodePacket(stringInfantry).require match {
|
||||
case FavoritesMessage(list, player_guid, line, label, armor) =>
|
||||
list mustEqual LoadoutType.Infantry
|
||||
player_guid mustEqual PlanetSideGUID(3760)
|
||||
|
|
@ -27,13 +27,13 @@ class FavoritesMessageTest extends Specification {
|
|||
|
||||
"encode (for infantry)" in {
|
||||
val msg = FavoritesMessage(LoadoutType.Infantry, PlanetSideGUID(3760), 0, "Agile (basic)", 1)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringInfantry
|
||||
}
|
||||
|
||||
"decode (for vehicles)" in {
|
||||
PacketCoding.DecodePacket(stringVehicles).require match {
|
||||
PacketCoding.decodePacket(stringVehicles).require match {
|
||||
case FavoritesMessage(list, player_guid, line, label, armor) =>
|
||||
list mustEqual LoadoutType.Vehicle
|
||||
player_guid mustEqual PlanetSideGUID(4210)
|
||||
|
|
@ -47,7 +47,7 @@ class FavoritesMessageTest extends Specification {
|
|||
|
||||
"encode (for vehicles)" in {
|
||||
val msg = FavoritesMessage(LoadoutType.Vehicle, PlanetSideGUID(4210), 0, "Skyguard")
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringVehicles
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class FavoritesRequestTest extends Specification {
|
|||
val stringInfantry = hex"5E 4B00 1187 4500 7800 6100 6D00 7000 6C00 6500"
|
||||
|
||||
"decode (for infantry)" in {
|
||||
PacketCoding.DecodePacket(stringInfantry).require match {
|
||||
PacketCoding.decodePacket(stringInfantry).require match {
|
||||
case FavoritesRequest(player_guid, list, action, line, label) =>
|
||||
player_guid mustEqual PlanetSideGUID(75)
|
||||
list mustEqual LoadoutType.Infantry
|
||||
|
|
@ -26,7 +26,7 @@ class FavoritesRequestTest extends Specification {
|
|||
|
||||
"encode (for infantry)" in {
|
||||
val msg = FavoritesRequest(PlanetSideGUID(75), LoadoutType.Infantry, FavoritesAction.Save, 1, Some("Example"))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringInfantry
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class FireHintMessageTest extends Specification {
|
|||
val string2 = hex"a1 080e 65af5705074411 0000cffee0fc7b08899f5580"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case FireHintMessage(weapon_guid, pos, u1, u2, u3, u4, u5) =>
|
||||
weapon_guid mustEqual PlanetSideGUID(5889)
|
||||
pos mustEqual Vector3(3482.2734f, 3642.4922f, 53.125f)
|
||||
|
|
@ -26,7 +26,7 @@ class FireHintMessageTest extends Specification {
|
|||
}
|
||||
}
|
||||
"decode string2" in {
|
||||
PacketCoding.DecodePacket(string2).require match {
|
||||
PacketCoding.decodePacket(string2).require match {
|
||||
case FireHintMessage(weapon_guid, pos, u1, u2, u3, u4, u5) =>
|
||||
weapon_guid mustEqual PlanetSideGUID(3592)
|
||||
pos mustEqual Vector3(2910.789f, 3744.875f, 69.0625f)
|
||||
|
|
@ -42,7 +42,7 @@ class FireHintMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = FireHintMessage(PlanetSideGUID(5889), Vector3(3482.2734f, 3642.4922f, 53.125f), 0, 65399, 7581, 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
@ -56,7 +56,7 @@ class FireHintMessageTest extends Specification {
|
|||
3,
|
||||
Some(Vector3(21.5f, -6.8125f, 2.65625f))
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string2
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class FriendsRequestTest extends Specification {
|
|||
val string = hex"72 3 0A0 46004A0048004E004300"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case FriendsRequest(action, friend) =>
|
||||
action mustEqual 1
|
||||
friend.length mustEqual 5
|
||||
|
|
@ -22,7 +22,7 @@ class FriendsRequestTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = FriendsRequest(1, "FJHNC")
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class FriendsResponseTest extends Specification {
|
|||
val stringShort = hex"73 81 80"
|
||||
|
||||
"decode (one friend)" in {
|
||||
PacketCoding.DecodePacket(stringOneFriend).require match {
|
||||
PacketCoding.decodePacket(stringOneFriend).require match {
|
||||
case FriendsResponse(action, unk2, unk3, unk4, list) =>
|
||||
action mustEqual FriendAction.UpdateFriend
|
||||
unk2 mustEqual 0
|
||||
|
|
@ -28,7 +28,7 @@ class FriendsResponseTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (multiple friends)" in {
|
||||
PacketCoding.DecodePacket(stringManyFriends).require match {
|
||||
PacketCoding.decodePacket(stringManyFriends).require match {
|
||||
case FriendsResponse(action, unk2, unk3, unk4, list) =>
|
||||
action mustEqual FriendAction.InitializeFriendList
|
||||
unk2 mustEqual 0
|
||||
|
|
@ -51,7 +51,7 @@ class FriendsResponseTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (short)" in {
|
||||
PacketCoding.DecodePacket(stringShort).require match {
|
||||
PacketCoding.decodePacket(stringShort).require match {
|
||||
case FriendsResponse(action, unk2, unk3, unk4, list) =>
|
||||
action mustEqual FriendAction.InitializeIgnoreList
|
||||
unk2 mustEqual 0
|
||||
|
|
@ -72,7 +72,7 @@ class FriendsResponseTest extends Specification {
|
|||
Friend("KurtHectic-G", false) ::
|
||||
Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringOneFriend
|
||||
}
|
||||
|
|
@ -90,14 +90,14 @@ class FriendsResponseTest extends Specification {
|
|||
Friend("KurtHectic-G", false) ::
|
||||
Nil
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringManyFriends
|
||||
}
|
||||
|
||||
"encode (short)" in {
|
||||
val msg = FriendsResponse(FriendAction.InitializeIgnoreList, 0, true, true)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringShort
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class GenericActionMessageTest extends Specification {
|
|||
val string = hex"A7 94"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case GenericActionMessage(action) =>
|
||||
action mustEqual 37
|
||||
case _ =>
|
||||
|
|
@ -20,7 +20,7 @@ class GenericActionMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = GenericActionMessage(37)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class GenericCollisionMsgTest extends Specification {
|
|||
val string =
|
||||
hex"3C 92C00000190000001B2A8010932CEF505C70946F00000000000000000000000017725EBC6D6A058000000000000000000000000000003F8FF45140"
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case GenericCollisionMsg(unk1, p, t, php, thp, pv, tv, ppos, tpos, unk2, unk3, unk4) =>
|
||||
unk1 mustEqual 2
|
||||
p mustEqual PlanetSideGUID(75)
|
||||
|
|
@ -53,7 +53,7 @@ class GenericCollisionMsgTest extends Specification {
|
|||
0L,
|
||||
1171341310L
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class GenericObjectActionMessageTest extends Specification {
|
|||
val string = hex"56 B501 24"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case GenericObjectActionMessage(object_guid, action) =>
|
||||
object_guid mustEqual PlanetSideGUID(437)
|
||||
action mustEqual 9
|
||||
|
|
@ -22,7 +22,7 @@ class GenericObjectActionMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = GenericObjectActionMessage(PlanetSideGUID(437), 9)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class GenericObjectStateMsgTest extends Specification {
|
|||
val string = hex"1D 6401 10000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case GenericObjectStateMsg(object_guid, state) =>
|
||||
object_guid mustEqual PlanetSideGUID(356)
|
||||
state mustEqual 16
|
||||
|
|
@ -22,7 +22,7 @@ class GenericObjectStateMsgTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = GenericObjectStateMsg(PlanetSideGUID(356), 16)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class HackMessageTest extends Specification {
|
|||
val string = hex"54 000105c3800000202fc04200000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case HackMessage(unk1, target_guid, player_guid, progress, unk5, hack_state, unk7) =>
|
||||
unk1 mustEqual 0
|
||||
target_guid mustEqual PlanetSideGUID(1024)
|
||||
|
|
@ -28,7 +28,7 @@ class HackMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = HackMessage(0, PlanetSideGUID(1024), PlanetSideGUID(3607), 0, 3212836864L, HackState.Start, 8L)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class HitHintTest extends Specification {
|
|||
val string = hex"0A 460B 0100"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case HitHint(source, player) =>
|
||||
source mustEqual PlanetSideGUID(2886)
|
||||
player mustEqual PlanetSideGUID(1)
|
||||
|
|
@ -22,7 +22,7 @@ class HitHintTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = HitHint(PlanetSideGUID(2886), PlanetSideGUID(1))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class HitMessageTest extends Specification {
|
|||
val string_hitobj = hex"09 99292705F4B1FB9514585F08BDD3D454CC5EE80300"
|
||||
|
||||
"decode (generic)" in {
|
||||
PacketCoding.DecodePacket(string_hitgeneric).require match {
|
||||
PacketCoding.decodePacket(string_hitgeneric).require match {
|
||||
case HitMessage(seq_time, projectile_guid, unk1, hit_info, unk2, unk3, unk4) =>
|
||||
seq_time mustEqual 777
|
||||
projectile_guid mustEqual PlanetSideGUID(40102)
|
||||
|
|
@ -27,7 +27,7 @@ class HitMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (object)" in {
|
||||
PacketCoding.DecodePacket(string_hitobj).require match {
|
||||
PacketCoding.decodePacket(string_hitobj).require match {
|
||||
case HitMessage(seq_time, projectile_guid, unk1, hit_info, unk2, unk3, unk4) =>
|
||||
seq_time mustEqual 153
|
||||
projectile_guid mustEqual PlanetSideGUID(40100)
|
||||
|
|
@ -49,7 +49,7 @@ class HitMessageTest extends Specification {
|
|||
|
||||
"encode (generic)" in {
|
||||
val msg_hitgeneric = HitMessage(777, PlanetSideGUID(40102), 0, None, true, false, None)
|
||||
val pkt_hitgeneric = PacketCoding.EncodePacket(msg_hitgeneric).require.toByteVector
|
||||
val pkt_hitgeneric = PacketCoding.encodePacket(msg_hitgeneric).require.toByteVector
|
||||
pkt_hitgeneric mustEqual string_hitgeneric
|
||||
}
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ class HitMessageTest extends Specification {
|
|||
false,
|
||||
None
|
||||
)
|
||||
val pkt_hitobj = PacketCoding.EncodePacket(msg_hitobj).require.toByteVector
|
||||
val pkt_hitobj = PacketCoding.encodePacket(msg_hitobj).require.toByteVector
|
||||
|
||||
pkt_hitobj mustEqual string_hitobj
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class HotSpotUpdateMessageTest extends Specification {
|
|||
val stringThree = hex"9F 0A00 4 030 00FC8 00F0A 80000 002E9 00BEA 80000 00FC8 00BEA 80000 0"
|
||||
|
||||
"decode (clear)" in {
|
||||
PacketCoding.DecodePacket(stringClear).require match {
|
||||
PacketCoding.decodePacket(stringClear).require match {
|
||||
case HotSpotUpdateMessage(continent_id, unk, spots) =>
|
||||
continent_id mustEqual 5
|
||||
unk mustEqual 1
|
||||
|
|
@ -24,7 +24,7 @@ class HotSpotUpdateMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (one)" in {
|
||||
PacketCoding.DecodePacket(stringOne).require match {
|
||||
PacketCoding.decodePacket(stringOne).require match {
|
||||
case HotSpotUpdateMessage(continent_id, unk, spots) =>
|
||||
continent_id mustEqual 5
|
||||
unk mustEqual 1
|
||||
|
|
@ -36,7 +36,7 @@ class HotSpotUpdateMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (two)" in {
|
||||
PacketCoding.DecodePacket(stringTwo).require match {
|
||||
PacketCoding.decodePacket(stringTwo).require match {
|
||||
case HotSpotUpdateMessage(continent_id, unk, spots) =>
|
||||
continent_id mustEqual 5
|
||||
unk mustEqual 5
|
||||
|
|
@ -49,7 +49,7 @@ class HotSpotUpdateMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (three)" in {
|
||||
PacketCoding.DecodePacket(stringThree).require match {
|
||||
PacketCoding.decodePacket(stringThree).require match {
|
||||
case HotSpotUpdateMessage(continent_id, unk, spots) =>
|
||||
continent_id mustEqual 10
|
||||
unk mustEqual 4
|
||||
|
|
@ -64,20 +64,20 @@ class HotSpotUpdateMessageTest extends Specification {
|
|||
|
||||
"encode (clear)" in {
|
||||
val msg = HotSpotUpdateMessage(5, 1, Nil)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual stringClear
|
||||
}
|
||||
|
||||
"encode (one)" in {
|
||||
val msg = HotSpotUpdateMessage(5, 1, List(HotSpotInfo(4700.0f, 2600.0f, 64.0f)))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual stringOne
|
||||
}
|
||||
|
||||
"encode (two)" in {
|
||||
val msg =
|
||||
HotSpotUpdateMessage(5, 5, List(HotSpotInfo(4000.0f, 5400.0f, 64.0f), HotSpotInfo(5500.0f, 2200.0f, 64.0f)))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual stringTwo
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +91,7 @@ class HotSpotUpdateMessageTest extends Specification {
|
|||
HotSpotInfo(4600.0f, 5500.0f, 64.0f)
|
||||
)
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual stringThree
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class InventoryStateMessageTest extends Specification {
|
|||
val string = hex"38 5C0B 00 3C02 B20000000 0"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case InventoryStateMessage(object_guid, unk, inv_guid, value) =>
|
||||
object_guid mustEqual PlanetSideGUID(2908)
|
||||
unk mustEqual 0
|
||||
|
|
@ -24,7 +24,7 @@ class InventoryStateMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = InventoryStateMessage(PlanetSideGUID(2908), 0, PlanetSideGUID(2800), 200)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class ItemTransactionMessageTest extends Specification {
|
|||
val string_forget = hex"44 BA00 600011006861726173736572000000"
|
||||
|
||||
"decode (buy)" in {
|
||||
PacketCoding.DecodePacket(string_buy).require match {
|
||||
PacketCoding.decodePacket(string_buy).require match {
|
||||
case ItemTransactionMessage(terminal_guid, transaction_type, item_page, item_name, unk1, item_guid) =>
|
||||
terminal_guid mustEqual PlanetSideGUID(844)
|
||||
transaction_type mustEqual TransactionType.Buy
|
||||
|
|
@ -27,7 +27,7 @@ class ItemTransactionMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (sell)" in {
|
||||
PacketCoding.DecodePacket(string_sell).require match {
|
||||
PacketCoding.decodePacket(string_sell).require match {
|
||||
case ItemTransactionMessage(terminal_guid, transaction_type, item_page, item_name, unk1, item_guid) =>
|
||||
terminal_guid mustEqual PlanetSideGUID(851)
|
||||
transaction_type mustEqual TransactionType.Sell
|
||||
|
|
@ -41,7 +41,7 @@ class ItemTransactionMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (forget)" in {
|
||||
PacketCoding.DecodePacket(string_forget).require match {
|
||||
PacketCoding.decodePacket(string_forget).require match {
|
||||
case ItemTransactionMessage(terminal_guid, transaction_type, item_page, item_name, unk1, item_guid) =>
|
||||
terminal_guid mustEqual PlanetSideGUID(186)
|
||||
transaction_type mustEqual TransactionType.Sell
|
||||
|
|
@ -56,13 +56,13 @@ class ItemTransactionMessageTest extends Specification {
|
|||
|
||||
"encode (buy)" in {
|
||||
val msg_buy = ItemTransactionMessage(PlanetSideGUID(844), TransactionType.Buy, 0, "punisher", 0, PlanetSideGUID(0))
|
||||
val pkt_buy = PacketCoding.EncodePacket(msg_buy).require.toByteVector
|
||||
val pkt_buy = PacketCoding.encodePacket(msg_buy).require.toByteVector
|
||||
pkt_buy mustEqual string_buy
|
||||
}
|
||||
|
||||
"encode (sell)" in {
|
||||
val msg_sell = ItemTransactionMessage(PlanetSideGUID(851), TransactionType.Sell, 0, "", 0, PlanetSideGUID(78))
|
||||
val pkt_sell = PacketCoding.EncodePacket(msg_sell).require.toByteVector
|
||||
val pkt_sell = PacketCoding.encodePacket(msg_sell).require.toByteVector
|
||||
|
||||
pkt_sell mustEqual string_sell
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ class ItemTransactionMessageTest extends Specification {
|
|||
"encode (forget)" in {
|
||||
val msg_forget =
|
||||
ItemTransactionMessage(PlanetSideGUID(186), TransactionType.Sell, 0, "harasser", 0, PlanetSideGUID(0))
|
||||
val pkt_forget = PacketCoding.EncodePacket(msg_forget).require.toByteVector
|
||||
val pkt_forget = PacketCoding.encodePacket(msg_forget).require.toByteVector
|
||||
|
||||
pkt_forget mustEqual string_forget
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ItemTransactionResultMessageTest extends Specification {
|
|||
val string_request = hex"44 DD 03 40 00 11 40 73 75 70 70 72 65 73 73 6F 72 00 00 00"
|
||||
val string_result = hex"45 DD 03 50 00"
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_result).require match {
|
||||
PacketCoding.decodePacket(string_result).require match {
|
||||
case ItemTransactionResultMessage(terminal_guid, transaction_type, is_success, error_code) =>
|
||||
terminal_guid mustEqual PlanetSideGUID(989)
|
||||
transaction_type mustEqual TransactionType.Buy
|
||||
|
|
@ -25,15 +25,15 @@ class ItemTransactionResultMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ItemTransactionResultMessage(PlanetSideGUID(989), TransactionType.Buy, true, 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_result
|
||||
}
|
||||
|
||||
"proper reply" in {
|
||||
try {
|
||||
val request = PacketCoding.DecodePacket(string_request).require.asInstanceOf[ItemTransactionMessage]
|
||||
val result = PacketCoding.DecodePacket(string_result).require.asInstanceOf[ItemTransactionResultMessage]
|
||||
val request = PacketCoding.decodePacket(string_request).require.asInstanceOf[ItemTransactionMessage]
|
||||
val result = PacketCoding.decodePacket(string_result).require.asInstanceOf[ItemTransactionResultMessage]
|
||||
request.terminal_guid mustEqual result.terminal_guid
|
||||
request.transaction_type mustEqual result.transaction_type
|
||||
} catch {
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class KeepAliveMessageTest extends Specification {
|
|||
val string = hex"BA 0000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case KeepAliveMessage(code) =>
|
||||
code mustEqual 0
|
||||
case _ =>
|
||||
|
|
@ -20,7 +20,7 @@ class KeepAliveMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = KeepAliveMessage()
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class LashMessageTest extends Specification {
|
|||
val string = hex"4f644a82e2c297a738a1ed0b01b886c0"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case LashMessage(seq_time, player, victim, bullet, pos, unk1) =>
|
||||
seq_time mustEqual 356
|
||||
player mustEqual PlanetSideGUID(2858)
|
||||
|
|
@ -33,7 +33,7 @@ class LashMessageTest extends Specification {
|
|||
Vector3(5903.7656f, 3456.5156f, 111.53125f),
|
||||
0
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class LoadMapMessageTest extends Specification {
|
|||
val string = hex"31 85 6D61703130 83 7A3130 0FA0 19000000 F6 F1 60 86 80"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case LoadMapMessage(map_name, nav_map_name, unk1, unk2, weapons_unlocked, unk3) =>
|
||||
map_name mustEqual "map10"
|
||||
nav_map_name mustEqual "z10"
|
||||
|
|
@ -25,7 +25,7 @@ class LoadMapMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = LoadMapMessage("map10", "z10", 40975, 25, true, 230810349)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ class LoginMessageTest extends Specification {
|
|||
|
||||
"LoginMessage" should {
|
||||
"decode (username)" in {
|
||||
PacketCoding.DecodePacket(string_password).require match {
|
||||
PacketCoding.decodePacket(string_password).require match {
|
||||
case LoginMessage(majorVersion, minorVersion, buildDate, username, password, token, revision) =>
|
||||
majorVersion mustEqual 3
|
||||
minorVersion mustEqual 15
|
||||
|
|
@ -28,7 +28,7 @@ class LoginMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (token)" in {
|
||||
PacketCoding.DecodePacket(string_token).require match {
|
||||
PacketCoding.decodePacket(string_token).require match {
|
||||
case LoginMessage(majorVersion, minorVersion, buildDate, username, password, token, revision) =>
|
||||
majorVersion mustEqual 3
|
||||
minorVersion mustEqual 15
|
||||
|
|
@ -52,7 +52,7 @@ class LoginMessageTest extends Specification {
|
|||
None,
|
||||
84
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_password
|
||||
}
|
||||
|
|
@ -68,7 +68,7 @@ class LoginMessageTest extends Specification {
|
|||
Some("AAAABBBBCCCCDDDDEEEEFFFFGGGGHHH"),
|
||||
84
|
||||
)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_token
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class LoginRespMessageTest extends Specification {
|
|||
0
|
||||
)
|
||||
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
||||
|
|
@ -45,12 +45,12 @@ class LoginRespMessageTest extends Specification {
|
|||
10001
|
||||
)
|
||||
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string_priv
|
||||
}
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case LoginRespMessage(token, error, stationError, subscription, unk, username, priv) =>
|
||||
token mustEqual "HaHLdYzs0VASjksR"
|
||||
error mustEqual LoginError.Success
|
||||
|
|
@ -65,7 +65,7 @@ class LoginRespMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode with privilege" in {
|
||||
PacketCoding.DecodePacket(string_priv).require match {
|
||||
PacketCoding.decodePacket(string_priv).require match {
|
||||
case LoginRespMessage(token, error, stationError, subscription, unk, username, priv) =>
|
||||
token mustEqual "HaHLdYzs0VASjksR"
|
||||
error mustEqual LoginError.Success
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class LootItemMessageTest extends Specification {
|
|||
val string = hex"6C DD0D 5C14"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case LootItemMessage(item_guid, target_guid) =>
|
||||
item_guid mustEqual PlanetSideGUID(3549)
|
||||
target_guid mustEqual PlanetSideGUID(5212)
|
||||
|
|
@ -22,7 +22,7 @@ class LootItemMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = LootItemMessage(PlanetSideGUID(3549), PlanetSideGUID(5212))
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
pkt mustEqual string
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class MailMessageTest extends Specification {
|
|||
val string = hex"F1 86466174654A489250726 96F72697479204D61696C2054657374 8E48656C6C6F204175726178697321"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case MailMessage(sender, subject, msg) =>
|
||||
sender mustEqual "FateJH"
|
||||
subject mustEqual "Priority Mail Test"
|
||||
|
|
@ -23,7 +23,7 @@ class MailMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = MailMessage("FateJH", "Priority Mail Test", "Hello Auraxis!")
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class MountVehicleMsgTest extends Specification {
|
|||
val string = hex"0E E104 6704 06"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case MountVehicleMsg(player_guid, vehicle_guid, entry) =>
|
||||
player_guid mustEqual PlanetSideGUID(1249)
|
||||
vehicle_guid mustEqual PlanetSideGUID(1127)
|
||||
|
|
@ -23,7 +23,7 @@ class MountVehicleMsgTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = MountVehicleMsg(PlanetSideGUID(1249), PlanetSideGUID(1127), 6)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class MoveItemMessageTest extends Specification {
|
|||
val string = hex"11 4C00 4B00 4B00 0900 0100"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case MoveItemMessage(item_guid, avatar_guid_1, avatar_guid_2, dest, unk1) =>
|
||||
item_guid mustEqual PlanetSideGUID(76)
|
||||
avatar_guid_1 mustEqual PlanetSideGUID(75)
|
||||
|
|
@ -25,7 +25,7 @@ class MoveItemMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = MoveItemMessage(PlanetSideGUID(76), PlanetSideGUID(75), PlanetSideGUID(75), 9, 1)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ class ObjectAttachMessageTest extends Specification {
|
|||
val stringToCursor = hex"2A 9F05 D405 00FA"
|
||||
|
||||
"decode (inventory 1,1)" in {
|
||||
PacketCoding.DecodePacket(stringToInventory).require match {
|
||||
PacketCoding.decodePacket(stringToInventory).require match {
|
||||
case ObjectAttachMessage(player_guid, item_guid, index) =>
|
||||
player_guid mustEqual PlanetSideGUID(1439)
|
||||
item_guid mustEqual PlanetSideGUID(1492)
|
||||
|
|
@ -23,7 +23,7 @@ class ObjectAttachMessageTest extends Specification {
|
|||
}
|
||||
|
||||
"decode (cursor)" in {
|
||||
PacketCoding.DecodePacket(stringToCursor).require match {
|
||||
PacketCoding.decodePacket(stringToCursor).require match {
|
||||
case ObjectAttachMessage(player_guid, item_guid, index) =>
|
||||
player_guid mustEqual PlanetSideGUID(1439)
|
||||
item_guid mustEqual PlanetSideGUID(1492)
|
||||
|
|
@ -35,14 +35,14 @@ class ObjectAttachMessageTest extends Specification {
|
|||
|
||||
"encode (inventory 1,1)" in {
|
||||
val msg = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 6)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringToInventory
|
||||
}
|
||||
|
||||
"encode (cursor)" in {
|
||||
val msg = ObjectAttachMessage(PlanetSideGUID(1439), PlanetSideGUID(1492), 250)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual stringToCursor
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ class ObjectDeleteMessageTest extends Specification {
|
|||
val string = hex"19 4C00 00"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string).require match {
|
||||
PacketCoding.decodePacket(string).require match {
|
||||
case ObjectDeleteMessage(object_guid, unk1) =>
|
||||
object_guid mustEqual PlanetSideGUID(76)
|
||||
unk1 mustEqual 0
|
||||
|
|
@ -22,7 +22,7 @@ class ObjectDeleteMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ObjectDeleteMessage(PlanetSideGUID(76), 0)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -10,7 +10,7 @@ class ObjectDeployedMessageTest extends Specification {
|
|||
val string_boomer = hex"86 000086626F6F6D6572040000000100000019000000"
|
||||
|
||||
"decode" in {
|
||||
PacketCoding.DecodePacket(string_boomer).require match {
|
||||
PacketCoding.decodePacket(string_boomer).require match {
|
||||
case ObjectDeployedMessage(unk: Int, desc: String, act: DeployOutcome.Value, count: Long, max: Long) =>
|
||||
unk mustEqual 0
|
||||
desc mustEqual "boomer"
|
||||
|
|
@ -24,7 +24,7 @@ class ObjectDeployedMessageTest extends Specification {
|
|||
|
||||
"encode" in {
|
||||
val msg = ObjectDeployedMessage("boomer", DeployOutcome.Success, 1, 25)
|
||||
val pkt = PacketCoding.EncodePacket(msg).require.toByteVector
|
||||
val pkt = PacketCoding.encodePacket(msg).require.toByteVector
|
||||
|
||||
pkt mustEqual string_boomer
|
||||
}
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue