Browse Source

server: Update the data package to use the Block from the persisted package

master
Alexis Hernandez 6 years ago
parent
commit
2dd9b4837a
  1. 2
      server/app/com/xsn/explorer/data/BlockDataHandler.scala
  2. 2
      server/app/com/xsn/explorer/data/LedgerDataHandler.scala
  3. 2
      server/app/com/xsn/explorer/data/anorm/BlockPostgresDataHandler.scala
  4. 2
      server/app/com/xsn/explorer/data/anorm/LedgerPostgresDataHandler.scala
  5. 2
      server/app/com/xsn/explorer/data/anorm/dao/BlockPostgresDAO.scala
  6. 6
      server/app/com/xsn/explorer/data/anorm/parsers/BlockParsers.scala
  7. 2
      server/app/com/xsn/explorer/data/async/BlockFutureDataHandler.scala
  8. 2
      server/app/com/xsn/explorer/data/async/LedgerFutureDataHandler.scala
  9. 8
      server/app/com/xsn/explorer/services/LedgerSynchronizerService.scala
  10. 2
      server/test/com/xsn/explorer/data/BlockPostgresDataHandlerSpec.scala
  11. 22
      server/test/com/xsn/explorer/data/LedgerPostgresDataHandlerSpec.scala
  12. 14
      server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala
  13. 27
      server/test/com/xsn/explorer/helpers/BlockLoader.scala
  14. 13
      server/test/com/xsn/explorer/helpers/Converters.scala
  15. 2
      server/test/com/xsn/explorer/helpers/FileBasedXSNService.scala
  16. 24
      server/test/com/xsn/explorer/helpers/LedgerHelper.scala
  17. 11
      server/test/com/xsn/explorer/services/LedgerSynchronizerServiceSpec.scala
  18. 14
      server/test/controllers/BlocksControllerSpec.scala

2
server/app/com/xsn/explorer/data/BlockDataHandler.scala

@ -4,7 +4,7 @@ import com.alexitc.playsonify.core.ApplicationResult
import com.alexitc.playsonify.models.ordering.FieldOrdering import com.alexitc.playsonify.models.ordering.FieldOrdering
import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult} import com.alexitc.playsonify.models.pagination.{PaginatedQuery, PaginatedResult}
import com.xsn.explorer.models.fields.BlockField import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import com.xsn.explorer.models.{Blockhash, Height} import com.xsn.explorer.models.{Blockhash, Height}
import scala.language.higherKinds import scala.language.higherKinds

2
server/app/com/xsn/explorer/data/LedgerDataHandler.scala

@ -2,7 +2,7 @@ package com.xsn.explorer.data
import com.alexitc.playsonify.core.ApplicationResult import com.alexitc.playsonify.core.ApplicationResult
import com.xsn.explorer.models.Transaction import com.xsn.explorer.models.Transaction
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import scala.language.higherKinds import scala.language.higherKinds

2
server/app/com/xsn/explorer/data/anorm/BlockPostgresDataHandler.scala

@ -7,7 +7,7 @@ import com.xsn.explorer.data.BlockBlockingDataHandler
import com.xsn.explorer.data.anorm.dao.BlockPostgresDAO import com.xsn.explorer.data.anorm.dao.BlockPostgresDAO
import com.xsn.explorer.errors._ import com.xsn.explorer.errors._
import com.xsn.explorer.models.fields.BlockField import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import com.xsn.explorer.models.{Blockhash, Height} import com.xsn.explorer.models.{Blockhash, Height}
import javax.inject.Inject import javax.inject.Inject
import org.scalactic.{Good, One, Or} import org.scalactic.{Good, One, Or}

2
server/app/com/xsn/explorer/data/anorm/LedgerPostgresDataHandler.scala

