Skip to content

Commit

Permalink
chore: update tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Pat Losoponkul committed May 6, 2024
1 parent 4d2a526 commit 8d968f8
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package org.hyperledger.identus.castor.core.model.did

import com.google.protobuf.ByteString
import io.iohk.atala.prism.crypto.{Sha256, Sha256Digest}
import org.hyperledger.identus.shared.crypto.Sha256Hash
import io.iohk.atala.prism.protos.node_models
import org.hyperledger.identus.shared.models.Base64UrlString
import zio.*
Expand All @@ -12,11 +12,11 @@ import org.hyperledger.identus.castor.core.model.did.PrismDID
object PrismDIDSpec extends ZIOSpecDefault {

private val canonicalSuffixHex = "9b5118411248d9663b6ab15128fba8106511230ff654e7514cdcc4ce919bde9b"
private val canonicalSuffix = Sha256Digest.fromHex(canonicalSuffixHex)
private val canonicalSuffix = Sha256Hash.fromHex(canonicalSuffixHex)
private val encodedStateUsedBase64 =
"Cj8KPRI7CgdtYXN0ZXIwEAFKLgoJc2VjcDI1NmsxEiEDHpf-yhIns-LP3tLvA8icC5FJ1ZlBwbllPtIdNZ3q0jU"

private val short = PrismDID.buildCanonical(canonicalSuffix.getValue).toOption.get
private val short = PrismDID.buildCanonical(canonicalSuffix.bytes.toArray).toOption.get
private val long = PrismDID
.buildLongFormFromAtalaOperation(
node_models.AtalaOperation.parseFrom(Base64UrlString.fromStringUnsafe(encodedStateUsedBase64).toByteArray)
Expand All @@ -27,7 +27,7 @@ object PrismDIDSpec extends ZIOSpecDefault {

private val didParserSpec = suite("PrismDID.fromString")(
test("success for valid DID") {
val stateHash = Sha256.compute(Array()).getValue
val stateHash = Sha256Hash.compute(Array()).bytes.toArray
val validDID = PrismDID.buildCanonical(stateHash).toOption.get
val unsafeDID = PrismDID.fromString(validDID.toString)
assert(unsafeDID)(isRight(equalTo(validDID)))
Expand Down Expand Up @@ -58,7 +58,7 @@ object PrismDIDSpec extends ZIOSpecDefault {
)
val encodedState = mockAtalaOperation.toByteArray
val encodedStateBase64 = Base64UrlString.fromByteArray(encodedState).toStringNoPadding
val stateHash = Sha256.compute(encodedState).getHexValue
val stateHash = Sha256Hash.compute(encodedState).hexEncoded
val didString = s"did:prism:$stateHash:$encodedStateBase64"
val unsafeDID = PrismDID.fromString(didString)
assert(unsafeDID)(isLeft(containsString("CreateDid Atala operation expected")))
Expand Down

0 comments on commit 8d968f8

Please sign in to comment.