mirror of
https://github.com/corda/corda.git
synced 2025-04-09 04:15:35 +00:00
Correct misleading comment in CompositeKey and minor changes to its unit test (#1321)
This commit is contained in:
parent
2b5e3e39a2
commit
e2f402f0e4
@ -262,7 +262,9 @@ class CompositeKey private constructor(val threshold: Int, children: List<NodeAn
|
||||
else if (n == 1) {
|
||||
require(threshold == null || threshold == children.first().weight)
|
||||
{ "Trying to build invalid CompositeKey, threshold value different than weight of single child node." }
|
||||
children.first().node // We can assume that this node is a correct CompositeKey.
|
||||
// Returning the only child node which is [PublicKey] itself. We need to avoid single-key [CompositeKey] instances,
|
||||
// as there are scenarios where developers expected the underlying key and its composite versions to be equivalent.
|
||||
children.first().node
|
||||
} else throw IllegalArgumentException("Trying to build CompositeKey without child nodes.")
|
||||
}
|
||||
}
|
||||
|
@ -25,16 +25,16 @@ class CompositeKeyTests : TestDependencyInjectionBase() {
|
||||
@JvmField
|
||||
val tempFolder: TemporaryFolder = TemporaryFolder()
|
||||
|
||||
val aliceKey = generateKeyPair()
|
||||
val bobKey = generateKeyPair()
|
||||
val charlieKey = generateKeyPair()
|
||||
private val aliceKey = generateKeyPair()
|
||||
private val bobKey = generateKeyPair()
|
||||
private val charlieKey = generateKeyPair()
|
||||
|
||||
val alicePublicKey: PublicKey = aliceKey.public
|
||||
val bobPublicKey: PublicKey = bobKey.public
|
||||
val charliePublicKey: PublicKey = charlieKey.public
|
||||
private val alicePublicKey: PublicKey = aliceKey.public
|
||||
private val bobPublicKey: PublicKey = bobKey.public
|
||||
private val charliePublicKey: PublicKey = charlieKey.public
|
||||
|
||||
val message = OpaqueBytes("Transaction".toByteArray())
|
||||
val secureHash = message.sha256()
|
||||
private val message = OpaqueBytes("Transaction".toByteArray())
|
||||
private val secureHash = message.sha256()
|
||||
|
||||
// By lazy is required so that the serialisers are configured before vals initialisation takes place (they internally invoke serialise).
|
||||
val aliceSignature by lazy { aliceKey.sign(SignableData(secureHash, SignatureMetadata(1, Crypto.findSignatureScheme(alicePublicKey).schemeNumberID))) }
|
||||
@ -43,7 +43,6 @@ class CompositeKeyTests : TestDependencyInjectionBase() {
|
||||
|
||||
@Test
|
||||
fun `(Alice) fulfilled by Alice signature`() {
|
||||
println(aliceKey.serialize().hash)
|
||||
assertTrue { alicePublicKey.isFulfilledBy(aliceSignature.by) }
|
||||
assertFalse { alicePublicKey.isFulfilledBy(charlieSignature.by) }
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user