@ -7,7 +7,7 @@ import com.alexitc.playsonify.models.ApplicationError
import com.xsn.explorer.data.LedgerBlockingDataHandler import com.xsn.explorer.data.LedgerBlockingDataHandler
import com.xsn.explorer.data.anorm.dao.{AggregatedAmountPostgresDAO, BalancePostgresDAO, BlockPostgresDAO, TransactionPostgresDAO} import com.xsn.explorer.data.anorm.dao.{AggregatedAmountPostgresDAO, BalancePostgresDAO, BlockPostgresDAO, TransactionPostgresDAO}
import com.xsn.explorer.errors.{PostgresForeignKeyViolationError, PreviousBlockMissingError, RepeatedBlockHeightError} import com.xsn.explorer.errors.{PostgresForeignKeyViolationError, PreviousBlockMissingError, RepeatedBlockHeightError}
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import com.xsn.explorer.models.{Address, Balance, Transaction} import com.xsn.explorer.models.{Address, Balance, Transaction}
import com.xsn.explorer.util.Extensions.ListOptionExt import com.xsn.explorer.util.Extensions.ListOptionExt
import javax.inject.Inject import javax.inject.Inject

2
server/app/com/xsn/explorer/data/anorm/dao/BlockPostgresDAO.scala

@ -8,7 +8,7 @@ import com.alexitc.playsonify.models.pagination.{Count, Limit, Offset, Paginated
import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter import com.alexitc.playsonify.sql.FieldOrderingSQLInterpreter
import com.xsn.explorer.data.anorm.parsers.BlockParsers._ import com.xsn.explorer.data.anorm.parsers.BlockParsers._
import com.xsn.explorer.models.fields.BlockField import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import com.xsn.explorer.models.{Blockhash, Height} import com.xsn.explorer.models.{Blockhash, Height}
import javax.inject.Inject import javax.inject.Inject

6
server/app/com/xsn/explorer/data/anorm/parsers/BlockParsers.scala

@ -3,7 +3,7 @@ package com.xsn.explorer.data.anorm.parsers
import anorm.SqlParser._ import anorm.SqlParser._
import anorm._ import anorm._
import com.xsn.explorer.models._ import com.xsn.explorer.models._
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
object BlockParsers { object BlockParsers {
@ -79,9 +79,7 @@ object BlockParsers {
bits = bits, bits = bits,
chainwork = chainwork, chainwork = chainwork,
difficulty = difficulty, difficulty = difficulty,
version = version, version = version
transactions = List.empty,
confirmations = Confirmations(0)
) )
} }
} }

2
server/app/com/xsn/explorer/data/async/BlockFutureDataHandler.scala

@ -6,7 +6,7 @@ import com.alexitc.playsonify.models.pagination.PaginatedQuery
import com.xsn.explorer.data.{BlockBlockingDataHandler, BlockDataHandler} import com.xsn.explorer.data.{BlockBlockingDataHandler, BlockDataHandler}
import com.xsn.explorer.executors.DatabaseExecutionContext import com.xsn.explorer.executors.DatabaseExecutionContext
import com.xsn.explorer.models.fields.BlockField import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import com.xsn.explorer.models.{Blockhash, Height} import com.xsn.explorer.models.{Blockhash, Height}
import javax.inject.Inject import javax.inject.Inject

2
server/app/com/xsn/explorer/data/async/LedgerFutureDataHandler.scala

@ -6,7 +6,7 @@ import com.alexitc.playsonify.core.FutureApplicationResult
import com.xsn.explorer.data.{LedgerBlockingDataHandler, LedgerDataHandler} import com.xsn.explorer.data.{LedgerBlockingDataHandler, LedgerDataHandler}
import com.xsn.explorer.executors.DatabaseExecutionContext import com.xsn.explorer.executors.DatabaseExecutionContext
import com.xsn.explorer.models.Transaction import com.xsn.explorer.models.Transaction
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import scala.concurrent.Future import scala.concurrent.Future

