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); }