Skip to content

Commit

Permalink
updated VMSuite to match latest ETS files - log entries replaced with…
Browse files Browse the repository at this point in the history
… hashes
  • Loading branch information
rtkaczyk committed Oct 20, 2017
1 parent 53ef726 commit 9339d19
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 11 additions & 3 deletions src/ets/scala/io/iohk/ethereum/ets/vm/VMSuite.scala
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
package io.iohk.ethereum.ets.vm

import akka.util.ByteString
import io.iohk.ethereum.domain.TxLogEntry
import io.iohk.ethereum.ets.common.TestOptions
import io.iohk.ethereum.network.p2p.messages.PV63.TxLogEntryImplicits._
import io.iohk.ethereum.rlp._
import io.iohk.ethereum.utils.Logger
import io.iohk.ethereum.vm.MockWorldState._
import io.iohk.ethereum.vm._
import io.iohk.ethereum.crypto.kec256
import org.scalatest._

class VMSuite extends FreeSpec with Matchers with Logger {
Expand Down Expand Up @@ -65,9 +69,8 @@ class VMSuite extends FreeSpec with Matchers with Logger {
deadAccounts.foreach(addr => result.world.isAccountDead(addr) shouldBe true)
}

scenario.logs.foreach { logs =>
val expectedLogs = logs.map(l => TxLogEntry(l.address, l.topics, l.data))
result.logs shouldEqual expectedLogs
scenario.logs.foreach { expectedLogHash =>
hashLogs(result.logs) shouldEqual expectedLogHash
}

scenario.callcreates.foreach { callcreates =>
Expand All @@ -91,4 +94,9 @@ class VMSuite extends FreeSpec with Matchers with Logger {
result.copy(world = worldAfterDel)
}

private def hashLogs(logs: Seq[TxLogEntry]): ByteString = {
val rlpLogs = RLPList(logs.map(_.toRLPEncodable): _*)
ByteString(kec256(encode(rlpLogs)))
}

}
8 changes: 1 addition & 7 deletions src/ets/scala/io/iohk/ethereum/ets/vm/scenario.scala
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ case class VMScenario(
callcreates: Option[List[CallCreate]],
pre: Map[Address, AccountState],
post: Option[Map[Address, AccountState]],
logs: Option[List[LogEntry]],
logs: Option[ByteString],
gas: Option[BigInt],
out: Option[ByteString]
)
Expand Down Expand Up @@ -42,9 +42,3 @@ case class CallCreate(
value: BigInt
)

case class LogEntry(
address: Address,
data: ByteString,
topics: List[ByteString]
)

0 comments on commit 9339d19

Please sign in to comment.