<commit_before>package sigmastate.utxo

import org.ergoplatform.ErgoBox
import org.scalatest.PropSpec
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.TryValues._
import sigmastate.serialization.generators.ValueGenerators

class ErgoBoxSerializerSpec extends PropSpec
  with GeneratorDrivenPropertyChecks
  with SerializationRoundTripSpec
  with ValueGenerators {

  implicit val ergoBoxSerializer = ErgoBox.serializer

  property("ErgoBox: Serializer round trip") {
    forAll { b: ErgoBox =>
      val bytes = ergoBoxSerializer.toBytes(b)
      val b1 = ergoBoxSerializer.parseBytes(bytes).success.value

      b1.value shouldBe b.value
      b1.proposition shouldBe b.proposition
      b1.transactionId.sameElements(b.transactionId) shouldBe true
      b1.boxId shouldBe b.boxId
      b1.additionalRegisters shouldBe b.additionalRegisters
    }
  }
}
<commit_msg>Add `ErgoBox` deserialization test with `pos` and `consumed` checks;<commit_after>package sigmastate.utxo

import org.scalacheck.Arbitrary._
import org.scalacheck.Gen
import org.ergoplatform.ErgoBox
import org.scalatest.PropSpec
import org.scalatest.prop.GeneratorDrivenPropertyChecks
import org.scalatest.TryValues._
import sigmastate.serialization.generators.ValueGenerators

class ErgoBoxSerializerSpec extends PropSpec
  with GeneratorDrivenPropertyChecks
  with SerializationRoundTripSpec
  with ValueGenerators {

  implicit val ergoBoxSerializer = ErgoBox.serializer

  property("ErgoBox: Serializer round trip") {
    forAll { b: ErgoBox =>
      val bytes = ergoBoxSerializer.toBytes(b)
      val b1 = ergoBoxSerializer.parseBytes(bytes).success.value

      b1.value shouldBe b.value
      b1.proposition shouldBe b.proposition
      b1.transactionId.sameElements(b.transactionId) shouldBe true
      b1.boxId shouldBe b.boxId
      b1.additionalRegisters shouldBe b.additionalRegisters
    }
  }

  property("ErgoBox: start pos and consumed bytes") {
    forAll { b: ErgoBox =>
      val randomBytesCount = Gen.chooseNum(1, 20).sample.get
      val randomBytes = Gen.listOfN(randomBytesCount, arbByte.arbitrary).sample.get.toArray
      val bytes = ergoBoxSerializer.toBytes(b)
      ergoBoxSerializer.parseBody(randomBytes ++ bytes, randomBytesCount) shouldEqual (b, bytes.length)
    }
  }
}

{'fraction_non_alphanumeric': 0.07220530665506741, 'fraction_numerical': 0.006524575902566333, 'mean_word_length': 4.4373522458628845, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 6, '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': '5561054', 'n_tokens_mistral': 722, 'n_tokens_neox': 714, 'n_words': 146}