Fix cash spending tests in perftestcordapp module.

This commit is contained in:
josecoll 2017-11-19 11:28:23 +00:00
parent b71c1a8744
commit 960d9010f6
4 changed files with 10 additions and 13 deletions

View File

@ -131,17 +131,19 @@ abstract class AbstractCashSelection {
stateAndRefs.clear() stateAndRefs.clear()
var totalPennies = 0L var totalPennies = 0L
val stateRefs = mutableSetOf<StateRef>()
while (rs.next()) { while (rs.next()) {
val txHash = SecureHash.parse(rs.getString(1)) val txHash = SecureHash.parse(rs.getString(1))
val index = rs.getInt(2) val index = rs.getInt(2)
val stateRef = StateRef(txHash, index) val pennies = rs.getLong(3)
val state = rs.getBlob(3).deserialize<TransactionState<Cash.State>>(context = SerializationDefaults.STORAGE_CONTEXT) totalPennies = rs.getLong(4)
val pennies = rs.getLong(4) val rowLockId = rs.getString(5)
totalPennies = rs.getLong(5) stateRefs.add(StateRef(txHash, index))
val rowLockId = rs.getString(6) log.trace { "ROW: $rowLockId ($lockId): ${StateRef(txHash, index)} : $pennies ($totalPennies)" }
stateAndRefs.add(StateAndRef(state, stateRef))
log.trace { "ROW: $rowLockId ($lockId): $stateRef : $pennies ($totalPennies)" }
} }
if (stateRefs.isNotEmpty())
// TODO: future implementation to retrieve contract states from a Vault BLOB store
stateAndRefs.addAll(services.loadStates(stateRefs) as Collection<StateAndRef<Cash.State>>)
if (stateAndRefs.isNotEmpty() && totalPennies >= amount.quantity) { if (stateAndRefs.isNotEmpty() && totalPennies >= amount.quantity) {
// we should have a minimum number of states to satisfy our selection `amount` criteria // we should have a minimum number of states to satisfy our selection `amount` criteria

View File

@ -34,7 +34,7 @@ class CashSelectionH2Impl : AbstractCashSelection() {
connection.createStatement().execute("CALL SET(@t, 0);") connection.createStatement().execute("CALL SET(@t, 0);")
val selectJoin = """ val selectJoin = """
SELECT vs.transaction_id, vs.output_index, vs.contract_state, ccs.pennies, SET(@t, ifnull(@t,0)+ccs.pennies) total_pennies, vs.lock_id SELECT vs.transaction_id, vs.output_index, ccs.pennies, SET(@t, ifnull(@t,0)+ccs.pennies) total_pennies, vs.lock_id
FROM vault_states AS vs, contract_pt_cash_states AS ccs FROM vault_states AS vs, contract_pt_cash_states AS ccs
WHERE vs.transaction_id = ccs.transaction_id AND vs.output_index = ccs.output_index WHERE vs.transaction_id = ccs.transaction_id AND vs.output_index = ccs.output_index
AND vs.state_status = 0 AND vs.state_status = 0

View File

@ -6,7 +6,6 @@ import com.r3.corda.enterprise.perftestcordapp.contracts.asset.Cash
import net.corda.core.identity.Party import net.corda.core.identity.Party
import net.corda.core.utilities.OpaqueBytes import net.corda.core.utilities.OpaqueBytes
import net.corda.core.utilities.getOrThrow import net.corda.core.utilities.getOrThrow
import net.corda.finance.flows.CashIssueFlow
import net.corda.node.internal.StartedNode import net.corda.node.internal.StartedNode
import net.corda.testing.BOC import net.corda.testing.BOC
import net.corda.testing.chooseIdentity import net.corda.testing.chooseIdentity
@ -16,12 +15,10 @@ import net.corda.testing.node.MockNetwork.MockNode
import net.corda.testing.startFlow import net.corda.testing.startFlow
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith import kotlin.test.assertFailsWith
@Ignore
class CashExitFlowTests { class CashExitFlowTests {
private lateinit var mockNet: MockNetwork private lateinit var mockNet: MockNetwork
private val initialBalance = 2000.DOLLARS private val initialBalance = 2000.DOLLARS

View File

@ -16,12 +16,10 @@ import net.corda.testing.node.MockNetwork
import net.corda.testing.node.MockNetwork.MockNode import net.corda.testing.node.MockNetwork.MockNode
import org.junit.After import org.junit.After
import org.junit.Before import org.junit.Before
import org.junit.Ignore
import org.junit.Test import org.junit.Test
import kotlin.test.assertEquals import kotlin.test.assertEquals
import kotlin.test.assertFailsWith import kotlin.test.assertFailsWith
@Ignore
class CashPaymentFlowTests { class CashPaymentFlowTests {
private lateinit var mockNet: MockNetwork private lateinit var mockNet: MockNetwork
private val initialBalance = 2000.DOLLARS private val initialBalance = 2000.DOLLARS