Files
rippled/src/test/app/SetAuth_test.cpp
Bart 1d42c4f6de refactor: Remove unnecessary copyright notices already covered by LICENSE.md (#5929)
Per XLS-0095, we are taking steps to rename ripple(d) to xrpl(d).

This change specifically removes all copyright notices referencing Ripple, XRPLF, and certain affiliated contributors upon mutual agreement, so the notice in the LICENSE.md file applies throughout. Copyright notices referencing external contributions remain as-is. Duplicate verbiage is also removed.
2025-11-04 08:33:42 +00:00

68 lines
1.8 KiB
C++

#include <test/jtx.h>
#include <xrpl/protocol/Feature.h>
#include <xrpl/protocol/jss.h>
namespace ripple {
namespace test {
struct SetAuth_test : public beast::unit_test::suite
{
// Set just the tfSetfAuth flag on a trust line
// If the trust line does not exist, then it should
// be created under the new rules.
static Json::Value
auth(
jtx::Account const& account,
jtx::Account const& dest,
std::string const& currency)
{
using namespace jtx;
Json::Value jv;
jv[jss::Account] = account.human();
jv[jss::LimitAmount] = STAmount(Issue{to_currency(currency), dest})
.getJson(JsonOptions::none);
jv[jss::TransactionType] = jss::TrustSet;
jv[jss::Flags] = tfSetfAuth;
return jv;
}
void
testAuth(FeatureBitset features)
{
using namespace jtx;
auto const gw = Account("gw");
auto const USD = gw["USD"];
Env env(*this);
env.fund(XRP(100000), "alice", "bob", gw);
env(fset(gw, asfRequireAuth));
env.close();
env(auth(gw, "alice", "USD"));
BEAST_EXPECT(
env.le(keylet::line(Account("alice").id(), gw.id(), USD.currency)));
env(trust("alice", USD(1000)));
env(trust("bob", USD(1000)));
env(pay(gw, "alice", USD(100)));
env(pay(gw, "bob", USD(100)),
ter(tecPATH_DRY)); // Should be terNO_AUTH
env(pay("alice", "bob", USD(50)),
ter(tecPATH_DRY)); // Should be terNO_AUTH
}
void
run() override
{
using namespace jtx;
auto const sa = testable_amendments();
testAuth(sa - featurePermissionedDEX);
testAuth(sa);
}
};
BEAST_DEFINE_TESTSUITE(SetAuth, app, ripple);
} // namespace test
} // namespace ripple