mirror of
https://github.com/corda/corda.git
synced 2025-04-06 19:07:08 +00:00
Code clean-up run
This commit is contained in:
parent
f9dc331551
commit
14f959b4af
@ -38,7 +38,7 @@ class NetworkIdentityModel {
|
||||
})
|
||||
|
||||
val notaries: ObservableList<Party> = networkIdentities.map {
|
||||
it.legalIdentitiesAndCerts.find { it.name.commonName?.let { ServiceType.parse(it).isNotary() } ?: false }
|
||||
it.legalIdentitiesAndCerts.find { it.name.commonName?.let { ServiceType.parse(it).isNotary() } == true }
|
||||
}.map { it?.party }.filterNotNull()
|
||||
|
||||
val notaryNodes: ObservableList<NodeInfo> = notaries.map { rpcProxy.value?.nodeInfoFromParty(it) }.filterNotNull()
|
||||
|
@ -88,7 +88,7 @@ class FinalityFlow(val transaction: SignedTransaction,
|
||||
private fun hasNoNotarySignature(stx: SignedTransaction): Boolean {
|
||||
val notaryKey = stx.tx.notary?.owningKey
|
||||
val signers = stx.sigs.map { it.by }.toSet()
|
||||
return !(notaryKey?.isFulfilledBy(signers) ?: false)
|
||||
return notaryKey?.isFulfilledBy(signers) != true
|
||||
}
|
||||
|
||||
private fun getPartiesToSend(ltx: LedgerTransaction): Set<Party> {
|
||||
|
@ -101,9 +101,7 @@ public class JavaCommercialPaper implements Contract {
|
||||
if (issuance != null ? !issuance.equals(state.issuance) : state.issuance != null) return false;
|
||||
if (owner != null ? !owner.equals(state.owner) : state.owner != null) return false;
|
||||
if (faceValue != null ? !faceValue.equals(state.faceValue) : state.faceValue != null) return false;
|
||||
if (maturityDate != null ? !maturityDate.equals(state.maturityDate) : state.maturityDate != null)
|
||||
return false;
|
||||
return true;
|
||||
return maturityDate != null ? maturityDate.equals(state.maturityDate) : state.maturityDate == null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -454,7 +454,7 @@ class Obligation<P : Any> : Contract {
|
||||
|
||||
requireThat {
|
||||
"there is a time-window from the authority" using (timeWindow != null)
|
||||
"the due date has passed" using (timeWindow!!.fromTime?.isAfter(deadline) ?: false)
|
||||
"the due date has passed" using (timeWindow!!.fromTime?.isAfter(deadline) == true)
|
||||
"input state lifecycle is correct" using (input.lifecycle == expectedInputLifecycle)
|
||||
"output state corresponds exactly to input state, with lifecycle changed" using (expectedOutput == actualOutput)
|
||||
}
|
||||
|
@ -12,6 +12,7 @@ import net.corda.core.utilities.seconds
|
||||
import net.corda.finance.DOLLARS
|
||||
import net.corda.finance.`issued by`
|
||||
import net.corda.finance.contracts.asset.*
|
||||
import net.corda.finance.contracts.asset.Cash.Companion.generateSpend
|
||||
import net.corda.testing.*
|
||||
import net.corda.testing.contracts.fillWithSomeTestCash
|
||||
import net.corda.testing.node.MockServices
|
||||
@ -269,7 +270,7 @@ class CommercialPaperTestsGeneric {
|
||||
// Alice pays $9000 to BigCorp to own some of their debt.
|
||||
moveTX = run {
|
||||
val builder = TransactionBuilder(DUMMY_NOTARY)
|
||||
Cash.generateSpend(aliceServices, builder, 9000.DOLLARS, AnonymousParty(bigCorpServices.key.public))
|
||||
generateSpend(aliceServices, builder, 9000.DOLLARS, AnonymousParty(bigCorpServices.key.public), ourIdentity, emptySet())
|
||||
CommercialPaper().generateMove(builder, issueTx.tx.outRef(0), AnonymousParty(aliceServices.key.public))
|
||||
val ptx = aliceServices.signInitialTransaction(builder)
|
||||
val ptx2 = bigCorpServices.addSignature(ptx)
|
||||
|
@ -12,6 +12,7 @@ import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.core.transactions.WireTransaction
|
||||
import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.finance.*
|
||||
import net.corda.finance.contracts.asset.Cash.Companion.generateSpend
|
||||
import net.corda.finance.utils.sumCash
|
||||
import net.corda.finance.utils.sumCashBy
|
||||
import net.corda.finance.utils.sumCashOrNull
|
||||
@ -505,7 +506,7 @@ class CashTests : TestDependencyInjectionBase() {
|
||||
private fun makeSpend(amount: Amount<Currency>, dest: AbstractParty): WireTransaction {
|
||||
val tx = TransactionBuilder(DUMMY_NOTARY)
|
||||
database.transaction {
|
||||
Cash.generateSpend(miniCorpServices, tx, amount, dest)
|
||||
generateSpend(miniCorpServices, tx, amount, dest, ourIdentity, emptySet())
|
||||
}
|
||||
return tx.toWireTransaction(miniCorpServices)
|
||||
}
|
||||
@ -607,7 +608,7 @@ class CashTests : TestDependencyInjectionBase() {
|
||||
database.transaction {
|
||||
|
||||
val tx = TransactionBuilder(DUMMY_NOTARY)
|
||||
Cash.generateSpend(miniCorpServices, tx, 80.DOLLARS, ALICE, setOf(MINI_CORP))
|
||||
generateSpend(miniCorpServices, tx, 80.DOLLARS, ALICE, ourIdentity, setOf(MINI_CORP))
|
||||
|
||||
assertEquals(vaultStatesUnconsumed.elementAt(2).ref, tx.inputStates()[0])
|
||||
}
|
||||
@ -826,7 +827,7 @@ class CashTests : TestDependencyInjectionBase() {
|
||||
PartyAndAmount(THEIR_IDENTITY_1, 400.DOLLARS),
|
||||
PartyAndAmount(THEIR_IDENTITY_2, 150.DOLLARS)
|
||||
)
|
||||
Cash.generateSpend(miniCorpServices, tx, payments)
|
||||
generateSpend(miniCorpServices, tx, amount, to, ourIdentity, emptySet())
|
||||
}
|
||||
val wtx = tx.toWireTransaction(miniCorpServices)
|
||||
fun out(i: Int) = wtx.getOutput(i) as Cash.State
|
||||
|
@ -52,7 +52,7 @@ data class SerializationContextImpl(override val preferredSerializationVersion:
|
||||
* We need to cache the AttachmentClassLoaders to avoid too many contexts, since the class loader is part of cache key for the context.
|
||||
*/
|
||||
override fun withAttachmentsClassLoader(attachmentHashes: List<SecureHash>): SerializationContext {
|
||||
properties[attachmentsClassLoaderEnabledPropertyName] as? Boolean ?: false || return this
|
||||
properties[attachmentsClassLoaderEnabledPropertyName] as? Boolean == true || return this
|
||||
val serializationContext = properties[serializationContextKey] as? SerializeAsTokenContextImpl ?: return this // Some tests don't set one.
|
||||
try {
|
||||
return withClassLoader(cache.get(attachmentHashes) {
|
||||
|
@ -21,8 +21,8 @@ sealed class PropertySerializer(val name: String, val readMethod: Method?, val r
|
||||
val default: String? = generateDefault()
|
||||
val mandatory: Boolean = generateMandatory()
|
||||
|
||||
private val isInterface: Boolean get() = resolvedType.asClass()?.isInterface ?: false
|
||||
private val isJVMPrimitive: Boolean get() = resolvedType.asClass()?.isPrimitive ?: false
|
||||
private val isInterface: Boolean get() = resolvedType.asClass()?.isInterface == true
|
||||
private val isJVMPrimitive: Boolean get() = resolvedType.asClass()?.isPrimitive == true
|
||||
|
||||
private fun generateType(): String {
|
||||
return if (isInterface || resolvedType == Any::class.java) "*" else SerializerFactory.nameForType(resolvedType)
|
||||
@ -45,7 +45,7 @@ sealed class PropertySerializer(val name: String, val readMethod: Method?, val r
|
||||
}
|
||||
|
||||
private fun generateMandatory(): Boolean {
|
||||
return isJVMPrimitive || !(readMethod?.returnsNullable() ?: true)
|
||||
return isJVMPrimitive || readMethod?.returnsNullable() == false
|
||||
}
|
||||
|
||||
private fun Method.returnsNullable(): Boolean {
|
||||
|
@ -35,7 +35,7 @@ class NodeInfoWatcherTest : NodeBasedTest() {
|
||||
|
||||
lateinit var keyManagementService: KeyManagementService
|
||||
lateinit var nodeInfoPath: Path
|
||||
val scheduler = TestScheduler();
|
||||
val scheduler = TestScheduler()
|
||||
val testSubscriber = TestSubscriber<NodeInfo>()
|
||||
|
||||
// Object under test
|
||||
|
@ -265,7 +265,7 @@ class FlowStateMachineImpl<R>(override val id: StateMachineRunId,
|
||||
// This is a hack to allow cash app access list of permitted issuer currency.
|
||||
// TODO: replace this with cordapp configuration.
|
||||
val config = serviceHub.configuration as? FullNodeConfiguration
|
||||
val permissionGranted = config?.extraAdvertisedServiceIds?.contains(permissionName) ?: true
|
||||
val permissionGranted = config?.extraAdvertisedServiceIds?.contains(permissionName) != false
|
||||
val checkPermissionEvent = FlowPermissionAuditEvent(
|
||||
serviceHub.clock.instant(),
|
||||
flowInitiator,
|
||||
|
@ -27,8 +27,5 @@ class NonInvalidatingCache<K, V> private constructor(
|
||||
}
|
||||
|
||||
override fun load(key: K) = loadFunction(key)
|
||||
override fun loadAll(keys: Iterable<K>): MutableMap<K, V> {
|
||||
return super.loadAll(keys)
|
||||
}
|
||||
}
|
||||
}
|
@ -29,8 +29,5 @@ class NonInvalidatingUnboundCache<K, V> private constructor(
|
||||
}
|
||||
|
||||
override fun load(key: K) = loadFunction(key)
|
||||
override fun loadAll(keys: Iterable<K>): MutableMap<K, V> {
|
||||
return super.loadAll(keys)
|
||||
}
|
||||
}
|
||||
}
|
@ -11,5 +11,5 @@ Useful commands include 'help' to see what is available, and 'bye' to shut down
|
||||
"""
|
||||
|
||||
prompt = { ->
|
||||
return "${new Date()}>>> ";
|
||||
return "${new Date()}>>> "
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import net.corda.core.utilities.OpaqueBytes
|
||||
import net.corda.core.utilities.toNonEmptySet
|
||||
import net.corda.finance.*
|
||||
import net.corda.finance.contracts.asset.Cash
|
||||
import net.corda.finance.contracts.asset.Cash.Companion.generateSpend
|
||||
import net.corda.finance.contracts.asset.DUMMY_CASH_ISSUER
|
||||
import net.corda.finance.contracts.asset.DUMMY_CASH_ISSUER_KEY
|
||||
import net.corda.finance.contracts.getCashBalance
|
||||
@ -515,7 +516,7 @@ class NodeVaultServiceTest : TestDependencyInjectionBase() {
|
||||
|
||||
database.transaction {
|
||||
val moveTx = TransactionBuilder(services.myInfo.chooseIdentity()).apply {
|
||||
Cash.generateSpend(services, this, Amount(1000, GBP), thirdPartyIdentity)
|
||||
generateSpend(services, this, Amount(1000, GBP), thirdPartyIdentity, ourIdentity, emptySet())
|
||||
}.toWireTransaction(services)
|
||||
service.notify(moveTx)
|
||||
}
|
||||
@ -560,7 +561,7 @@ class NodeVaultServiceTest : TestDependencyInjectionBase() {
|
||||
// Move cash
|
||||
val moveTx = database.transaction {
|
||||
TransactionBuilder(newNotary).apply {
|
||||
Cash.generateSpend(services, this, Amount(1000, GBP), thirdPartyIdentity)
|
||||
generateSpend(services, this, Amount(1000, GBP), thirdPartyIdentity, ourIdentity, emptySet())
|
||||
}.toWireTransaction(services)
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import net.corda.core.node.services.vault.QueryCriteria.VaultQueryCriteria
|
||||
import net.corda.core.transactions.TransactionBuilder
|
||||
import net.corda.finance.*
|
||||
import net.corda.finance.contracts.asset.Cash
|
||||
import net.corda.finance.contracts.asset.Cash.Companion.generateSpend
|
||||
import net.corda.finance.contracts.asset.DUMMY_CASH_ISSUER
|
||||
import net.corda.finance.contracts.asset.DUMMY_CASH_ISSUER_KEY
|
||||
import net.corda.finance.contracts.getCashBalance
|
||||
@ -99,7 +100,7 @@ class VaultWithCashTest : TestDependencyInjectionBase() {
|
||||
database.transaction {
|
||||
// A tx that spends our money.
|
||||
val spendTXBuilder = TransactionBuilder(DUMMY_NOTARY)
|
||||
Cash.generateSpend(services, spendTXBuilder, 80.DOLLARS, BOB)
|
||||
generateSpend(services, spendTXBuilder, 80.DOLLARS, BOB, ourIdentity, emptySet())
|
||||
val spendPTX = services.signInitialTransaction(spendTXBuilder, freshKey)
|
||||
notaryServices.addSignature(spendPTX)
|
||||
}
|
||||
@ -151,7 +152,7 @@ class VaultWithCashTest : TestDependencyInjectionBase() {
|
||||
database.transaction {
|
||||
try {
|
||||
val txn1Builder = TransactionBuilder(DUMMY_NOTARY)
|
||||
Cash.generateSpend(services, txn1Builder, 60.DOLLARS, BOB)
|
||||
generateSpend(services, txn1Builder, 60.DOLLARS, BOB, ourIdentity, emptySet())
|
||||
val ptxn1 = notaryServices.signInitialTransaction(txn1Builder)
|
||||
val txn1 = services.addSignature(ptxn1, freshKey)
|
||||
println("txn1: ${txn1.id} spent ${((txn1.tx.outputs[0].data) as Cash.State).amount}")
|
||||
@ -187,7 +188,7 @@ class VaultWithCashTest : TestDependencyInjectionBase() {
|
||||
database.transaction {
|
||||
try {
|
||||
val txn2Builder = TransactionBuilder(DUMMY_NOTARY)
|
||||
Cash.generateSpend(services, txn2Builder, 80.DOLLARS, BOB)
|
||||
generateSpend(services, txn2Builder, 80.DOLLARS, BOB, ourIdentity, emptySet())
|
||||
val ptxn2 = notaryServices.signInitialTransaction(txn2Builder)
|
||||
val txn2 = services.addSignature(ptxn2, freshKey)
|
||||
println("txn2: ${txn2.id} spent ${((txn2.tx.outputs[0].data) as Cash.State).amount}")
|
||||
@ -311,7 +312,7 @@ class VaultWithCashTest : TestDependencyInjectionBase() {
|
||||
database.transaction {
|
||||
// A tx that spends our money.
|
||||
val spendTXBuilder = TransactionBuilder(DUMMY_NOTARY)
|
||||
Cash.generateSpend(services, spendTXBuilder, 80.DOLLARS, BOB)
|
||||
generateSpend(services, spendTXBuilder, 80.DOLLARS, BOB, ourIdentity, emptySet())
|
||||
val spendPTX = notaryServices.signInitialTransaction(spendTXBuilder)
|
||||
val spendTX = services.addSignature(spendPTX, freshKey)
|
||||
services.recordTransactions(spendTX)
|
||||
|
@ -71,7 +71,6 @@ class FixedRate(ratioUnit: RatioUnit) : Rate(ratioUnit) {
|
||||
fun isPositive(): Boolean = ratioUnit!!.value > BigDecimal("0.0")
|
||||
|
||||
override fun equals(other: Any?) = other?.javaClass == javaClass && super.equals(other)
|
||||
override fun hashCode() = super.hashCode()
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -21,7 +21,7 @@ class R3Pty(val name: CordaX500Name, settings: SettingsProvider, dimension: Dime
|
||||
|
||||
val terminal = JediTermWidget(dimension, settings)
|
||||
|
||||
val isConnected: Boolean get() = terminal.ttyConnector?.isConnected ?: false
|
||||
val isConnected: Boolean get() = terminal.ttyConnector?.isConnected == true
|
||||
|
||||
override fun close() {
|
||||
log.info("Closing terminal '{}'", name)
|
||||
|
@ -103,7 +103,7 @@ class Network : CordaView() {
|
||||
hgap = 5.0
|
||||
vgap = 5.0
|
||||
for (identity in identities) {
|
||||
val isNotary = identity.name.commonName?.let { ServiceType.parse(it).isNotary() } ?: false
|
||||
val isNotary = identity.name.commonName?.let { ServiceType.parse(it).isNotary() } == true
|
||||
row("${if (isNotary) "Notary " else ""}Public Key :") {
|
||||
copyableLabel(SimpleObjectProperty(identity.owningKey.toBase58String()))
|
||||
}
|
||||
@ -150,7 +150,7 @@ class Network : CordaView() {
|
||||
}
|
||||
|
||||
override fun onDock() {
|
||||
centralLabel = mapLabels.firstOrDefault(SimpleObjectProperty(myLabel), { centralPeer?.contains(it.text, true) ?: false })
|
||||
centralLabel = mapLabels.firstOrDefault(SimpleObjectProperty(myLabel), { centralPeer?.contains(it.text, true) == true })
|
||||
centralLabel.value?.let { mapScrollPane.centerLabel(it) }
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ class Network : CordaView() {
|
||||
}
|
||||
|
||||
init {
|
||||
centralLabel = mapLabels.firstOrDefault(SimpleObjectProperty(myLabel), { centralPeer?.contains(it.text, true) ?: false })
|
||||
centralLabel = mapLabels.firstOrDefault(SimpleObjectProperty(myLabel), { centralPeer?.contains(it.text, true) == true })
|
||||
Bindings.bindContent(notaryList.children, notaryButtons)
|
||||
Bindings.bindContent(peerList.children, peerButtons)
|
||||
// Run once when the screen is ready.
|
||||
|
@ -37,7 +37,7 @@ class SearchField<T>(private val data: ObservableList<T>, vararg filterCriteria:
|
||||
text.isNullOrBlank() || if (category == ALL) {
|
||||
filterCriteria.any { it.second(data, text) }
|
||||
} else {
|
||||
filterCriteria.toMap()[category]?.invoke(data, text) ?: false
|
||||
filterCriteria.toMap()[category]?.invoke(data, text) == true
|
||||
}
|
||||
}
|
||||
}, arrayOf<Observable>(textField.textProperty(), searchCategory.valueProperty())))
|
||||
|
@ -135,8 +135,8 @@ class TransactionViewer : CordaView("Transactions") {
|
||||
"Transaction ID" to { tx, s -> "${tx.id}".contains(s, true) },
|
||||
"Input" to { tx, s -> tx.inputs.resolved.any { it.state.contract.contains(s, true) } },
|
||||
"Output" to { tx, s -> tx.outputs.any { it.state.contract.contains(s, true) } },
|
||||
"Input Party" to { tx, s -> tx.inputParties.any { it.any { it.value?.name?.organisation?.contains(s, true) ?: false } } },
|
||||
"Output Party" to { tx, s -> tx.outputParties.any { it.any { it.value?.name?.organisation?.contains(s, true) ?: false } } },
|
||||
"Input Party" to { tx, s -> tx.inputParties.any { it.any { it.value?.name?.organisation?.contains(s, true) == true } } },
|
||||
"Output Party" to { tx, s -> tx.outputParties.any { it.any { it.value?.name?.organisation?.contains(s, true) == true } } },
|
||||
"Command Type" to { tx, s -> tx.commandTypes.any { it.simpleName.contains(s, true) } }
|
||||
)
|
||||
root.top = searchField.root
|
||||
|
@ -147,7 +147,7 @@ class CashViewer : CordaView("Cash") {
|
||||
*/
|
||||
val searchField = SearchField(cashStates,
|
||||
"Currency" to { state, text -> state.state.data.amount.token.product.toString().contains(text, true) },
|
||||
"Issuer" to { state, text -> state.resolveIssuer().value?.name?.organisation?.contains(text, true) ?: false }
|
||||
"Issuer" to { state, text -> state.resolveIssuer().value?.name?.organisation?.contains(text, true) == true }
|
||||
)
|
||||
root.top = hbox(5.0) {
|
||||
button("New Transaction", FontAwesomeIconView(FontAwesomeIcon.PLUS)) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user