mirror of
https://github.com/corda/corda.git
synced 2025-01-18 02:39:51 +00:00
Reverted comment change about immutable accessors.
This commit is contained in:
parent
9396ee9551
commit
c4fd63ced6
@ -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)
|
||||
|
@ -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<StateRef> = 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<StateRef> = ArrayList(references)
|
||||
|
||||
/** Returns a mutable copy of the list of attachment hashes. */
|
||||
/** Returns an immutable list of attachment hashes. */
|
||||
fun attachments(): List<AttachmentId> = ArrayList(attachments)
|
||||
|
||||
/** Returns a mutable copy of the list of output [TransactionState]s. */
|
||||
/** Returns an immutable list of output [TransactionState]s. */
|
||||
fun outputStates(): List<TransactionState<*>> = ArrayList(outputs)
|
||||
|
||||
/** Returns a mutable copy of the list of [Command]s. */
|
||||
/** Returns an immutable list of [Command]s. */
|
||||
fun commands(): List<Command<*>> = ArrayList(commands)
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user