Browse Source

server: Allow storing empty addresses on transaction inputs/outputs

bitcoin
Alexis Hernandez 6 years ago
parent
commit
149601dda7
  1. 2
      server/app/com/xsn/explorer/data/anorm/dao/TransactionInputPostgresDAO.scala
  2. 2
      server/app/com/xsn/explorer/data/anorm/dao/TransactionOutputPostgresDAO.scala
  3. 13
      server/test/com/xsn/explorer/data/TransactionPostgresDataHandlerSpec.scala

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

@ -35,7 +35,7 @@ class TransactionInputPostgresDAO {
|INSERT INTO transaction_inputs
| (txid, index, from_txid, from_output_index, value, addresses)
|VALUES
| ({txid}, {index}, {from_txid}, {from_output_index}, {value}, ARRAY[{addresses}])
| ({txid}, {index}, {from_txid}, {from_output_index}, {value}, ARRAY[{addresses}]::TEXT[])
""".stripMargin,
params.head,
params.tail: _*

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

@ -61,7 +61,7 @@ class TransactionOutputPostgresDAO {
|INSERT INTO transaction_outputs
| (txid, index, value, addresses, hex_script)
|VALUES
| ({txid}, {index}, {value}, ARRAY[{addresses}], {hex_script})
| ({txid}, {index}, {value}, ARRAY[{addresses}]::TEXT[], {hex_script})
""".stripMargin,
params.head,
params.tail: _*

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

@ -52,6 +52,19 @@ class TransactionPostgresDataHandlerSpec extends PostgresDataHandlerSpec with Be
result mustEqual Good(expected)
}
"find no results - no address involved" in {
val tx = transaction.copy(
inputs = transaction.inputs.map(_.copy(addresses = List.empty)),
outputs = transaction.outputs.map(_.copy(addresses = List.empty))
)
upsertTransaction(tx)
val expected = PaginatedResult(query.offset, query.limit, Count(0), List.empty)
val result = dataHandler.getBy(randomAddress, query, defaultOrdering)
result mustEqual Good(expected)
}
"find the right values" in {
upsertTransaction(transaction)

Loading…
Cancel
Save