<commit_before>

module Unison.Test.Cryptography where

import qualified Unison.Cryptography as C
import qualified Data.ByteString.Char8 as B
import Unison.Runtime.Cryptography
import Test.Tasty
import Test.Tasty.HUnit

cryptoTest :: IO Assertion
cryptoTest = do
  let crypto = noise (B.pack "dummypublickey")
      cleartext = (B.pack "cleartext")
  symkey <- C.randomBytes crypto 16
  cyphertext <- C.encrypt crypto symkey [cleartext]
  let decypheredtext = C.decrypt crypto symkey cyphertext
  case decypheredtext of
    Left _ -> fail "Roundtrip encryption failure."
    Right d -> return $ assertEqual "Original cleartext is not equal to decrypted message." cleartext d

ioTests :: IO TestTree
ioTests = fmap (testCase "Cryptography roundtrip test.") cryptoTest

<commit_msg>Updated crypto test for constructor function name change (noise -> mkCrypto) and increased key size to satisfy cacophony.<commit_after>

module Unison.Test.Cryptography where

import qualified Unison.Cryptography as C
import qualified Data.ByteString.Char8 as B
import Unison.Runtime.Cryptography
import Test.Tasty
import Test.Tasty.HUnit

cryptoTest :: IO Assertion
cryptoTest = do
  let crypto = mkCrypto (B.pack "dummypublickey")
      cleartext = (B.pack "cleartext")
  symkey <- C.randomBytes crypto 32
  cyphertext <- C.encrypt crypto symkey [cleartext]
  let decypheredtext = C.decrypt crypto symkey cyphertext
  case decypheredtext of
    Left _ -> fail "Roundtrip encryption failure."
    Right d -> return $ assertEqual "Original cleartext is not equal to decrypted message." cleartext d

ioTests :: IO TestTree
ioTests = fmap (testCase "Cryptography roundtrip test.") cryptoTest


{'fraction_non_alphanumeric': 0.07121484141232795, 'fraction_numerical': 0.003590664272890485, 'mean_word_length': 4.428571428571429, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7135178', 'n_tokens_mistral': 510, 'n_tokens_neox': 489, 'n_words': 176}