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.
[CORDA-2387]: Seeing warnings for "Double insert in net.corda.node.ut…
…ilities.AppendOnlyPersistentMap" (fixed) (corda#4499) * [CORDA-2387]: Reproduced the issue in a test. * [CORDA-2387]: Fixed. * [CORDA-2387]: Fixed.
- Loading branch information
1 parent
f590300
commit 5d3b24d
Showing
4 changed files
with
88 additions
and
4 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
79 changes: 79 additions & 0 deletions
79
node/src/integration-test/kotlin/net/corda/node/logging/IssueCashLoggingTests.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,79 @@ | ||
package net.corda.node.logging | ||
|
||
import co.paralleluniverse.fibers.Suspendable | ||
import net.corda.core.concurrent.CordaFuture | ||
import net.corda.core.contracts.Amount | ||
import net.corda.core.flows.StartableByRPC | ||
import net.corda.core.identity.Party | ||
import net.corda.core.messaging.startFlow | ||
import net.corda.core.serialization.CordaSerializable | ||
import net.corda.core.utilities.OpaqueBytes | ||
import net.corda.core.utilities.ProgressTracker | ||
import net.corda.core.utilities.getOrThrow | ||
import net.corda.finance.DOLLARS | ||
import net.corda.finance.flows.AbstractCashFlow | ||
import net.corda.finance.flows.CashIssueFlow | ||
import net.corda.finance.flows.CashPaymentFlow | ||
import net.corda.node.services.Permissions.Companion.all | ||
import net.corda.testing.driver.DriverParameters | ||
import net.corda.testing.driver.driver | ||
import net.corda.testing.node.User | ||
import net.corda.testing.node.internal.cordappWithPackages | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import java.util.* | ||
import java.util.concurrent.CompletableFuture.allOf | ||
|
||
class IssueCashLoggingTests { | ||
|
||
private val UNSIGNED_FINANCE_CORDAPP = cordappWithPackages("net.corda.finance") | ||
|
||
@Test | ||
fun `issuing and sending cash as payment do not result in duplicate insertion warnings`() { | ||
val user = User("mark", "dadada", setOf(all())) | ||
driver(DriverParameters(cordappsForAllNodes = setOf(UNSIGNED_FINANCE_CORDAPP))) { | ||
val nodeA = startNode(rpcUsers = listOf(user)).getOrThrow() | ||
val nodeB = startNode().getOrThrow() | ||
|
||
val amount = 1.DOLLARS | ||
val ref = OpaqueBytes.of(0) | ||
val recipient = nodeB.nodeInfo.legalIdentities[0] | ||
|
||
nodeA.rpc.startFlow(::CashIssueAndPaymentFlow, amount, ref, recipient, false, defaultNotaryIdentity).returnValue.getOrThrow() | ||
|
||
val linesWithDuplicateInsertionWarningsInA = nodeA.logFile().useLines { lines -> lines.filter(String::containsDuplicateInsertWarning).toList() } | ||
val linesWithDuplicateInsertionWarningsInB = nodeB.logFile().useLines { lines -> lines.filter(String::containsDuplicateInsertWarning).toList() } | ||
|
||
assertThat(linesWithDuplicateInsertionWarningsInA).isEmpty() | ||
assertThat(linesWithDuplicateInsertionWarningsInB).isEmpty() | ||
} | ||
} | ||
|
||
@StartableByRPC | ||
class CashIssueAndPaymentFlow(val amount: Amount<Currency>, | ||
val issueRef: OpaqueBytes, | ||
val recipient: Party, | ||
val anonymous: Boolean, | ||
val notary: Party, | ||
progressTracker: ProgressTracker) : AbstractCashFlow<AbstractCashFlow.Result>(progressTracker) { | ||
|
||
constructor(amount: Amount<Currency>, | ||
issueRef: OpaqueBytes, | ||
recipient: Party, | ||
anonymous: Boolean, | ||
notary: Party) : this(amount, issueRef, recipient, anonymous, notary, tracker()) | ||
|
||
constructor(request: IssueAndPaymentRequest) : this(request.amount, request.issueRef, request.recipient, request.anonymous, request.notary, tracker()) | ||
|
||
@Suspendable | ||
override fun call(): Result { | ||
subFlow(CashIssueFlow(amount, issueRef, notary)) | ||
return subFlow(CashPaymentFlow(amount, recipient, anonymous)) | ||
} | ||
|
||
@CordaSerializable | ||
class IssueAndPaymentRequest(amount: Amount<Currency>, val issueRef: OpaqueBytes, val recipient: Party, val notary: Party, val anonymous: Boolean) : AbstractRequest(amount) | ||
} | ||
} | ||
|
||
private fun String.containsDuplicateInsertWarning(): Boolean = contains("Double insert") && contains("not inserting the second time") |
7 changes: 7 additions & 0 deletions
7
node/src/integration-test/kotlin/net/corda/node/logging/PackageUtils.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,7 @@ | ||
package net.corda.node.logging | ||
|
||
import net.corda.core.internal.div | ||
import net.corda.testing.driver.NodeHandle | ||
import java.io.File | ||
|
||
fun NodeHandle.logFile(): File = (baseDirectory / "logs").toFile().walk().filter { it.name.startsWith("node-") && it.extension == "log" }.single() |
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