8
server/app/com/xsn/explorer/services/LedgerSynchronizerService.scala

@ -4,9 +4,10 @@ import com.alexitc.playsonify.core.FutureApplicationResult
import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureOps, OptionOps} import com.alexitc.playsonify.core.FutureOr.Implicits.{FutureOps, OptionOps}
import com.xsn.explorer.data.async.{BlockFutureDataHandler, LedgerFutureDataHandler} import com.xsn.explorer.data.async.{BlockFutureDataHandler, LedgerFutureDataHandler}
import com.xsn.explorer.errors.BlockNotFoundError import com.xsn.explorer.errors.BlockNotFoundError
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import com.xsn.explorer.models.{Blockhash, Height, Transaction} import com.xsn.explorer.models.{Blockhash, Height, Transaction}
import com.xsn.explorer.util.Extensions.FutureOrExt import com.xsn.explorer.util.Extensions.FutureOrExt
import io.scalaland.chimney.dsl._
import javax.inject.Inject import javax.inject.Inject
import org.scalactic.Good import org.scalactic.Good
import org.slf4j.LoggerFactory import org.slf4j.LoggerFactory
@ -159,8 +160,9 @@ class LedgerSynchronizerService @Inject() (
private def getRPCBlock(blockhash: Blockhash): FutureApplicationResult[(Block, List[Transaction])] = { private def getRPCBlock(blockhash: Blockhash): FutureApplicationResult[(Block, List[Transaction])] = {
val result = for { val result = for {
block <- xsnService.getBlock(blockhash).toFutureOr rpcBlock <- xsnService.getBlock(blockhash).toFutureOr
transactions <- transactionRPCService.getTransactions(block.transactions).toFutureOr transactions <- transactionRPCService.getTransactions(rpcBlock.transactions).toFutureOr
block = rpcBlock.into[Block].transform
} yield (block, transactions) } yield (block, transactions)
result.toFuture result.toFuture

2
server/test/com/xsn/explorer/data/BlockPostgresDataHandlerSpec.scala

@ -10,7 +10,7 @@ import com.xsn.explorer.errors.BlockNotFoundError
import com.xsn.explorer.helpers.BlockLoader import com.xsn.explorer.helpers.BlockLoader
import com.xsn.explorer.models.Blockhash import com.xsn.explorer.models.Blockhash
import com.xsn.explorer.models.fields.BlockField import com.xsn.explorer.models.fields.BlockField
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.persisted.Block
import org.scalactic.{Bad, One, Or} import org.scalactic.{Bad, One, Or}
import org.scalatest.BeforeAndAfter import org.scalatest.BeforeAndAfter

22
server/test/com/xsn/explorer/data/LedgerPostgresDataHandlerSpec.scala

@ -2,10 +2,9 @@ package com.xsn.explorer.data
import com.xsn.explorer.data.common.PostgresDataHandlerSpec import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.errors.{PreviousBlockMissingError, RepeatedBlockHeightError} import com.xsn.explorer.errors.{PreviousBlockMissingError, RepeatedBlockHeightError}
import com.xsn.explorer.helpers.Converters._
import com.xsn.explorer.helpers.DataHandlerObjects._ import com.xsn.explorer.helpers.DataHandlerObjects._
import com.xsn.explorer.helpers.{BlockLoader, TransactionLoader} import com.xsn.explorer.helpers.LedgerHelper._
import com.xsn.explorer.models.Transaction
import com.xsn.explorer.models.rpc.Block
import org.scalactic.{Bad, Good} import org.scalactic.{Bad, Good}
import org.scalatest.BeforeAndAfter import org.scalatest.BeforeAndAfter
@ -13,15 +12,6 @@ class LedgerPostgresDataHandlerSpec extends PostgresDataHandlerSpec with BeforeA
lazy val dataHandler = createLedgerDataHandler(database) lazy val dataHandler = createLedgerDataHandler(database)
val blockList = List(
BlockLoader.get("00000c822abdbb23e28f79a49d29b41429737c6c7e15df40d1b1f1b35907ae34"),
BlockLoader.get("000003fb382f6892ae96594b81aa916a8923c70701de4e7054aac556c7271ef7"),
BlockLoader.get("000004645e2717b556682e3c642a4c6e473bf25c653ff8e8c114a3006040ffb8"),
BlockLoader.get("00000766115b26ecbc09cd3a3db6870fdaf2f049d65a910eb2f2b48b566ca7bd"),
BlockLoader.get("00000b59875e80b0afc6c657bc5318d39e03532b7d97fb78a4c7bd55c4840c32"),
BlockLoader.get("00000267225f7dba55d9a3493740e7f0dde0f28a371d2c3b42e7676b5728d020")
)
before { before {
clearDatabase() clearDatabase()
} }
@ -80,12 +70,4 @@ class LedgerPostgresDataHandlerSpec extends PostgresDataHandlerSpec with BeforeA
} }
} }
} }
private def getTransactions(block: Block) = {
block
.transactions
.map(_.string)
.map(TransactionLoader.get)
.map(Transaction.fromRPC)
}
} }

