input-output-hk / scrypto

Cryptographic primitives for Scala

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Provide a Replacement for hash "correct Tag" Test

stenolog opened this issue · comments

This test:

property(s"${hash.getClass.getSimpleName} should return correct Tag") {
forAll { (string: String, bytes: Array[Byte]) =>
val digest = hash(string)
digest.isInstanceOf[D] shouldBe true
if (digest.isInstanceOf[Digest32]) {
hash.DigestSize shouldBe 32
} else if (digest.isInstanceOf[Digest64]) {
hash.DigestSize shouldBe 64
}
}
}

is not functional within scala 2.

This came up during work on

Reproduce

  • just replace 32/64 hash.DigestSize shouldBe 32 with a wrong value, the test will not fail.
  • or: add breakpoints to lines 64 and 66
  • or: add else { fail("Tag is not Digest32 or Digest64") } to line 67
  • #108 (review) (reproducer in CI)

Tasks

  • disable the non-functioning part
  • find a solution to have the Tag available in runtime
  • provide a new test (for scala 2 and 3)

Potential fix: pull-108-2fa4a7e