{"action":"created","comment":{"url":"https://api.github.com/repos/ripple/rippled/pulls/comments/91807030","pull_request_review_id":12320628,"id":91807030,"diff_hunk":"@@ -0,0 +1,4089 @@\n+//------------------------------------------------------------------------------\n+/*\n+  This file is part of rippled: https://github.com/ripple/rippled\n+  Copyright (c) 2012-2016 Ripple Labs Inc.\n+\n+  Permission to use, copy, modify, and/or distribute this software for any\n+  purpose  with  or without fee is hereby granted, provided that the above\n+  copyright notice and this permission notice appear in all copies.\n+\n+  THE  SOFTWARE IS PROVIDED \"AS IS\" AND THE AUTHOR DISCLAIMS ALL WARRANTIES\n+  WITH  REGARD  TO  THIS  SOFTWARE  INCLUDING  ALL  IMPLIED  WARRANTIES  OF\n+  MERCHANTABILITY  AND  FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR\n+  ANY  SPECIAL ,  DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES\n+  WHATSOEVER  RESULTING  FROM  LOSS  OF USE, DATA OR PROFITS, WHETHER IN AN\n+  ACTION  OF  CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF\n+  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.\n+*/\n+//==============================================================================\n+\n+#include <BeastConfig.h>\n+#include <ripple/test/jtx.h>\n+#include <ripple/test/jtx/Env.h>\n+#include <ripple/beast/unit_test.h>\n+#include <ripple/beast/core/LexicalCast.h>\n+#include <ripple/protocol/JsonFields.h>\n+#include <ripple/protocol/SField.h>\n+#include <boost/filesystem.hpp>\n+#include <ripple/basics/StringUtilities.h>\n+\n+namespace ripple {\n+\n+extern std::array<char const*,20> ledgerXRPDiscrepancyData;\n+\n+class Discrepancy_test : public beast::unit_test::suite\n+{\n+    // This is a legacy test ported from js/coffee. It starts with\n+    // a saved ledger, submits a transaction as a blob and then queries\n+    // that transaction to verify that the net of balance changes match\n+    // the fee charged.\n+    void\n+    testXRPDiscrepancy ()\n+    {\n+        testcase (\"Discrepancy test : XRP Discrepancy\");\n+        using namespace test::jtx;\n+\n+        boost::system::error_code ec;\n+        // create a temporary path to write DB files to and\n+        // our starting ledger data\n+        auto path  = boost::filesystem::temp_directory_path(ec);\n+        BEAST_EXPECTS(!ec, ec.message());\n+        path /= boost::filesystem::unique_path(\"%%%%-%%%%-%%%%-%%%%\", ec);\n+        BEAST_EXPECTS(!ec, ec.message());\n+        boost::filesystem::create_directories(path, ec);\n+        BEAST_EXPECTS(!ec, ec.message());\n+\n+        auto ledgerFile = path / \"ledgerdata.json\";\n+        std::ofstream o (ledgerFile.string(), std::ios::out | std::ios::trunc);\n+        for(auto p : ledgerXRPDiscrepancyData)\n+            o << p;\n+        o.close();\n+\n+        {\n+            Env env(*this, [&]()\n+                {\n+                    auto p = std::make_unique<Config>();\n+                    test::setupConfigForUnitTests(*p);\n+                    p->START_LEDGER = ledgerFile.string();\n+                    p->START_UP = Config::LOAD_FILE;\n+                    p->legacy(\"database_path\", path.string());\n+                    return p;\n+                }());\n+\n+\n+            Json::Value jrq;\n+            jrq[jss::id] = 1;\n+            jrq[jss::tx_blob] =\n+                \"1200002200020000240000124E61D5438D7EA4C680000000000000000000000\"\n+                \"000004A50590000000000E5C92828261DBAAC933B6309C6F5C72AF020AFD468\"\n+                \"400000000000000A69D4D3E7809B4814C8000000000000000000000000434E5\"\n+                \"9000000000041C8BE2C0A6AA17471B9F6D0AF92AAB1C94D5A25732103FC5F96E\"\n+                \"A61889691EC7A56FB2B859B600DE68C0255BF580D5C22D02EB97AFCE47447304\"\n+                \"5022100D14B60BC6E01E5C19471F87EB00A4BFCA16D039BB91AEE12DA1142E8C\"\n+                \"4CAE7C2022020E2809CF24DE2BC0C3DCF1A07C469DB415F880485B2B323E5B5A\"\n+                \"A1D9F6F22D48114AFD96601692A6C6416DBA294F0DA684675A824B28314AFD96\"\n+                \"601692A6C6416DBA294F0DA684675A824B201123000000000000000000000000\"\n+                \"04A50590000000000E5C92828261DBAAC933B6309C6F5C72AF020AFD401E5C92\"\n+                \"828261DBAAC933B6309C6F5C72AF020AFD4FF100000000000000000000000000\"\n+                \"000000000000000300000000000000000000000004A50590000000000E5C9282\"\n+                \"8261DBAAC933B6309C6F5C72AF020AFD401E5C92828261DBAAC933B6309C6F5C\"\n+                \"72AF020AFD4FF01A034782E2DBAC4FB82B601CD50421E8EF24F3A00100000000\"\n+                \"000000000000000000000000000000000300000000000000000000000004A505\"\n+                \"90000000000E5C92828261DBAAC933B6309C6F5C72AF020AFD401E5C92828261\"\n+                \"DBAAC933B6309C6F5C72AF020AFD400\";\n+            auto jrr = env.rpc (\"json\", \"submit\", to_string(jrq))[jss::result];\n+            auto hash = jrr[jss::tx_json][jss::hash];\n+            env.close();\n+            Json::Value jrq2;\n+            jrq2[jss::binary] = false;\n+            jrq2[jss::transaction] = hash;\n+            jrq2[jss::id] = 3;\n+            jrr = env.rpc (\"json\", \"tx\", to_string(jrq2))[jss::result];\n+            uint64_t fee = jrr[jss::Fee].asUInt();\n+            auto meta = jrr[jss::meta];\n+            auto sumPrev = UINT64_C(0);\n+            auto sumFinal = UINT64_C(0);\n+            for(auto const& an : meta[sfAffectedNodes.fieldName])\n+            {\n+                Json::Value node;\n+                if(an.isMember(sfCreatedNode.fieldName))\n+                    node = an[sfCreatedNode.fieldName];\n+                else if(an.isMember(sfModifiedNode.fieldName))\n+                    node = an[sfModifiedNode.fieldName];\n+                else if(an.isMember(sfDeletedNode.fieldName))\n+                    node = an[sfDeletedNode.fieldName];\n+\n+                if(node && node[sfLedgerEntryType.fieldName] == \"AccountRoot\")\n+                {\n+                    Json::Value prevFields =\n+                        node.isMember(sfPreviousFields.fieldName) ?\n+                        node[sfPreviousFields.fieldName] :\n+                        node[sfNewFields.fieldName];\n+                    Json::Value finalFields =\n+                        node.isMember(sfFinalFields.fieldName) ?\n+                        node[sfFinalFields.fieldName] :\n+                        node[sfNewFields.fieldName];\n+                    if(prevFields)\n+                        sumPrev += beast::lexicalCastThrow<std::uint64_t>(\n+                            prevFields[sfBalance.fieldName].asString());\n+                    if(finalFields)\n+                        sumFinal += beast::lexicalCastThrow<std::uint64_t>(\n+                            finalFields[sfBalance.fieldName].asString());\n+                }\n+            }\n+            // the difference in balances (final and prev) should be the\n+            // fee charged\n+            BEAST_EXPECT(sumPrev-sumFinal == fee);\n+        }\n+\n+        boost::filesystem::remove_all(path, ec);","path":"src/test/app/Discrepancy_test.cpp","position":139,"original_position":139,"commit_id":"b9e489056e10a7755aa5ab57c781b39677b839bf","original_commit_id":"b9e489056e10a7755aa5ab57c781b39677b839bf","user":{"login":"mellery451","id":463430,"avatar_url":"https://avatars.githubusercontent.com/u/463430?v=3","gravatar_id":"","url":"https://api.github.com/users/mellery451","html_url":"https://github.com/mellery451","followers_url":"https://api.github.com/users/mellery451/followers","following_url":"https://api.github.com/users/mellery451/following{/other_user}","gists_url":"https://api.github.com/users/mellery451/gists{/gist_id}","starred_url":"https://api.github.com/users/mellery451/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellery451/subscriptions","organizations_url":"https://api.github.com/users/mellery451/orgs","repos_url":"https://api.github.com/users/mellery451/repos","events_url":"https://api.github.com/users/mellery451/events{/privacy}","received_events_url":"https://api.github.com/users/mellery451/received_events","type":"User","site_admin":false},"body":"good point  -- will fix.","created_at":"2016-12-09T22:19:46Z","updated_at":"2016-12-09T22:19:46Z","html_url":"https://github.com/ripple/rippled/pull/1930#discussion_r91807030","pull_request_url":"https://api.github.com/repos/ripple/rippled/pulls/1930","_links":{"self":{"href":"https://api.github.com/repos/ripple/rippled/pulls/comments/91807030"},"html":{"href":"https://github.com/ripple/rippled/pull/1930#discussion_r91807030"},"pull_request":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1930"}}},"pull_request":{"url":"https://api.github.com/repos/ripple/rippled/pulls/1930","id":97041682,"html_url":"https://github.com/ripple/rippled/pull/1930","diff_url":"https://github.com/ripple/rippled/pull/1930.diff","patch_url":"https://github.com/ripple/rippled/pull/1930.patch","issue_url":"https://api.github.com/repos/ripple/rippled/issues/1930","number":1930,"state":"open","locked":false,"title":"Port discrepancy-test.coffee to c++ (RIPD-1352):","user":{"login":"mellery451","id":463430,"avatar_url":"https://avatars.githubusercontent.com/u/463430?v=3","gravatar_id":"","url":"https://api.github.com/users/mellery451","html_url":"https://github.com/mellery451","followers_url":"https://api.github.com/users/mellery451/followers","following_url":"https://api.github.com/users/mellery451/following{/other_user}","gists_url":"https://api.github.com/users/mellery451/gists{/gist_id}","starred_url":"https://api.github.com/users/mellery451/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellery451/subscriptions","organizations_url":"https://api.github.com/users/mellery451/orgs","repos_url":"https://api.github.com/users/mellery451/repos","events_url":"https://api.github.com/users/mellery451/events{/privacy}","received_events_url":"https://api.github.com/users/mellery451/received_events","type":"User","site_admin":false},"body":"Add jtx unit test that verifies a transaction net balance against the\r\nreported fee.","created_at":"2016-12-08T01:17:27Z","updated_at":"2016-12-09T22:19:46Z","closed_at":null,"merged_at":null,"merge_commit_sha":"ad86e36f6557f4620670bd470fd5d1f174d6f571","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/ripple/rippled/pulls/1930/commits","review_comments_url":"https://api.github.com/repos/ripple/rippled/pulls/1930/comments","review_comment_url":"https://api.github.com/repos/ripple/rippled/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ripple/rippled/issues/1930/comments","statuses_url":"https://api.github.com/repos/ripple/rippled/statuses/b9e489056e10a7755aa5ab57c781b39677b839bf","head":{"label":"mellery451:discr_test","ref":"discr_test","sha":"b9e489056e10a7755aa5ab57c781b39677b839bf","user":{"login":"mellery451","id":463430,"avatar_url":"https://avatars.githubusercontent.com/u/463430?v=3","gravatar_id":"","url":"https://api.github.com/users/mellery451","html_url":"https://github.com/mellery451","followers_url":"https://api.github.com/users/mellery451/followers","following_url":"https://api.github.com/users/mellery451/following{/other_user}","gists_url":"https://api.github.com/users/mellery451/gists{/gist_id}","starred_url":"https://api.github.com/users/mellery451/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellery451/subscriptions","organizations_url":"https://api.github.com/users/mellery451/orgs","repos_url":"https://api.github.com/users/mellery451/repos","events_url":"https://api.github.com/users/mellery451/events{/privacy}","received_events_url":"https://api.github.com/users/mellery451/received_events","type":"User","site_admin":false},"repo":{"id":63169724,"name":"rippled","full_name":"mellery451/rippled","owner":{"login":"mellery451","id":463430,"avatar_url":"https://avatars.githubusercontent.com/u/463430?v=3","gravatar_id":"","url":"https://api.github.com/users/mellery451","html_url":"https://github.com/mellery451","followers_url":"https://api.github.com/users/mellery451/followers","following_url":"https://api.github.com/users/mellery451/following{/other_user}","gists_url":"https://api.github.com/users/mellery451/gists{/gist_id}","starred_url":"https://api.github.com/users/mellery451/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mellery451/subscriptions","organizations_url":"https://api.github.com/users/mellery451/orgs","repos_url":"https://api.github.com/users/mellery451/repos","events_url":"https://api.github.com/users/mellery451/events{/privacy}","received_events_url":"https://api.github.com/users/mellery451/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mellery451/rippled","description":"Ripple peer-to-peer network daemon","fork":true,"url":"https://api.github.com/repos/mellery451/rippled","forks_url":"https://api.github.com/repos/mellery451/rippled/forks","keys_url":"https://api.github.com/repos/mellery451/rippled/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mellery451/rippled/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mellery451/rippled/teams","hooks_url":"https://api.github.com/repos/mellery451/rippled/hooks","issue_events_url":"https://api.github.com/repos/mellery451/rippled/issues/events{/number}","events_url":"https://api.github.com/repos/mellery451/rippled/events","assignees_url":"https://api.github.com/repos/mellery451/rippled/assignees{/user}","branches_url":"https://api.github.com/repos/mellery451/rippled/branches{/branch}","tags_url":"https://api.github.com/repos/mellery451/rippled/tags","blobs_url":"https://api.github.com/repos/mellery451/rippled/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mellery451/rippled/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mellery451/rippled/git/refs{/sha}","trees_url":"https://api.github.com/repos/mellery451/rippled/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mellery451/rippled/statuses/{sha}","languages_url":"https://api.github.com/repos/mellery451/rippled/languages","stargazers_url":"https://api.github.com/repos/mellery451/rippled/stargazers","contributors_url":"https://api.github.com/repos/mellery451/rippled/contributors","subscribers_url":"https://api.github.com/repos/mellery451/rippled/subscribers","subscription_url":"https://api.github.com/repos/mellery451/rippled/subscription","commits_url":"https://api.github.com/repos/mellery451/rippled/commits{/sha}","git_commits_url":"https://api.github.com/repos/mellery451/rippled/git/commits{/sha}","comments_url":"https://api.github.com/repos/mellery451/rippled/comments{/number}","issue_comment_url":"https://api.github.com/repos/mellery451/rippled/issues/comments{/number}","contents_url":"https://api.github.com/repos/mellery451/rippled/contents/{+path}","compare_url":"https://api.github.com/repos/mellery451/rippled/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mellery451/rippled/merges","archive_url":"https://api.github.com/repos/mellery451/rippled/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mellery451/rippled/downloads","issues_url":"https://api.github.com/repos/mellery451/rippled/issues{/number}","pulls_url":"https://api.github.com/repos/mellery451/rippled/pulls{/number}","milestones_url":"https://api.github.com/repos/mellery451/rippled/milestones{/number}","notifications_url":"https://api.github.com/repos/mellery451/rippled/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mellery451/rippled/labels{/name}","releases_url":"https://api.github.com/repos/mellery451/rippled/releases{/id}","deployments_url":"https://api.github.com/repos/mellery451/rippled/deployments","created_at":"2016-07-12T15:29:01Z","updated_at":"2016-07-12T15:29:12Z","pushed_at":"2016-12-09T17:51:54Z","git_url":"git://github.com/mellery451/rippled.git","ssh_url":"git@github.com:mellery451/rippled.git","clone_url":"https://github.com/mellery451/rippled.git","svn_url":"https://github.com/mellery451/rippled","homepage":"https://ripple.com","size":79545,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"develop"}},"base":{"label":"ripple:develop","ref":"develop","sha":"4d7b1a3b61484d43b300ceb01a69c77fa0c0d4e8","user":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"repo":{"id":2724167,"name":"rippled","full_name":"ripple/rippled","owner":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ripple/rippled","description":"Decentralized cryptocurrency blockchain daemon implementing the Ripple Consensus Ledger in C++","fork":false,"url":"https://api.github.com/repos/ripple/rippled","forks_url":"https://api.github.com/repos/ripple/rippled/forks","keys_url":"https://api.github.com/repos/ripple/rippled/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ripple/rippled/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ripple/rippled/teams","hooks_url":"https://api.github.com/repos/ripple/rippled/hooks","issue_events_url":"https://api.github.com/repos/ripple/rippled/issues/events{/number}","events_url":"https://api.github.com/repos/ripple/rippled/events","assignees_url":"https://api.github.com/repos/ripple/rippled/assignees{/user}","branches_url":"https://api.github.com/repos/ripple/rippled/branches{/branch}","tags_url":"https://api.github.com/repos/ripple/rippled/tags","blobs_url":"https://api.github.com/repos/ripple/rippled/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ripple/rippled/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ripple/rippled/git/refs{/sha}","trees_url":"https://api.github.com/repos/ripple/rippled/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ripple/rippled/statuses/{sha}","languages_url":"https://api.github.com/repos/ripple/rippled/languages","stargazers_url":"https://api.github.com/repos/ripple/rippled/stargazers","contributors_url":"https://api.github.com/repos/ripple/rippled/contributors","subscribers_url":"https://api.github.com/repos/ripple/rippled/subscribers","subscription_url":"https://api.github.com/repos/ripple/rippled/subscription","commits_url":"https://api.github.com/repos/ripple/rippled/commits{/sha}","git_commits_url":"https://api.github.com/repos/ripple/rippled/git/commits{/sha}","comments_url":"https://api.github.com/repos/ripple/rippled/comments{/number}","issue_comment_url":"https://api.github.com/repos/ripple/rippled/issues/comments{/number}","contents_url":"https://api.github.com/repos/ripple/rippled/contents/{+path}","compare_url":"https://api.github.com/repos/ripple/rippled/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ripple/rippled/merges","archive_url":"https://api.github.com/repos/ripple/rippled/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ripple/rippled/downloads","issues_url":"https://api.github.com/repos/ripple/rippled/issues{/number}","pulls_url":"https://api.github.com/repos/ripple/rippled/pulls{/number}","milestones_url":"https://api.github.com/repos/ripple/rippled/milestones{/number}","notifications_url":"https://api.github.com/repos/ripple/rippled/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ripple/rippled/labels{/name}","releases_url":"https://api.github.com/repos/ripple/rippled/releases{/id}","deployments_url":"https://api.github.com/repos/ripple/rippled/deployments","created_at":"2011-11-07T04:40:15Z","updated_at":"2016-12-06T08:39:30Z","pushed_at":"2016-12-09T16:02:18Z","git_url":"git://github.com/ripple/rippled.git","ssh_url":"git@github.com:ripple/rippled.git","clone_url":"https://github.com/ripple/rippled.git","svn_url":"https://github.com/ripple/rippled","homepage":"https://ripple.com","size":133731,"stargazers_count":1187,"watchers_count":1187,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":370,"mirror_url":null,"open_issues_count":130,"forks":370,"open_issues":130,"watchers":1187,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1930"},"html":{"href":"https://github.com/ripple/rippled/pull/1930"},"issue":{"href":"https://api.github.com/repos/ripple/rippled/issues/1930"},"comments":{"href":"https://api.github.com/repos/ripple/rippled/issues/1930/comments"},"review_comments":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1930/comments"},"review_comment":{"href":"https://api.github.com/repos/ripple/rippled/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1930/commits"},"statuses":{"href":"https://api.github.com/repos/ripple/rippled/statuses/b9e489056e10a7755aa5ab57c781b39677b839bf"}}}}
{"actor":{"display_login":"mellery451"}}