|
@ -3,8 +3,11 @@ package com.xsn.explorer.data |
|
|
import com.xsn.explorer.data.anorm.BlockPostgresDataHandler |
|
|
import com.xsn.explorer.data.anorm.BlockPostgresDataHandler |
|
|
import com.xsn.explorer.data.anorm.dao.BlockPostgresDAO |
|
|
import com.xsn.explorer.data.anorm.dao.BlockPostgresDAO |
|
|
import com.xsn.explorer.data.common.PostgresDataHandlerSpec |
|
|
import com.xsn.explorer.data.common.PostgresDataHandlerSpec |
|
|
|
|
|
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.rpc.Block |
|
|
import com.xsn.explorer.models.rpc.Block |
|
|
|
|
|
import org.scalactic.Bad |
|
|
|
|
|
|
|
|
class BlockPostgresDataHandlerSpec extends PostgresDataHandlerSpec { |
|
|
class BlockPostgresDataHandlerSpec extends PostgresDataHandlerSpec { |
|
|
|
|
|
|
|
@ -32,6 +35,25 @@ class BlockPostgresDataHandlerSpec extends PostgresDataHandlerSpec { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
"getBy" should { |
|
|
|
|
|
"return a block" in { |
|
|
|
|
|
val block = BlockLoader.get("1ca318b7a26ed67ca7c8c9b5069d653ba224bf86989125d1dfbb0973b7d6a5e0") |
|
|
|
|
|
|
|
|
|
|
|
dataHandler.create(block) |
|
|
|
|
|
|
|
|
|
|
|
val result = dataHandler.getBy(block.hash) |
|
|
|
|
|
result.isGood mustEqual true |
|
|
|
|
|
matches(block, result.get) |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
"fail on block not found" in { |
|
|
|
|
|
val blockhash = Blockhash.from("b858d38a3552c83aea58f66fe00ae220352a235e33fcf1f3af04507a61a9dc32").get |
|
|
|
|
|
|
|
|
|
|
|
val result = dataHandler.getBy(blockhash) |
|
|
|
|
|
result mustEqual Bad(BlockNotFoundError).accumulating |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
private def matches(expected: Block, result: Block) = { |
|
|
private def matches(expected: Block, result: Block) = { |
|
|
// NOTE: transactions and confirmations are not matched intentionally |
|
|
// NOTE: transactions and confirmations are not matched intentionally |
|
|
result.hash mustEqual expected.hash |
|
|
result.hash mustEqual expected.hash |
|
|