PSF-BotServer/common/src/test/scala/game/ItemTransactionResultMessageTest.scala
Jakob Gillich e0defe8240
Persistence #1 featuring quill (#508)
* Add .scalafmt.conf

* Adopt quill for database access

* Removed postgresql-async
* Refactored all instances of database access
* Creating duplicate characters of the same account is no longer possible
* Rewrote large parts of LoginSessionActor

* Implement migrations

* Move overrides into subdirectory

* Make usernames case insensitive

* Use LOWER(?) comparison instead of storing lowercased username

* import scala.util.{Success, Failure}

* Add config and joda-time dependencies

* Add sbt-scalafmt

* Use defaultWithAlign scalafmt preset

* Format all

* Add scalafix

* Remove unused imports

* Don't lowercase username when inserting

* Update readme

* Listen on worldserver.Hostname address

* Remove database test on startup

It could fail when the global thread pool is busy loading zone
maps. Migrations run on the main thread and also serve the
purpose of verifying the database configuration so it's fine to
remove the test altogether.

* Refactor chat message handlers, zones

What started as a small change to how zones are stored turned
into a pretty big effort of refactoring the chat message handler.
The !hack command was removed, the /capturebase commandwas added.

* Expose db ports in docker-compose.yml

* Silence property override log

* Rework configuration

* Unify configuration using the typesafe.config library
* Add configuration option for public address
* Configuration is now loaded from application.conf rather than worldserver.ini
* Refactor PsLogin and remove unnecessary logging
* Move pslogin into net.psforever.pslogin namespace

* Fix coverage
2020-07-13 23:54:05 -04:00

44 lines
1.5 KiB
Scala

// Copyright (c) 2017 PSForever
package game
import org.specs2.mutable._
import net.psforever.packet._
import net.psforever.packet.game._
import net.psforever.types.{PlanetSideGUID, TransactionType}
import scodec.bits._
class ItemTransactionResultMessageTest extends Specification {
//these are paried packets come from the same capture
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 {
case ItemTransactionResultMessage(terminal_guid, transaction_type, is_success, error_code) =>
terminal_guid mustEqual PlanetSideGUID(989)
transaction_type mustEqual TransactionType.Buy
is_success mustEqual true
error_code mustEqual 0
case default =>
ko
}
}
"encode" in {
val msg = ItemTransactionResultMessage(PlanetSideGUID(989), TransactionType.Buy, true, 0)
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]
request.terminal_guid mustEqual result.terminal_guid
request.transaction_type mustEqual result.transaction_type
} catch {
case e: Exception =>
ko
}
}
}