diff --git a/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionBuilderTest.kt b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionBuilderTest.kt index af20bbba0f..083d91753f 100644 --- a/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionBuilderTest.kt +++ b/core-tests/src/test/kotlin/net/corda/coretests/transactions/TransactionBuilderTest.kt @@ -158,24 +158,21 @@ class TransactionBuilderTest { val inputStateRef1 = StateRef(SecureHash.randomSHA256(), 0) val referenceState1 = TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary) val referenceStateRef1 = StateRef(SecureHash.randomSHA256(), 1) - val timeWindow = TimeWindow.untilOnly(Instant.now()) val builder = TransactionBuilder(notary) .addInputState(StateAndRef(inputState1, inputStateRef1)) .addAttachment(SecureHash.allOnesHash) .addOutputState(TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)) .addCommand(DummyCommandData, notary.owningKey) .addReferenceState(StateAndRef(referenceState1, referenceStateRef1).referenced()) - val inputState2 = TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary) val inputStateRef2 = StateRef(SecureHash.randomSHA256(), 0) - val referenceState2 = TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary) val referenceStateRef2 = StateRef(SecureHash.randomSHA256(), 1) // List accessors are mutable. - (builder.inputStates() as ArrayList).add(inputStateRef2) - (builder.attachments() as ArrayList).add(SecureHash.zeroHash) - (builder.outputStates() as ArrayList).add(TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)) - (builder.commands() as ArrayList).add(Command(DummyCommandData, notary.owningKey)) - (builder.referenceStates() as ArrayList).add(referenceStateRef2) + assertThat((builder.inputStates() as ArrayList).also { it.add(inputStateRef2) }).hasSize(2) + assertThat((builder.attachments() as ArrayList).also { it.add(SecureHash.zeroHash) }).hasSize(2) + assertThat((builder.outputStates() as ArrayList).also { it.add(TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)) }).hasSize(2) + assertThat((builder.commands() as ArrayList).also { it.add(Command(DummyCommandData, notary.owningKey)) }).hasSize(2) + assertThat((builder.referenceStates() as ArrayList).also { it.add(referenceStateRef2) }).hasSize(2) // List accessors are copies. assertThat(builder.inputStates()).hasSize(1) diff --git a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt index 0be1c1acdf..6d41464edf 100644 --- a/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt +++ b/core/src/main/kotlin/net/corda/core/transactions/TransactionBuilder.kt @@ -813,19 +813,19 @@ open class TransactionBuilder( this.privacySalt = privacySalt } - /** Returns a mutable copy of the list of input [StateRef]s. */ + /** Returns an immutable list of input [StateRef]s. */ fun inputStates(): List = ArrayList(inputs) - /** Returns a mutable copy of the list of reference input [StateRef]s. */ + /** Returns an immutable list of reference input [StateRef]s. */ fun referenceStates(): List = ArrayList(references) - /** Returns a mutable copy of the list of attachment hashes. */ + /** Returns an immutable list of attachment hashes. */ fun attachments(): List = ArrayList(attachments) - /** Returns a mutable copy of the list of output [TransactionState]s. */ + /** Returns an immutable list of output [TransactionState]s. */ fun outputStates(): List> = ArrayList(outputs) - /** Returns a mutable copy of the list of [Command]s. */ + /** Returns an immutable list of [Command]s. */ fun commands(): List> = ArrayList(commands) /**