From 97cac67bba940a592afb02d34287768cd4fcc2fc Mon Sep 17 00:00:00 2001 From: Denis Angell Date: Tue, 24 Oct 2023 23:14:19 +0200 Subject: [PATCH] Patch import (#150) * add index test * remove comment * remove warn env --- src/test/app/Import_test.cpp | 47 ++++++++++++++++++++++++++++-- src/test/app/LedgerMaster_test.cpp | 2 -- src/test/app/XahauGenesis_test.cpp | 5 +--- 3 files changed, 45 insertions(+), 9 deletions(-) diff --git a/src/test/app/Import_test.cpp b/src/test/app/Import_test.cpp index 43bded54b..992215005 100644 --- a/src/test/app/Import_test.cpp +++ b/src/test/app/Import_test.cpp @@ -297,7 +297,6 @@ class Import_test : public beast::unit_test::suite BEAST_EXPECT(result1 == 1234); // std::optional result2 = parse_uint64("0xFFAABBCCDD22"); - // std::cout << "RESULT: " << *result2 << "\n"; // BEAST_EXPECT(result2 == 0xFFAABBCCDD22); std::optional result3 = parse_uint64("2147483647"); @@ -768,6 +767,27 @@ class Import_test : public beast::unit_test::suite BEAST_EXPECT( syntaxCheckXPOP(raw, env.journal).has_value() == false); } + // XPOP.ledger.index missing or wrong format + // invalid xpop.ledger.index (must be int) + { + std::string strJson = R"json({ + "ledger": { + "acroot": "DCE36DCACDCFCB3441866E09A183B7B8064B3F5E06593CD6AA8ACCC1B284B477", + "txroot": "409C8D073DDB5AB07FD2CD4F14467A8F3BC8FFBA16A0032D12D823D8511C12F4", + "phash": "BAB19E13B25251A83493073F424FD986EA7BA49F9F4C83A061700131460D747D", + "close": 738786851, + "coins": "99999998999999868", + "cres": 10, + "flags": "not an int", + "index": "1" + }, + "transaction": {}, + "validation": {} + })json"; + Blob raw = Blob(strJson.begin(), strJson.end()); + BEAST_EXPECT( + syntaxCheckXPOP(raw, env.journal).has_value() == false); + } // XPOP.ledger.pclose missing or wrong format // invalid xpop.ledger.pclose (must be int) { @@ -780,6 +800,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": "not an int" }, "transaction": {}, @@ -804,6 +825,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -828,6 +850,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -852,6 +875,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -877,6 +901,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -902,6 +927,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -928,6 +954,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -966,6 +993,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1009,6 +1037,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1050,6 +1079,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1091,6 +1121,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1135,6 +1166,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1179,6 +1211,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1223,6 +1256,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1266,6 +1300,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1310,6 +1345,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1355,6 +1391,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1400,6 +1437,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1446,6 +1484,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1492,6 +1531,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1528,7 +1568,6 @@ class Import_test : public beast::unit_test::suite } // XPOP.validation.unl entry has wrong format - // valid xpop { std::string strJson = R"json({ @@ -1540,6 +1579,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -1594,6 +1634,7 @@ class Import_test : public beast::unit_test::suite "coins": "99999998999999868", "cres": 10, "flags": 10, + "index": 1, "pclose": 738786851 }, "transaction": { @@ -2379,7 +2420,7 @@ class Import_test : public beast::unit_test::suite // temMALFORMED - Import: !proof.isObject() && !proof.isArray() { Json::Value tmpXpop = loadXpop(ImportTCAccountSet::w_seed); - tmpXpop[jss::transaction][jss::proof] = "not object"; + tmpXpop[jss::transaction][jss::proof] = "not a object"; Json::Value const tx = import(alice, tmpXpop); env(tx, ter(temMALFORMED)); } diff --git a/src/test/app/LedgerMaster_test.cpp b/src/test/app/LedgerMaster_test.cpp index 6729772b4..4e5a4c94c 100644 --- a/src/test/app/LedgerMaster_test.cpp +++ b/src/test/app/LedgerMaster_test.cpp @@ -100,7 +100,6 @@ class LedgerMaster_test : public beast::unit_test::suite uint32_t txnIndex = metas[0]->getFieldU32(sfTransactionIndex); auto result = env.app().getLedgerMaster().txnIdFromIndex( startLegSeq, txnIndex); - std::cout << "RESULT: " << *result << "\n"; BEAST_EXPECT( *result == uint256("0CC11AD1AD89661689F6B6148D82CB6A7101DA4D66EC843670262D" @@ -111,7 +110,6 @@ class LedgerMaster_test : public beast::unit_test::suite uint32_t txnIndex = metas[1]->getFieldU32(sfTransactionIndex); auto result = env.app().getLedgerMaster().txnIdFromIndex( startLegSeq + 1, txnIndex); - std::cout << "RESULT: " << *result << "\n"; BEAST_EXPECT( *result == uint256("DCAECE52F028B9D0F7CA43CBE15AB4EF7B84A8EF5D455238992E1E" diff --git a/src/test/app/XahauGenesis_test.cpp b/src/test/app/XahauGenesis_test.cpp index f9c83b430..7c793017d 100644 --- a/src/test/app/XahauGenesis_test.cpp +++ b/src/test/app/XahauGenesis_test.cpp @@ -620,10 +620,7 @@ struct XahauGenesis_test : public beast::unit_test::suite using namespace jtx; testcase("Test governance membership voting L1"); - Env env{*this, envconfig(), features - featureXahauGenesis, nullptr, - beast::severities::kWarning -// beast::severities::kTrace - }; + Env env{*this, envconfig(), features - featureXahauGenesis, nullptr}; auto const alice = Account("alice"); auto const bob = Account("bob");