Cleaned up code causing build warnings

This commit is contained in:
Shams Asari 2017-03-31 18:01:13 +01:00
parent 30dd29752c
commit e0c548d4fa
12 changed files with 21 additions and 45 deletions

View File

@ -4,18 +4,13 @@ import net.corda.core.contracts.AuthenticatedObject
import net.corda.core.contracts.CommandData
import net.corda.core.contracts.ContractState
import net.corda.core.contracts.TransactionForContract
import net.corda.core.utilities.loggerFor
import java.util.*
/**
* Compose a number of clauses, such that the first match is run, and it errors if none is run.
*/
@Deprecated("Use FirstOf instead")
class FirstComposition<S : ContractState, C : CommandData, K : Any>(val firstClause: Clause<S, C, K>, vararg remainingClauses: Clause<S, C, K>) : CompositeClause<S, C, K>() {
companion object {
val logger = loggerFor<FirstComposition<*, *, *>>()
}
class FirstComposition<S : ContractState, C : CommandData, K : Any>(firstClause: Clause<S, C, K>, vararg remainingClauses: Clause<S, C, K>) : CompositeClause<S, C, K>() {
override val clauses = ArrayList<Clause<S, C, K>>()
override fun matchedClauses(commands: List<AuthenticatedObject<C>>): List<Clause<S, C, K>> = listOf(clauses.first { it.matches(commands) })

View File

@ -59,7 +59,7 @@ class X509UtilitiesTest {
serverCert.checkValidity(Date()) // throws on verification problems
serverCert.verify(caCertAndKey.keyPair.public) // throws on verification problems
assertFalse { serverCert.keyUsage[5] } // Bit 5 == keyCertSign according to ASN.1 spec (see full comment on KeyUsage property)
assertTrue { serverCert.basicConstraints === -1 } // This returns the signing path length should be -1 for non-CA certificate
assertTrue { serverCert.basicConstraints == -1 } // This returns the signing path length should be -1 for non-CA certificate
assertEquals(2, serverCert.subjectAlternativeNames.size)
var foundAliasDnsName = false
for (entry in serverCert.subjectAlternativeNames) {
@ -224,7 +224,7 @@ class X509UtilitiesTest {
var done = false
var serverError = false
val serverThread = thread() {
val serverThread = thread {
try {
val sslServerSocket = serverSocket.accept()
assert(sslServerSocket.isConnected)

View File

@ -6,7 +6,6 @@ import net.corda.core.utilities.DUMMY_NOTARY
import net.corda.testing.ALICE
import net.corda.testing.BOB
import net.corda.testing.MOCK_IDENTITY_SERVICE
import net.corda.testing.ledger
import net.corda.testing.node.MockNetwork
import org.junit.Before
import org.junit.Test
@ -30,7 +29,6 @@ class TxKeyFlowUtilitiesTests {
val notaryNode = net.createNotaryNode(null, DUMMY_NOTARY.name)
val aliceNode = net.createPartyNode(notaryNode.info.address, ALICE.name)
val bobNode = net.createPartyNode(notaryNode.info.address, BOB.name)
val aliceKey: Party = aliceNode.services.myInfo.legalIdentity
val bobKey: Party = bobNode.services.myInfo.legalIdentity
// Run the flows

View File

@ -2,8 +2,6 @@ package net.corda.docs
import net.corda.contracts.asset.Cash
import net.corda.core.contracts.Amount
import net.corda.core.contracts.Issued
import net.corda.core.contracts.PartyAndReference
import net.corda.core.contracts.USD
import net.corda.core.messaging.CordaRPCOps
import net.corda.core.messaging.startFlow
@ -111,7 +109,6 @@ fun generateTransactions(proxy: CordaRPCOps) {
val issueRef = OpaqueBytes.of(0)
val notary = proxy.networkMapUpdates().first.first { it.advertisedServices.any { it.info.type.isNotary() } }.notaryIdentity
val me = proxy.nodeIdentity().legalIdentity
val meAndRef = PartyAndReference(me, issueRef)
while (true) {
Thread.sleep(1000)
val random = SplittableRandom()

View File

@ -1,7 +1,6 @@
@file:JvmName("Driver")
package net.corda.node.driver
import co.paralleluniverse.common.util.ProcessUtil
import com.google.common.net.HostAndPort
import com.google.common.util.concurrent.*
import com.typesafe.config.Config
@ -59,7 +58,7 @@ private val log: Logger = loggerFor<DriverDSL>()
*/
interface DriverDSLExposedInterface {
/**
* Starts a [Node] in a separate process.
* Starts a [net.corda.node.internal.Node] in a separate process.
*
* @param providedName Optional name of the node, which will be its legal name in [Party]. Defaults to something
* random. Note that this must be unique as the driver uses it as a primary key!
@ -170,7 +169,6 @@ fun <A> driver(
isDebug: Boolean = false,
driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()),
portAllocation: PortAllocation = PortAllocation.Incremental(10000),
sshdPortAllocation: PortAllocation = PortAllocation.Incremental(20000),
debugPortAllocation: PortAllocation = PortAllocation.Incremental(5005),
systemProperties: Map<String, String> = emptyMap(),
useTestClock: Boolean = false,
@ -179,7 +177,6 @@ fun <A> driver(
) = genericDriver(
driverDsl = DriverDSL(
portAllocation = portAllocation,
sshdPortAllocation = sshdPortAllocation,
debugPortAllocation = debugPortAllocation,
systemProperties = systemProperties,
driverDirectory = driverDirectory.toAbsolutePath(),
@ -336,7 +333,6 @@ class ShutdownManager(private val executorService: ExecutorService) {
class DriverDSL(
val portAllocation: PortAllocation,
val sshdPortAllocation: PortAllocation,
val debugPortAllocation: PortAllocation,
val systemProperties: Map<String, String>,
val driverDirectory: Path,
@ -526,7 +522,6 @@ class DriverDSL(
override fun startNetworkMapService() {
val debugPort = if (isDebug) debugPortAllocation.nextPort() else null
val apiAddress = portAllocation.nextHostAndPort().toString()
val sshdAddress = sshdPortAllocation.nextHostAndPort().toString()
val baseDirectory = driverDirectory / networkMapLegalName
val config = ConfigHelper.loadConfig(
baseDirectory = baseDirectory,

View File

@ -1,8 +1,6 @@
package net.corda.node.services.api
import net.corda.core.crypto.SecureHash
import net.corda.core.node.services.FileUploader
import java.io.InputStream
/**
* A service that implements AcceptsFileUpload can have new binary data provided to it via an HTTP upload.
@ -16,5 +14,5 @@ interface AcceptsFileUpload: FileUploader {
/** What file extensions are acceptable for the file to be handed to upload() */
val acceptableFileExtensions: List<String>
override fun accepts(prefix: String) = prefix == dataTypePrefix
override fun accepts(type: String) = type == dataTypePrefix
}

View File

@ -10,6 +10,7 @@ open class StorageServiceImpl(override val attachments: AttachmentStorage,
lateinit override var uploaders: List<FileUploader>
fun initUploaders(uploadersList: List<FileUploader>) {
@Suppress("DEPRECATION")
uploaders = uploadersList
}
}

View File

@ -3,7 +3,6 @@ package net.corda.irs
import com.google.common.net.HostAndPort
import com.google.common.util.concurrent.Futures
import net.corda.client.rpc.CordaRPCClient
import net.corda.core.crypto.Party
import net.corda.core.getOrThrow
import net.corda.core.node.services.ServiceInfo
import net.corda.irs.api.NodeInterestRates
@ -24,8 +23,8 @@ import java.time.LocalDate
class IRSDemoTest : IntegrationTestCategory {
val rpcUser = User("user", "password", emptySet())
val currentDate = LocalDate.now()
val futureDate = currentDate.plusMonths(6)
val currentDate: LocalDate = LocalDate.now()
val futureDate: LocalDate = currentDate.plusMonths(6)
@Test
fun `runs IRS demo`() {
@ -45,7 +44,7 @@ class IRSDemoTest : IntegrationTestCategory {
val nextFixingDates = getFixingDateObservable(nodeA.configuration)
runUploadRates(controllerAddr)
runTrade(nodeAAddr, nodeA.nodeInfo.legalIdentity, nodeB.nodeInfo.legalIdentity)
runTrade(nodeAAddr)
// Wait until the initial trade and all scheduled fixings up to the current date have finished
nextFixingDates.first { it == null || it > currentDate }
@ -73,7 +72,7 @@ class IRSDemoTest : IntegrationTestCategory {
assert(putJson(url, "\"$futureDate\""))
}
private fun runTrade(nodeAddr: HostAndPort, fixedRatePayer: Party, floatingRatePayer: Party) {
private fun runTrade(nodeAddr: HostAndPort) {
val fileContents = IOUtils.toString(Thread.currentThread().contextClassLoader.getResourceAsStream("example-irs-trade.json"), Charsets.UTF_8.name())
val tradeFile = fileContents.replace("tradeXXX", "trade1")
val url = URL("http://$nodeAddr/api/irs/deals")

View File

@ -21,12 +21,8 @@ val IRS_PROGRAM_ID = InterestRateSwap()
// This is a placeholder for some types that we haven't identified exactly what they are just yet for things still in discussion
@CordaSerializable
open class UnknownType() {
override fun equals(other: Any?): Boolean {
return (other is UnknownType)
}
open class UnknownType {
override fun equals(other: Any?): Boolean = other is UnknownType
override fun hashCode() = 1
}
@ -188,7 +184,7 @@ class FloatingRatePaymentEvent(date: LocalDate,
* Currently, we are not interested (excuse pun) in valuing the swap, calculating the PVs, DFs and all that good stuff (soon though).
* This is just a representation of a vanilla Fixed vs Floating (same currency) IRS in the R3 prototype model.
*/
class InterestRateSwap() : Contract {
class InterestRateSwap : Contract {
override val legalContractReference = SecureHash.sha256("is_this_the_text_of_the_contract ? TBD")
companion object {
@ -522,7 +518,7 @@ class InterestRateSwap() : Contract {
class Group : GroupClauseVerifier<State<*>, Commands, UniqueIdentifier>(AnyOf(Agree(), Fix(), Pay(), Mature())) {
// Group by Trade ID for in / out states
override fun groupStates(tx: TransactionForContract): List<TransactionForContract.InOutGroup<State<*>, UniqueIdentifier>> {
return tx.groupStates() { state -> state.linearId }
return tx.groupStates { state -> state.linearId }
}
}
@ -550,8 +546,8 @@ class InterestRateSwap() : Contract {
val irs = outputs.filterIsInstance<State<*>>().single()
requireThat {
"There are no in states for an agreement" by inputs.isEmpty()
"There are events in the fix schedule" by (irs.calculation.fixedLegPaymentSchedule.size > 0)
"There are events in the float schedule" by (irs.calculation.floatingLegPaymentSchedule.size > 0)
"There are events in the fix schedule" by (irs.calculation.fixedLegPaymentSchedule.isNotEmpty())
"There are events in the float schedule" by (irs.calculation.floatingLegPaymentSchedule.isNotEmpty())
"All notionals must be non zero" by (irs.fixedLeg.notional.quantity > 0 && irs.floatingLeg.notional.quantity > 0)
"The fixed leg rate must be positive" by (irs.fixedLeg.fixedRate.isPositive())
"The currency of the notionals must be the same" by (irs.fixedLeg.notional.token == irs.floatingLeg.notional.token)
@ -739,6 +735,7 @@ class InterestRateSwap() : Contract {
fun toAnonymous(): State<AnonymousParty> {
return if (this.fixedLeg.fixedRatePayer is AnonymousParty) {
@Suppress("UNCHECKED_CAST")
this as State<AnonymousParty>
} else {
State(fixedLeg.toAnonymous(), floatingLeg.toAnonymous(), calculation, common, linearId)

View File

@ -151,7 +151,7 @@ object IdenticonRenderer {
private fun drawPatch(g: GraphicsContext, x: Double, y: Double, patchIndex: Int, turn: Int, patchSize: Double, _invert: Boolean, color: PatchColor) {
val patch = patchTypes[patchIndex % patchTypes.size]
val invert = if ((patchFlags[patchIndex].toInt() and PATCH_INVERTED.toInt()) !== 0) !_invert else _invert
val invert = if ((patchFlags[patchIndex].toInt() and PATCH_INVERTED.toInt()) != 0) !_invert else _invert
g.apply {
// paint background
clearRect(x, y, patchSize, patchSize)

View File

@ -68,7 +68,6 @@ fun <A> verifierDriver(
isDebug: Boolean = false,
driverDirectory: Path = Paths.get("build", getTimestampAsDirectoryName()),
portAllocation: PortAllocation = PortAllocation.Incremental(10000),
sshdPortAllocation: PortAllocation = PortAllocation.Incremental(20000),
debugPortAllocation: PortAllocation = PortAllocation.Incremental(5005),
systemProperties: Map<String, String> = emptyMap(),
useTestClock: Boolean = false,
@ -78,7 +77,6 @@ fun <A> verifierDriver(
driverDsl = VerifierDriverDSL(
DriverDSL(
portAllocation = portAllocation,
sshdPortAllocation = sshdPortAllocation,
debugPortAllocation = debugPortAllocation,
systemProperties = systemProperties,
driverDirectory = driverDirectory.toAbsolutePath(),
@ -260,10 +258,8 @@ data class VerifierDriverDSL(
val locator = ActiveMQClient.createServerLocatorWithoutHA(transport)
val sessionFactory = locator.createSessionFactory()
val session = sessionFactory.createSession(NODE_USER, NODE_USER, false, true, true, locator.isPreAcknowledge, locator.ackBatchSize)
try {
return closure(session)
} finally {
session.close()
return session.use {
closure(it)
}
}

View File

@ -76,7 +76,7 @@ class VerifierTests {
val alice = aliceFuture.get()
val verifier1 = startVerifier(alice)
val verifier2 = startVerifier(alice)
val verifier3 = startVerifier(alice)
startVerifier(alice)
alice.waitUntilNumberOfVerifiers(3)
val remainingTransactionsCount = AtomicInteger(numberOfTransactions)
val futures = transactions.map { transaction ->