Skip to content

Commit

Permalink
Added more UT
Browse files Browse the repository at this point in the history
  • Loading branch information
oleks-rip committed Nov 13, 2024
1 parent 7de5cb5 commit e8ca019
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 2 deletions.
9 changes: 8 additions & 1 deletion src/test/app/PermissionedDomains_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include <xrpl/protocol/Issue.h>
#include <xrpl/protocol/jss.h>

#include <algorithm>
#include <exception>
#include <map>
#include <optional>
Expand Down Expand Up @@ -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"},
Expand Down Expand Up @@ -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));

Expand Down
3 changes: 2 additions & 1 deletion src/test/jtx/fee.h
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ class fee
Throw<std::runtime_error>("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}}
{
}

Expand Down
20 changes: 20 additions & 0 deletions src/test/rpc/LedgerRPC_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e8ca019

Please sign in to comment.