14
server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala

@ -4,9 +4,10 @@ import com.alexitc.playsonify.models.ordering.{FieldOrdering, OrderingCondition}
import com.alexitc.playsonify.models.pagination._ import com.alexitc.playsonify.models.pagination._
import com.xsn.explorer.data.common.PostgresDataHandlerSpec import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.errors.{BlockNotFoundError, TransactionNotFoundError} import com.xsn.explorer.errors.{BlockNotFoundError, TransactionNotFoundError}
import com.xsn.explorer.helpers.Converters._
import com.xsn.explorer.helpers.DataHandlerObjects._ import com.xsn.explorer.helpers.DataHandlerObjects._
import com.xsn.explorer.helpers.DataHelper._ import com.xsn.explorer.helpers.DataHelper._
import com.xsn.explorer.helpers.{BlockLoader, DataGenerator, TransactionLoader} import com.xsn.explorer.helpers.{DataGenerator, LedgerHelper, TransactionLoader}
import com.xsn.explorer.models._ import com.xsn.explorer.models._
import com.xsn.explorer.models.fields.TransactionField import com.xsn.explorer.models.fields.TransactionField
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.rpc.Block
@ -23,16 +24,9 @@ class TransactionPostgresDataHandlerSpec extends PostgresDataHandlerSpec with Be
val defaultOrdering = FieldOrdering(TransactionField.Time, OrderingCondition.DescendingOrder) val defaultOrdering = FieldOrdering(TransactionField.Time, OrderingCondition.DescendingOrder)
val block = DataGenerator.randomBlock() val blockList = LedgerHelper.blockList.take(6)
val blockList = List( val block = DataGenerator.randomBlock()
BlockLoader.get("00000c822abdbb23e28f79a49d29b41429737c6c7e15df40d1b1f1b35907ae34"),
BlockLoader.get("000003fb382f6892ae96594b81aa916a8923c70701de4e7054aac556c7271ef7"),
BlockLoader.get("000004645e2717b556682e3c642a4c6e473bf25c653ff8e8c114a3006040ffb8"),
BlockLoader.get("00000766115b26ecbc09cd3a3db6870fdaf2f049d65a910eb2f2b48b566ca7bd"),
BlockLoader.get("00000b59875e80b0afc6c657bc5318d39e03532b7d97fb78a4c7bd55c4840c32"),
BlockLoader.get("00000267225f7dba55d9a3493740e7f0dde0f28a371d2c3b42e7676b5728d020")
)
val dummyTransaction = randomTransaction(blockhash = block.hash, utxos = List.empty) val dummyTransaction = randomTransaction(blockhash = block.hash, utxos = List.empty)

27
server/test/com/xsn/explorer/helpers/BlockLoader.scala

