From a01c60124200549bf1e33bfba3bce1ccce5c5ecc Mon Sep 17 00:00:00 2001 From: Richard Holland Date: Tue, 29 Aug 2023 13:37:14 +0000 Subject: [PATCH] start governance test cases --- src/test/app/XahauGenesis_test.cpp | 44 ++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/src/test/app/XahauGenesis_test.cpp b/src/test/app/XahauGenesis_test.cpp index b8f95a7c9..25410d0e1 100644 --- a/src/test/app/XahauGenesis_test.cpp +++ b/src/test/app/XahauGenesis_test.cpp @@ -322,9 +322,11 @@ struct XahauGenesis_test : public beast::unit_test::suite env.close(); } + void testGovernance() { + using namespace jtx; testcase("Test governance hook"); @@ -341,6 +343,48 @@ struct XahauGenesis_test : public beast::unit_test::suite setupGov(env, {alice.id(), bob.id(), carol.id(), david.id(), edward.id()}); + auto vote = [](uint8_t topic1, + std::optional topic2, + std::vector data, + std::optional layer, + Json::Value& txn) + { + auto charToHex = [](uint8_t inp) -> std::string + { + std::string s; + s.reserve(2); + s += "0123456789ABCDEF"[inp >> 4]; + s += "0123456789ABCDEF"[inp >> 0]; + return s; + }; + + txn[jss::HookParameters] = Json::arrayValue; + txn[jss::HookParameters][0u][jss::HookParameter] = Json::objectValue; + txn[jss::HookParameters][0u][jss::HookParameter][jss::HookParameterName] = + "54"; // 'T' + txn[jss::HookParameters][0u][jss::HookParameter][jss::HookParameterValue] = + charToHex(topic1) + (topic2 ? charToHex(*topic2) : ""); + + txn[jss::HookParameters][1u][jss::HookParameter][jss::HookParameterName] = + "56"; // 'V' + + std::string strData; + strData.reserve(data.size() << 1U); + for (uint8_t c : data) + strData += charToHex(c); + + txn[jss::HookParameters][1u][jss::HookParameter][jss::HookParameterValue] = strData; + + + if (layer) + { + txn[jss::HookParameters][2u][jss::HookParameter][jss::HookParameterName] = "4C"; + txn[jss::HookParameters][2u][jss::HookParameter][jss::HookParameterValue] = charToHex(*layer); + } + }; + + + BEAST_EXPECT(true); }