|
|
@ -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 = { |
|
|
|