@ -2,17 +2,23 @@ package com.xsn.explorer.helpers
import java.io.File import java.io.File
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models._
import com.xsn.explorer.models.{Blockhash, rpc} import io.scalaland.chimney.dsl._
import play.api.libs.json.{JsValue, Json} import play.api.libs.json.{JsValue, Json}
object BlockLoader { object BlockLoader {
private val BasePath = "blocks" private val BasePath = "blocks"
def get(blockhash: String): Block = { def get(blockhash: String): persisted.Block = {
val block = json(blockhash).as[Block] val rpcBlock = getRPC(blockhash)
cleanGenesisBlock(block)
rpcBlock.into[persisted.Block].transform
}
def getRPC(blockhash: String): rpc.Block = {
val partial = json(blockhash).as[rpc.Block]
cleanGenesisBlock(partial)
} }
def json(blockhash: String): JsValue = { def json(blockhash: String): JsValue = {
@ -21,17 +27,22 @@ object BlockLoader {
val json = scala.io.Source.fromResource(resource).getLines().mkString("\n") val json = scala.io.Source.fromResource(resource).getLines().mkString("\n")
Json.parse(json) Json.parse(json)
} catch { } catch {
case _ => throw new RuntimeException(s"Block $blockhash not found") case _: Throwable => throw new RuntimeException(s"Block $blockhash not found")
} }
} }
def all(): List[Block] = { def all(): List[persisted.Block] = {
allRPC()
.map(_.into[persisted.Block].transform)
}
def allRPC(): List[rpc.Block] = {
val uri = getClass.getResource(s"/$BasePath") val uri = getClass.getResource(s"/$BasePath")
new File(uri.getPath) new File(uri.getPath)
.listFiles() .listFiles()
.toList .toList
.map(_.getName) .map(_.getName)
.map(get) .map(getRPC)
} }
def cleanGenesisBlock(block: rpc.Block): rpc.Block = { def cleanGenesisBlock(block: rpc.Block): rpc.Block = {

13
server/test/com/xsn/explorer/helpers/Converters.scala

@ -0,0 +1,13 @@
package com.xsn.explorer.helpers
import com.xsn.explorer.models._
import io.scalaland.chimney.dsl._
import scala.language.implicitConversions
object Converters {
implicit def toPersistedBlock(rpcBlock: rpc.Block): persisted.Block = {
rpcBlock.into[persisted.Block].transform
}
}

2
server/test/com/xsn/explorer/helpers/FileBasedXSNService.scala

@ -11,7 +11,7 @@ import scala.concurrent.Future
class FileBasedXSNService extends DummyXSNService { class FileBasedXSNService extends DummyXSNService {
private lazy val blockMap = BlockLoader.all().map { block => block.hash -> block }.toMap private lazy val blockMap = BlockLoader.allRPC().map { block => block.hash -> block }.toMap
private lazy val transactionMap = TransactionLoader.all().map { tx => tx.id -> tx }.toMap private lazy val transactionMap = TransactionLoader.all().map { tx => tx.id -> tx }.toMap
override def getBlock(blockhash: Blockhash): FutureApplicationResult[Block] = { override def getBlock(blockhash: Blockhash): FutureApplicationResult[Block] = {

24
server/test/com/xsn/explorer/helpers/LedgerHelper.scala

@ -0,0 +1,24 @@
package com.xsn.explorer.helpers
import com.xsn.explorer.models._
object LedgerHelper {
val blockList = List(
BlockLoader.getRPC("00000c822abdbb23e28f79a49d29b41429737c6c7e15df40d1b1f1b35907ae34"),
BlockLoader.getRPC("000003fb382f6892ae96594b81aa916a8923c70701de4e7054aac556c7271ef7"),
BlockLoader.getRPC("000004645e2717b556682e3c642a4c6e473bf25c653ff8e8c114a3006040ffb8"),
BlockLoader.getRPC("00000766115b26ecbc09cd3a3db6870fdaf2f049d65a910eb2f2b48b566ca7bd"),
BlockLoader.getRPC("00000b59875e80b0afc6c657bc5318d39e03532b7d97fb78a4c7bd55c4840c32"),
BlockLoader.getRPC("00000267225f7dba55d9a3493740e7f0dde0f28a371d2c3b42e7676b5728d020"),
BlockLoader.getRPC("0000017ee4121cd8ae22f7321041ccb953d53828824217a9dc61a1c857facf85")
)
def getTransactions(block: rpc.Block): List[Transaction] = {
block
.transactions
.map(_.string)
.map(TransactionLoader.get)
.map(Transaction.fromRPC)
}
}

11
server/test/com/xsn/explorer/services/LedgerSynchronizerServiceSpec.scala

@ -6,6 +6,7 @@ import com.xsn.explorer.data.async.{BlockFutureDataHandler, LedgerFutureDataHand
import com.xsn.explorer.data.common.PostgresDataHandlerSpec import com.xsn.explorer.data.common.PostgresDataHandlerSpec
import com.xsn.explorer.errors.BlockNotFoundError import com.xsn.explorer.errors.BlockNotFoundError
import com.xsn.explorer.helpers.DataHandlerObjects._ import com.xsn.explorer.helpers.DataHandlerObjects._
import com.xsn.explorer.helpers.LedgerHelper._
import com.xsn.explorer.helpers._ import com.xsn.explorer.helpers._
import com.xsn.explorer.models.rpc.Block import com.xsn.explorer.models.rpc.Block
import com.xsn.explorer.models.{Blockhash, Height} import com.xsn.explorer.models.{Blockhash, Height}
@ -22,16 +23,6 @@ class LedgerSynchronizerServiceSpec extends PostgresDataHandlerSpec with BeforeA
lazy val transactionDataHandler = createTransactionDataHandler(database) lazy val transactionDataHandler = createTransactionDataHandler(database)
lazy val blockDataHandler = createBlockDataHandler(database) lazy val blockDataHandler = createBlockDataHandler(database)
val blockList = List(
BlockLoader.get("00000c822abdbb23e28f79a49d29b41429737c6c7e15df40d1b1f1b35907ae34"),
BlockLoader.get("000003fb382f6892ae96594b81aa916a8923c70701de4e7054aac556c7271ef7"),
BlockLoader.get("000004645e2717b556682e3c642a4c6e473bf25c653ff8e8c114a3006040ffb8"),
BlockLoader.get("00000766115b26ecbc09cd3a3db6870fdaf2f049d65a910eb2f2b48b566ca7bd"),
BlockLoader.get("00000b59875e80b0afc6c657bc5318d39e03532b7d97fb78a4c7bd55c4840c32"),
BlockLoader.get("00000267225f7dba55d9a3493740e7f0dde0f28a371d2c3b42e7676b5728d020"),
BlockLoader.get("0000017ee4121cd8ae22f7321041ccb953d53828824217a9dc61a1c857facf85")
)
val genesis = blockList(0) val genesis = blockList(0)
before { before {

14
server/test/controllers/BlocksControllerSpec.scala

@ -19,7 +19,7 @@ import play.api.test.Helpers._
class BlocksControllerSpec extends MyAPISpec { class BlocksControllerSpec extends MyAPISpec {
// PoS block // PoS block
val posBlock = BlockLoader.get("1ca318b7a26ed67ca7c8c9b5069d653ba224bf86989125d1dfbb0973b7d6a5e0") val posBlock = BlockLoader.getRPC("1ca318b7a26ed67ca7c8c9b5069d653ba224bf86989125d1dfbb0973b7d6a5e0")
val customXSNService = new FileBasedXSNService val customXSNService = new FileBasedXSNService
@ -27,7 +27,7 @@ class BlocksControllerSpec extends MyAPISpec {
// TODO: Handle ordering // TODO: Handle ordering
override def getByBlockhash(blockhash: Blockhash, paginatedQuery: PaginatedQuery, ordering: FieldOrdering[TransactionField]): ApplicationResult[PaginatedResult[TransactionWithValues]] = { override def getByBlockhash(blockhash: Blockhash, paginatedQuery: PaginatedQuery, ordering: FieldOrdering[TransactionField]): ApplicationResult[PaginatedResult[TransactionWithValues]] = {
val transactions = BlockLoader val transactions = BlockLoader
.get(blockhash.string) .getRPC(blockhash.string)
.transactions .transactions
.map(_.string) .map(_.string)
.map(TransactionLoader.get) .map(TransactionLoader.get)
@ -82,7 +82,7 @@ class BlocksControllerSpec extends MyAPISpec {
} }
"retrieve a PoS block having a rounding error" in { "retrieve a PoS block having a rounding error" in {
val posBlockRoundingError = BlockLoader.get("25762bf01143f7fe34912c926e0b95528b082c6323de35516de0fc321f5d8058") val posBlockRoundingError = BlockLoader.getRPC("25762bf01143f7fe34912c926e0b95528b082c6323de35516de0fc321f5d8058")
val block = posBlockRoundingError val block = posBlockRoundingError
val response = GET(url(block.hash.string)) val response = GET(url(block.hash.string))
@ -103,7 +103,7 @@ class BlocksControllerSpec extends MyAPISpec {
} }
"retrieve a PoW block" in { "retrieve a PoW block" in {
val powBlock = BlockLoader.get("000004645e2717b556682e3c642a4c6e473bf25c653ff8e8c114a3006040ffb8") val powBlock = BlockLoader.getRPC("000004645e2717b556682e3c642a4c6e473bf25c653ff8e8c114a3006040ffb8")
val block = powBlock val block = powBlock
val response = GET(url(block.hash.string)) val response = GET(url(block.hash.string))
@ -121,7 +121,7 @@ class BlocksControllerSpec extends MyAPISpec {
} }
"retrieve TPoS block" in { "retrieve TPoS block" in {
val tposBlock = BlockLoader.get("19f320185015d146237efe757852b21c5e08b88b2f4de9d3fa9517d8463e472b") val tposBlock = BlockLoader.getRPC("19f320185015d146237efe757852b21c5e08b88b2f4de9d3fa9517d8463e472b")
val block = tposBlock val block = tposBlock
val response = GET(url(block.hash.string)) val response = GET(url(block.hash.string))
@ -147,7 +147,7 @@ class BlocksControllerSpec extends MyAPISpec {
} }
"retrieve TPoS block with coinsplit" in { "retrieve TPoS block with coinsplit" in {
val tposBlock2 = BlockLoader.get("a3a9fb111a3f85c3d920c2dc58ce14d541a65763834247ef958aa3b4d665ef9c") val tposBlock2 = BlockLoader.getRPC("a3a9fb111a3f85c3d920c2dc58ce14d541a65763834247ef958aa3b4d665ef9c")
val block = tposBlock2 val block = tposBlock2
val response = GET(url(block.hash.string)) val response = GET(url(block.hash.string))
@ -173,7 +173,7 @@ class BlocksControllerSpec extends MyAPISpec {
} }
"retrieve the genesis block" in { "retrieve the genesis block" in {
val block = BlockLoader.get("00000c822abdbb23e28f79a49d29b41429737c6c7e15df40d1b1f1b35907ae34") val block = BlockLoader.getRPC("00000c822abdbb23e28f79a49d29b41429737c6c7e15df40d1b1f1b35907ae34")
val response = GET(url(block.hash.string)) val response = GET(url(block.hash.string))
status(response) mustEqual OK status(response) mustEqual OK

Loading…
Cancel
Save