Browse Source

server: Remove unused code

scalafmt-draft
Alexis Hernandez 7 years ago
parent
commit
521d3fa361
  1. 5
      server/conf/evolutions/default/2.sql
  2. 58
      server/test/com/xsn/explorer/data/BalancePostgresDataHandlerSpec.scala

5
server/conf/evolutions/default/2.sql

@ -11,11 +11,6 @@ CREATE TABLE balances(
-- constraints
CONSTRAINT balances_address_pk PRIMARY KEY (address),
CONSTRAINT balances_address_format CHECK (address ~ '[a-zA-Z0-9]{34}$')
-- TODO: useful to add them if we can support them
-- CONSTRAINT balances_available_check CHECK (available = received - spent),
-- CONSTRAINT balances_received_ge_spent_check CHECK (received >= spent),
-- CONSTRAINT balances_received_positive_check CHECK (received >= 0),
-- CONSTRAINT balances_spent_positive_check CHECK (spent >= 0)
);
CREATE INDEX balances_available_index ON balances (available);

58
server/test/com/xsn/explorer/data/BalancePostgresDataHandlerSpec.scala

@ -46,64 +46,6 @@ class BalancePostgresDataHandlerSpec extends PostgresDataHandlerSpec {
val result = dataHandler.upsert(patch)
result mustEqual Good(expected)
}
"allow to set received coins and then, spend them all" in {
pending // TODO: remove it when database checks are enabled
val address = DataHelper.createAddress("XjfNeGJhLgW3egmsZqdbpCNGfysPs7jTNm")
val initialBalance = Balance(address, received = BigDecimal(10))
val patch = Balance(address, spent = BigDecimal(10))
val expected = combine(initialBalance, patch)
dataHandler.upsert(initialBalance).isGood mustEqual true
val result = dataHandler.upsert(patch)
result mustEqual Good(expected)
}
"fail to set received as negative" in {
pending // TODO: remove it when database checks are enabled
val address = DataHelper.createAddress("XdhDFQBfk4E7GE3GVRe4X1bzxiyxRiN2kr")
val balance = Balance(address, received = BigDecimal(-1))
val result = dataHandler.upsert(balance)
println(result)
result.isBad mustEqual true
}
"fail to set spent as negative" in {
pending // TODO: remove it when database checks are enabled
val address = DataHelper.createAddress("Xry2cCLNDMqLmENGW49vYJZPXHPgpqDZ8K")
val balance = Balance(address, spent = BigDecimal(-1))
val result = dataHandler.upsert(balance)
println(result)
result.isBad mustEqual true
}
"fail to set spent > received" in {
pending // TODO: remove it when database checks are enabled
val address = DataHelper.createAddress("XmCEMpTo4r68N7hsmrYhNbfSqSVNJGb6qx")
val balance = Balance(address, received = BigDecimal(9), spent = BigDecimal(10))
val result = dataHandler.upsert(balance)
println(result)
result.isBad mustEqual true
}
"fail to set go negative on received" in {
pending // TODO: remove it when database checks are enabled
val address = DataHelper.createAddress("XauduFtKWMNZaPxqruayxp3S1kj9rvDxjN")
val initialBalance = Balance(address, received = BigDecimal(10))
val patch = Balance(address, spent = BigDecimal(11))
dataHandler.upsert(initialBalance)
val result = dataHandler.upsert(patch)
println(result)
result.isBad mustEqual true
}
}
private def combine(balances: Balance*): Balance = {

Loading…
Cancel
Save