{"action":"created","comment":{"url":"https://api.github.com/repos/rchain/rchain/pulls/comments/228570905","pull_request_review_id":168879439,"id":228570905,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIyODU3MDkwNQ==","diff_hunk":"@@ -1,27 +1,115 @@\n package coop.rchain.rholang.interpreter.accounting\n+import java.nio.file.Files\n+\n+import cats.Id\n+import cats.effect.Sync\n+import coop.rchain.crypto.hash.Blake2b512Random\n+import cats.implicits._\n+import coop.rchain.models._\n+import coop.rchain.rholang.interpreter.Runtime.{RhoContext, RhoISpace}\n+import coop.rchain.rholang.interpreter.errors.OutOfPhlogistonsError\n import coop.rchain.rholang.{PrettyPrinted, ProcGen}\n-import coop.rchain.rholang.interpreter.Interpreter\n-import coop.rchain.rholang.syntax.rholang_mercury.Absyn.Proc\n+import coop.rchain.rholang.interpreter._\n+import coop.rchain.rholang.syntax.rholang_mercury.Absyn.{PPar, Proc}\n import coop.rchain.rholang.syntax.rholang_mercury.PrettyPrinter\n+import coop.rchain.rspace.history.Branch\n+import coop.rchain.rspace.{Context, RSpace}\n+import monix.eval.Task\n import org.scalacheck.Arbitrary\n import org.scalacheck.Test.Parameters\n import org.scalatest.{FlatSpec, Matchers}\n import org.scalatest.prop.PropertyChecks\n \n+import scala.concurrent.duration._\n+import monix.execution.Scheduler.Implicits.global\n+\n class CostAccountingPropertyTest extends FlatSpec with PropertyChecks with Matchers {\n+  import CostAccountingPropertyTest._\n+\n   implicit val params: Parameters = Parameters.defaultVerbose.withMinSuccessfulTests(1000)\n   implicit val procArbitrary = Arbitrary(\n     ProcGen.topLevelGen(5).map(PrettyPrinted[Proc](_, PrettyPrinter.print))\n   )\n \n+  implicit val taskExecutionDuration = 5.seconds\n+\n   def cost(proc: Proc): Cost = Cost(Interpreter.buildPar(proc).apply)\n \n   behavior of \"Cost accounting in Reducer\"\n \n-  it should \"cost of substitution is never negative\" in {\n+  it should \"have positive cost of substitution\" in {\n     forAll { p: PrettyPrinted[Proc] =>\n       cost(p.value).value should be >= 0L\n     }\n+  }\n+\n+  behavior of \"Charging phlos in Reducer\"\n+\n+  it should \"charge the same if the evaluation order is reversed\" in {\n+    forAll { (p: PrettyPrinted[Proc], q: PrettyPrinted[Proc]) =>\n+      haveEqualResults(costOfExecution(p.value, q.value), costOfExecution(q.value, p.value))\n+    }\n+  }\n \n+  it should \"sequential execution and parallel execution have the same cost\" in {\n+    forAll { (p: PrettyPrinted[Proc], q: PrettyPrinted[Proc]) =>\n+      haveEqualResults(\n+        costOfExecution(new PPar(p.value, q.value)),\n+        costOfExecution(q.value, p.value)\n+      )\n+    }\n   }\n }\n+\n+object CostAccountingPropertyTest {\n+  def haveEqualResults[A](tasks: Task[A]*)(implicit duration: Duration): Boolean =\n+    tasks.toList\n+      .sequence[Task, A]\n+      .map { _.sliding(2).forall { case List(r1, r2) => r1 == r2 } }\n+      .runSyncUnsafe(duration)\n+\n+  def createRhoISpace(): RhoISpace = {\n+    implicit val syncF: Sync[Id] = coop.rchain.catscontrib.effect.implicits.syncId\n+    import coop.rchain.rholang.interpreter.storage.implicits._\n+    val dbDir               = Files.createTempDirectory(\"cost-accounting-property-test-\")\n+    val context: RhoContext = Context.create(dbDir, 1024L * 1024L * 4)\n+    val space: RhoISpace = RSpace.create[\n+      Id,\n+      Par,\n+      BindPattern,\n+      OutOfPhlogistonsError.type,\n+      ListParWithRandom,\n+      ListParWithRandomAndPhlos,\n+      TaggedContinuation\n+    ](context, Branch(\"test\"))\n+    space\n+  }\n+\n+  def execute(reducer: ChargingReducer[Task], p: Proc)(\n+      implicit rand: Blake2b512Random\n+  ): Task[Long] = {\n+    val program = Interpreter.buildPar(p).apply","path":"rholang/src/test/scala/coop/rchain/rholang/interpreter/accounting/CostAccountingPropertyTest.scala","position":94,"original_position":94,"commit_id":"8dc0e09e5ed5da0394f50f0510548037dfffd54a","original_commit_id":"fcba36cba8323513ee5a8af58d6823fb325002d4","user":{"login":"odeac","id":1412609,"node_id":"MDQ6VXNlcjE0MTI2MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/1412609?v=4","gravatar_id":"","url":"https://api.github.com/users/odeac","html_url":"https://github.com/odeac","followers_url":"https://api.github.com/users/odeac/followers","following_url":"https://api.github.com/users/odeac/following{/other_user}","gists_url":"https://api.github.com/users/odeac/gists{/gist_id}","starred_url":"https://api.github.com/users/odeac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeac/subscriptions","organizations_url":"https://api.github.com/users/odeac/orgs","repos_url":"https://api.github.com/users/odeac/repos","events_url":"https://api.github.com/users/odeac/events{/privacy}","received_events_url":"https://api.github.com/users/odeac/received_events","type":"User","site_admin":false},"body":"yes, we can certainly build Par generators on top of the Proc generator","created_at":"2018-10-26T15:30:18Z","updated_at":"2018-10-26T15:30:18Z","html_url":"https://github.com/rchain/rchain/pull/1736#discussion_r228570905","pull_request_url":"https://api.github.com/repos/rchain/rchain/pulls/1736","author_association":"COLLABORATOR","_links":{"self":{"href":"https://api.github.com/repos/rchain/rchain/pulls/comments/228570905"},"html":{"href":"https://github.com/rchain/rchain/pull/1736#discussion_r228570905"},"pull_request":{"href":"https://api.github.com/repos/rchain/rchain/pulls/1736"}},"in_reply_to_id":228282765},"pull_request":{"url":"https://api.github.com/repos/rchain/rchain/pulls/1736","id":225755396,"node_id":"MDExOlB1bGxSZXF1ZXN0MjI1NzU1Mzk2","html_url":"https://github.com/rchain/rchain/pull/1736","diff_url":"https://github.com/rchain/rchain/pull/1736.diff","patch_url":"https://github.com/rchain/rchain/pull/1736.patch","issue_url":"https://api.github.com/repos/rchain/rchain/issues/1736","number":1736,"state":"open","locked":false,"title":"Implement property tests for CostAccounting","user":{"login":"odeac","id":1412609,"node_id":"MDQ6VXNlcjE0MTI2MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/1412609?v=4","gravatar_id":"","url":"https://api.github.com/users/odeac","html_url":"https://github.com/odeac","followers_url":"https://api.github.com/users/odeac/followers","following_url":"https://api.github.com/users/odeac/following{/other_user}","gists_url":"https://api.github.com/users/odeac/gists{/gist_id}","starred_url":"https://api.github.com/users/odeac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeac/subscriptions","organizations_url":"https://api.github.com/users/odeac/orgs","repos_url":"https://api.github.com/users/odeac/repos","events_url":"https://api.github.com/users/odeac/events{/privacy}","received_events_url":"https://api.github.com/users/odeac/received_events","type":"User","site_admin":false},"body":"## Overview\r\nsee title\r\n\r\n### Which JIRA issue does this PR relate to? If there is not a JIRA issue addressing this work, please create one now and add the link here.\r\nhttps://rchain.atlassian.net/browse/RHOL-949\r\n\r\n### Complete this checklist before you submit the PR\r\n- [x] This PR contains no more than 200 lines of code, excluding test code.\r\n- [x] This PR meets [RChain development coding standards](https://rchain.atlassian.net/wiki/spaces/DOC/pages/28082177/Coding+Standards).\r\n- [ ] If this PR adds a new feature, this PR includes tests related to this feature.\r\n- [x] You assigned one person to review this PR\r\n\r\n### If you are not a member of the core development team, please confirm:\r\n- [ ] You signed the commit. Merging requires a signature. Please see the [developer wiki](https://rchain.atlassian.net/wiki/spaces/DOC/pages/498630673/How+to+sign+commits+to+rchain+rchain) for instructions.\r\n- [ ] Your GitHub account is also an account with [Travis CI](https://travis-ci.org). Unit tests will not run on your PR unless you have an account with Travis. Merge requires passed unit tests.\r\n\r\n### Notes\r\nOptional. Add any notes on caveats, approaches you tried that didn't work, or anything else.\r\n","created_at":"2018-10-25T13:18:08Z","updated_at":"2018-10-26T15:30:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"26712944d425e60e9872c70b65ee8cec91b2206c","assignee":null,"assignees":[],"requested_reviewers":[{"login":"birchmd","id":13788876,"node_id":"MDQ6VXNlcjEzNzg4ODc2","avatar_url":"https://avatars1.githubusercontent.com/u/13788876?v=4","gravatar_id":"","url":"https://api.github.com/users/birchmd","html_url":"https://github.com/birchmd","followers_url":"https://api.github.com/users/birchmd/followers","following_url":"https://api.github.com/users/birchmd/following{/other_user}","gists_url":"https://api.github.com/users/birchmd/gists{/gist_id}","starred_url":"https://api.github.com/users/birchmd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/birchmd/subscriptions","organizations_url":"https://api.github.com/users/birchmd/orgs","repos_url":"https://api.github.com/users/birchmd/repos","events_url":"https://api.github.com/users/birchmd/events{/privacy}","received_events_url":"https://api.github.com/users/birchmd/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/rchain/rchain/pulls/1736/commits","review_comments_url":"https://api.github.com/repos/rchain/rchain/pulls/1736/comments","review_comment_url":"https://api.github.com/repos/rchain/rchain/pulls/comments{/number}","comments_url":"https://api.github.com/repos/rchain/rchain/issues/1736/comments","statuses_url":"https://api.github.com/repos/rchain/rchain/statuses/8dc0e09e5ed5da0394f50f0510548037dfffd54a","head":{"label":"odeac:rhol-949","ref":"rhol-949","sha":"8dc0e09e5ed5da0394f50f0510548037dfffd54a","user":{"login":"odeac","id":1412609,"node_id":"MDQ6VXNlcjE0MTI2MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/1412609?v=4","gravatar_id":"","url":"https://api.github.com/users/odeac","html_url":"https://github.com/odeac","followers_url":"https://api.github.com/users/odeac/followers","following_url":"https://api.github.com/users/odeac/following{/other_user}","gists_url":"https://api.github.com/users/odeac/gists{/gist_id}","starred_url":"https://api.github.com/users/odeac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeac/subscriptions","organizations_url":"https://api.github.com/users/odeac/orgs","repos_url":"https://api.github.com/users/odeac/repos","events_url":"https://api.github.com/users/odeac/events{/privacy}","received_events_url":"https://api.github.com/users/odeac/received_events","type":"User","site_admin":false},"repo":{"id":135245214,"node_id":"MDEwOlJlcG9zaXRvcnkxMzUyNDUyMTQ=","name":"rchain","full_name":"odeac/rchain","private":false,"owner":{"login":"odeac","id":1412609,"node_id":"MDQ6VXNlcjE0MTI2MDk=","avatar_url":"https://avatars0.githubusercontent.com/u/1412609?v=4","gravatar_id":"","url":"https://api.github.com/users/odeac","html_url":"https://github.com/odeac","followers_url":"https://api.github.com/users/odeac/followers","following_url":"https://api.github.com/users/odeac/following{/other_user}","gists_url":"https://api.github.com/users/odeac/gists{/gist_id}","starred_url":"https://api.github.com/users/odeac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/odeac/subscriptions","organizations_url":"https://api.github.com/users/odeac/orgs","repos_url":"https://api.github.com/users/odeac/repos","events_url":"https://api.github.com/users/odeac/events{/privacy}","received_events_url":"https://api.github.com/users/odeac/received_events","type":"User","site_admin":false},"html_url":"https://github.com/odeac/rchain","description":null,"fork":true,"url":"https://api.github.com/repos/odeac/rchain","forks_url":"https://api.github.com/repos/odeac/rchain/forks","keys_url":"https://api.github.com/repos/odeac/rchain/keys{/key_id}","collaborators_url":"https://api.github.com/repos/odeac/rchain/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/odeac/rchain/teams","hooks_url":"https://api.github.com/repos/odeac/rchain/hooks","issue_events_url":"https://api.github.com/repos/odeac/rchain/issues/events{/number}","events_url":"https://api.github.com/repos/odeac/rchain/events","assignees_url":"https://api.github.com/repos/odeac/rchain/assignees{/user}","branches_url":"https://api.github.com/repos/odeac/rchain/branches{/branch}","tags_url":"https://api.github.com/repos/odeac/rchain/tags","blobs_url":"https://api.github.com/repos/odeac/rchain/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/odeac/rchain/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/odeac/rchain/git/refs{/sha}","trees_url":"https://api.github.com/repos/odeac/rchain/git/trees{/sha}","statuses_url":"https://api.github.com/repos/odeac/rchain/statuses/{sha}","languages_url":"https://api.github.com/repos/odeac/rchain/languages","stargazers_url":"https://api.github.com/repos/odeac/rchain/stargazers","contributors_url":"https://api.github.com/repos/odeac/rchain/contributors","subscribers_url":"https://api.github.com/repos/odeac/rchain/subscribers","subscription_url":"https://api.github.com/repos/odeac/rchain/subscription","commits_url":"https://api.github.com/repos/odeac/rchain/commits{/sha}","git_commits_url":"https://api.github.com/repos/odeac/rchain/git/commits{/sha}","comments_url":"https://api.github.com/repos/odeac/rchain/comments{/number}","issue_comment_url":"https://api.github.com/repos/odeac/rchain/issues/comments{/number}","contents_url":"https://api.github.com/repos/odeac/rchain/contents/{+path}","compare_url":"https://api.github.com/repos/odeac/rchain/compare/{base}...{head}","merges_url":"https://api.github.com/repos/odeac/rchain/merges","archive_url":"https://api.github.com/repos/odeac/rchain/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/odeac/rchain/downloads","issues_url":"https://api.github.com/repos/odeac/rchain/issues{/number}","pulls_url":"https://api.github.com/repos/odeac/rchain/pulls{/number}","milestones_url":"https://api.github.com/repos/odeac/rchain/milestones{/number}","notifications_url":"https://api.github.com/repos/odeac/rchain/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/odeac/rchain/labels{/name}","releases_url":"https://api.github.com/repos/odeac/rchain/releases{/id}","deployments_url":"https://api.github.com/repos/odeac/rchain/deployments","created_at":"2018-05-29T05:27:29Z","updated_at":"2018-05-29T05:27:33Z","pushed_at":"2018-10-26T15:12:02Z","git_url":"git://github.com/odeac/rchain.git","ssh_url":"git@github.com:odeac/rchain.git","clone_url":"https://github.com/odeac/rchain.git","svn_url":"https://github.com/odeac/rchain","homepage":null,"size":18707,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"rchain:dev","ref":"dev","sha":"288f0f2f484af976aa0db7c713fc1d3e40477665","user":{"login":"rchain","id":20671765,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNjcxNzY1","avatar_url":"https://avatars0.githubusercontent.com/u/20671765?v=4","gravatar_id":"","url":"https://api.github.com/users/rchain","html_url":"https://github.com/rchain","followers_url":"https://api.github.com/users/rchain/followers","following_url":"https://api.github.com/users/rchain/following{/other_user}","gists_url":"https://api.github.com/users/rchain/gists{/gist_id}","starred_url":"https://api.github.com/users/rchain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchain/subscriptions","organizations_url":"https://api.github.com/users/rchain/orgs","repos_url":"https://api.github.com/users/rchain/repos","events_url":"https://api.github.com/users/rchain/events{/privacy}","received_events_url":"https://api.github.com/users/rchain/received_events","type":"Organization","site_admin":false},"repo":{"id":84493691,"node_id":"MDEwOlJlcG9zaXRvcnk4NDQ5MzY5MQ==","name":"rchain","full_name":"rchain/rchain","private":false,"owner":{"login":"rchain","id":20671765,"node_id":"MDEyOk9yZ2FuaXphdGlvbjIwNjcxNzY1","avatar_url":"https://avatars0.githubusercontent.com/u/20671765?v=4","gravatar_id":"","url":"https://api.github.com/users/rchain","html_url":"https://github.com/rchain","followers_url":"https://api.github.com/users/rchain/followers","following_url":"https://api.github.com/users/rchain/following{/other_user}","gists_url":"https://api.github.com/users/rchain/gists{/gist_id}","starred_url":"https://api.github.com/users/rchain/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rchain/subscriptions","organizations_url":"https://api.github.com/users/rchain/orgs","repos_url":"https://api.github.com/users/rchain/repos","events_url":"https://api.github.com/users/rchain/events{/privacy}","received_events_url":"https://api.github.com/users/rchain/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/rchain/rchain","description":null,"fork":false,"url":"https://api.github.com/repos/rchain/rchain","forks_url":"https://api.github.com/repos/rchain/rchain/forks","keys_url":"https://api.github.com/repos/rchain/rchain/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rchain/rchain/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rchain/rchain/teams","hooks_url":"https://api.github.com/repos/rchain/rchain/hooks","issue_events_url":"https://api.github.com/repos/rchain/rchain/issues/events{/number}","events_url":"https://api.github.com/repos/rchain/rchain/events","assignees_url":"https://api.github.com/repos/rchain/rchain/assignees{/user}","branches_url":"https://api.github.com/repos/rchain/rchain/branches{/branch}","tags_url":"https://api.github.com/repos/rchain/rchain/tags","blobs_url":"https://api.github.com/repos/rchain/rchain/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rchain/rchain/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rchain/rchain/git/refs{/sha}","trees_url":"https://api.github.com/repos/rchain/rchain/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rchain/rchain/statuses/{sha}","languages_url":"https://api.github.com/repos/rchain/rchain/languages","stargazers_url":"https://api.github.com/repos/rchain/rchain/stargazers","contributors_url":"https://api.github.com/repos/rchain/rchain/contributors","subscribers_url":"https://api.github.com/repos/rchain/rchain/subscribers","subscription_url":"https://api.github.com/repos/rchain/rchain/subscription","commits_url":"https://api.github.com/repos/rchain/rchain/commits{/sha}","git_commits_url":"https://api.github.com/repos/rchain/rchain/git/commits{/sha}","comments_url":"https://api.github.com/repos/rchain/rchain/comments{/number}","issue_comment_url":"https://api.github.com/repos/rchain/rchain/issues/comments{/number}","contents_url":"https://api.github.com/repos/rchain/rchain/contents/{+path}","compare_url":"https://api.github.com/repos/rchain/rchain/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rchain/rchain/merges","archive_url":"https://api.github.com/repos/rchain/rchain/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rchain/rchain/downloads","issues_url":"https://api.github.com/repos/rchain/rchain/issues{/number}","pulls_url":"https://api.github.com/repos/rchain/rchain/pulls{/number}","milestones_url":"https://api.github.com/repos/rchain/rchain/milestones{/number}","notifications_url":"https://api.github.com/repos/rchain/rchain/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rchain/rchain/labels{/name}","releases_url":"https://api.github.com/repos/rchain/rchain/releases{/id}","deployments_url":"https://api.github.com/repos/rchain/rchain/deployments","created_at":"2017-03-09T22:15:35Z","updated_at":"2018-10-26T15:22:59Z","pushed_at":"2018-10-26T15:22:53Z","git_url":"git://github.com/rchain/rchain.git","ssh_url":"git@github.com:rchain/rchain.git","clone_url":"https://github.com/rchain/rchain.git","svn_url":"https://github.com/rchain/rchain","homepage":null,"size":18879,"stargazers_count":466,"watchers_count":466,"language":"Scala","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":131,"mirror_url":null,"archived":false,"open_issues_count":32,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":131,"open_issues":32,"watchers":466,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/rchain/rchain/pulls/1736"},"html":{"href":"https://github.com/rchain/rchain/pull/1736"},"issue":{"href":"https://api.github.com/repos/rchain/rchain/issues/1736"},"comments":{"href":"https://api.github.com/repos/rchain/rchain/issues/1736/comments"},"review_comments":{"href":"https://api.github.com/repos/rchain/rchain/pulls/1736/comments"},"review_comment":{"href":"https://api.github.com/repos/rchain/rchain/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/rchain/rchain/pulls/1736/commits"},"statuses":{"href":"https://api.github.com/repos/rchain/rchain/statuses/8dc0e09e5ed5da0394f50f0510548037dfffd54a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"odeac"}}