forked from corda/corda
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix coin selection with Flow-friendly sleep (corda#1847)
- Loading branch information
Showing
10 changed files
with
190 additions
and
94 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
40 changes: 40 additions & 0 deletions
40
finance/src/test/kotlin/net/corda/finance/contracts/asset/CashSelectionH2Test.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package net.corda.finance.contracts.asset | ||
|
||
import net.corda.core.utilities.getOrThrow | ||
import net.corda.finance.DOLLARS | ||
import net.corda.finance.flows.CashException | ||
import net.corda.finance.flows.CashPaymentFlow | ||
import net.corda.testing.chooseIdentity | ||
import net.corda.testing.node.MockNetwork | ||
import org.assertj.core.api.Assertions.assertThatThrownBy | ||
import org.junit.Test | ||
|
||
|
||
class CashSelectionH2Test { | ||
|
||
@Test | ||
fun `check does not hold connection over retries`() { | ||
val mockNet = MockNetwork(threadPerNode = true) | ||
try { | ||
val notaryNode = mockNet.createNotaryNode() | ||
val bankA = mockNet.createNode(configOverrides = { existingConfig -> | ||
// Tweak connections to be minimal to make this easier (1 results in a hung node during start up, so use 2 connections). | ||
existingConfig.dataSourceProperties.setProperty("maximumPoolSize", "2") | ||
existingConfig | ||
}) | ||
|
||
mockNet.startNodes() | ||
|
||
// Start more cash spends than we have connections. If spend leaks a connection on retry, we will run out of connections. | ||
val flow1 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notaryNode.info.chooseIdentity())) | ||
val flow2 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notaryNode.info.chooseIdentity())) | ||
val flow3 = bankA.services.startFlow(CashPaymentFlow(amount = 100.DOLLARS, anonymous = false, recipient = notaryNode.info.chooseIdentity())) | ||
|
||
assertThatThrownBy { flow1.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) | ||
assertThatThrownBy { flow2.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) | ||
assertThatThrownBy { flow3.resultFuture.getOrThrow() }.isInstanceOf(CashException::class.java) | ||
} finally { | ||
mockNet.stopNodes() | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.