mirror of
https://github.com/corda/corda.git
synced 2025-01-18 10:46:38 +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 inputStateRef1 = StateRef(SecureHash.randomSHA256(), 0)
|
||||||
val referenceState1 = TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)
|
val referenceState1 = TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)
|
||||||
val referenceStateRef1 = StateRef(SecureHash.randomSHA256(), 1)
|
val referenceStateRef1 = StateRef(SecureHash.randomSHA256(), 1)
|
||||||
val timeWindow = TimeWindow.untilOnly(Instant.now())
|
|
||||||
val builder = TransactionBuilder(notary)
|
val builder = TransactionBuilder(notary)
|
||||||
.addInputState(StateAndRef(inputState1, inputStateRef1))
|
.addInputState(StateAndRef(inputState1, inputStateRef1))
|
||||||
.addAttachment(SecureHash.allOnesHash)
|
.addAttachment(SecureHash.allOnesHash)
|
||||||
.addOutputState(TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary))
|
.addOutputState(TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary))
|
||||||
.addCommand(DummyCommandData, notary.owningKey)
|
.addCommand(DummyCommandData, notary.owningKey)
|
||||||
.addReferenceState(StateAndRef(referenceState1, referenceStateRef1).referenced())
|
.addReferenceState(StateAndRef(referenceState1, referenceStateRef1).referenced())
|
||||||
val inputState2 = TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)
|
|
||||||
val inputStateRef2 = StateRef(SecureHash.randomSHA256(), 0)
|
val inputStateRef2 = StateRef(SecureHash.randomSHA256(), 0)
|
||||||
val referenceState2 = TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)
|
|
||||||
val referenceStateRef2 = StateRef(SecureHash.randomSHA256(), 1)
|
val referenceStateRef2 = StateRef(SecureHash.randomSHA256(), 1)
|
||||||
|
|
||||||
// List accessors are mutable.
|
// List accessors are mutable.
|
||||||
(builder.inputStates() as ArrayList).add(inputStateRef2)
|
assertThat((builder.inputStates() as ArrayList).also { it.add(inputStateRef2) }).hasSize(2)
|
||||||
(builder.attachments() as ArrayList).add(SecureHash.zeroHash)
|
assertThat((builder.attachments() as ArrayList).also { it.add(SecureHash.zeroHash) }).hasSize(2)
|
||||||
(builder.outputStates() as ArrayList).add(TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary))
|
assertThat((builder.outputStates() as ArrayList).also { it.add(TransactionState(DummyState(), DummyContract.PROGRAM_ID, notary)) }).hasSize(2)
|
||||||
(builder.commands() as ArrayList).add(Command(DummyCommandData, notary.owningKey))
|
assertThat((builder.commands() as ArrayList).also { it.add(Command(DummyCommandData, notary.owningKey)) }).hasSize(2)
|
||||||
(builder.referenceStates() as ArrayList).add(referenceStateRef2)
|
assertThat((builder.referenceStates() as ArrayList).also { it.add(referenceStateRef2) }).hasSize(2)
|
||||||
|
|
||||||
// List accessors are copies.
|
// List accessors are copies.
|
||||||
assertThat(builder.inputStates()).hasSize(1)
|
assertThat(builder.inputStates()).hasSize(1)
|
||||||
|
@ -813,19 +813,19 @@ open class TransactionBuilder(
|
|||||||
this.privacySalt = privacySalt
|
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)
|
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)
|
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)
|
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)
|
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)
|
fun commands(): List<Command<*>> = ArrayList(commands)
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user