From 188fd2b18eef15a7ff7f6195ffaf047b3db9e79b Mon Sep 17 00:00:00 2001 From: Oleksandr <115580134+oleks-rip@users.noreply.github.com> Date: Wed, 13 Nov 2024 13:49:13 -0500 Subject: [PATCH] Added more UT --- src/test/app/PermissionedDomains_test.cpp | 9 ++++++++- src/test/jtx/fee.h | 2 +- src/test/rpc/LedgerRPC_test.cpp | 20 ++++++++++++++++++++ 3 files changed, 29 insertions(+), 2 deletions(-) diff --git a/src/test/app/PermissionedDomains_test.cpp b/src/test/app/PermissionedDomains_test.cpp index 7955aa7fe02..52c9e02aa03 100644 --- a/src/test/app/PermissionedDomains_test.cpp +++ b/src/test/app/PermissionedDomains_test.cpp @@ -26,7 +26,6 @@ #include #include -#include #include #include #include @@ -144,6 +143,11 @@ class PermissionedDomains_test : public beast::unit_test::suite {alice7, "credential7"}}; env(pd::setTx(account, credentialsNon, domain), ter(tecNO_ISSUER)); + // Test bad fee + env(pd::setTx(account, credentials11, domain), + fee(1, true), + ter(temBAD_FEE)); + pd::Credentials const credentials4{ {alice2, "credential1"}, {alice3, "credential2"}, @@ -401,6 +405,9 @@ class PermissionedDomains_test : public beast::unit_test::suite // Delete a non-existent domain. env(pd::deleteTx(alice, uint256(75)), ter(tecNO_ENTRY)); + // Test bad fee + env(pd::deleteTx(alice, uint256(75)), ter(temBAD_FEE), fee(1, true)); + // Delete a zero domain. env(pd::deleteTx(alice, uint256(0)), ter(temMALFORMED)); diff --git a/src/test/jtx/fee.h b/src/test/jtx/fee.h index c671e0b2a1e..ab7a743a3d0 100644 --- a/src/test/jtx/fee.h +++ b/src/test/jtx/fee.h @@ -53,7 +53,7 @@ class fee Throw("fee: not XRP"); } - explicit fee(std::uint64_t amount) : fee{STAmount{amount}} + explicit fee(std::uint64_t amount, bool negative = false) : fee{STAmount{amount, negative}} { } diff --git a/src/test/rpc/LedgerRPC_test.cpp b/src/test/rpc/LedgerRPC_test.cpp index 76e9feeb83b..99b0f0a23fc 100644 --- a/src/test/rpc/LedgerRPC_test.cpp +++ b/src/test/rpc/LedgerRPC_test.cpp @@ -3113,6 +3113,26 @@ class LedgerRPC_test : public beast::unit_test::suite jss::PermissionedDomain); } + { + // Fail, invalid permissioned domain index + Json::Value params; + params[jss::ledger_index] = jss::validated; + params[jss::permissioned_domain] = + "12F1F1F1F180D67377B2FAB292A31C922470326268D2B9B74CD1E582645B9A" + "DE"; + auto const jrr = env.rpc("json", "ledger_entry", to_string(params)); + checkErrorValue(jrr[jss::result], "entryNotFound", ""); + } + + { + // Fail, invalid permissioned domain index + Json::Value params; + params[jss::ledger_index] = jss::validated; + params[jss::permissioned_domain] = "NotAHexString"; + auto const jrr = env.rpc("json", "ledger_entry", to_string(params)); + checkErrorValue(jrr[jss::result], "malformedRequest", ""); + } + { // Fail, invalid account Json::Value params;