diff --git a/src/test/app/ConfidentialTransfer_test.cpp b/src/test/app/ConfidentialTransfer_test.cpp index 68358599c1..f187f8a47c 100644 --- a/src/test/app/ConfidentialTransfer_test.cpp +++ b/src/test/app/ConfidentialTransfer_test.cpp @@ -18,7 +18,6 @@ //============================================================================== #include -#include #include #include diff --git a/src/test/jtx/confidentialTransfer.h b/src/test/jtx/confidentialTransfer.h deleted file mode 100644 index 9bf9391032..0000000000 --- a/src/test/jtx/confidentialTransfer.h +++ /dev/null @@ -1,45 +0,0 @@ -//------------------------------------------------------------------------------ -/* - This file is part of rippled: https://github.com/ripple/rippled - Copyright (c) 2024 Ripple Labs Inc. - - Permission to use, copy, modify, and/or distribute this software for any - purpose with or without fee is hereby granted, provided that the above - copyright notice and this permission notice appear in all copies. - - THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES - WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF - MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR - ANY SPECIAL , DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES - WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN - ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF - OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. -*/ -//============================================================================== - -#ifndef RIPPLE_TEST_JTX_CONFIDENTIALTRANSFER_H_INCLUDED -#define RIPPLE_TEST_JTX_CONFIDENTIALTRANSFER_H_INCLUDED - -#include -#include -#include - -namespace ripple { -namespace test { -namespace jtx { - -Json::Value -convert( - MPTID const mptId, - jtx::Account const& account, - std::uint64_t const amount, - std::optional holderPk, - std::string holderEncAmt, - std::string issuerEncAmt, - std::string zkp); - -} // namespace jtx -} // namespace test -} // namespace ripple - -#endif diff --git a/src/test/jtx/impl/mpt.cpp b/src/test/jtx/impl/mpt.cpp index fb2e9b4daa..fc83da173a 100644 --- a/src/test/jtx/impl/mpt.cpp +++ b/src/test/jtx/impl/mpt.cpp @@ -257,60 +257,77 @@ MPTTester::set(MPTSet const& arg) jv[sfMPTokenMetadata] = strHex(*arg.metadata); if (arg.pubKey) jv[sfIssuerElGamalPublicKey] = strHex(*arg.pubKey); - if (submit(arg, jv) == tesSUCCESS && (arg.flags || arg.mutableFlags)) + if (submit(arg, jv) == tesSUCCESS) { - auto require = [&](std::optional const& holder, - bool unchanged) { - auto flags = getFlags(holder); - if (!unchanged) - { - if (arg.flags) + if ((arg.flags || arg.mutableFlags)) + { + auto require = [&](std::optional const& holder, + bool unchanged) { + auto flags = getFlags(holder); + if (!unchanged) { - if (*arg.flags & tfMPTLock) - flags |= lsfMPTLocked; - else if (*arg.flags & tfMPTUnlock) - flags &= ~lsfMPTLocked; + if (arg.flags) + { + if (*arg.flags & tfMPTLock) + flags |= lsfMPTLocked; + else if (*arg.flags & tfMPTUnlock) + flags &= ~lsfMPTLocked; + } + + if (arg.mutableFlags) + { + if (*arg.mutableFlags & tmfMPTSetCanLock) + flags |= lsfMPTCanLock; + else if (*arg.mutableFlags & tmfMPTClearCanLock) + flags &= ~lsfMPTCanLock; + + if (*arg.mutableFlags & tmfMPTSetRequireAuth) + flags |= lsfMPTRequireAuth; + else if (*arg.mutableFlags & tmfMPTClearRequireAuth) + flags &= ~lsfMPTRequireAuth; + + if (*arg.mutableFlags & tmfMPTSetCanEscrow) + flags |= lsfMPTCanEscrow; + else if (*arg.mutableFlags & tmfMPTClearCanEscrow) + flags &= ~lsfMPTCanEscrow; + + if (*arg.mutableFlags & tmfMPTSetCanClawback) + flags |= lsfMPTCanClawback; + else if (*arg.mutableFlags & tmfMPTClearCanClawback) + flags &= ~lsfMPTCanClawback; + + if (*arg.mutableFlags & tmfMPTSetCanTrade) + flags |= lsfMPTCanTrade; + else if (*arg.mutableFlags & tmfMPTClearCanTrade) + flags &= ~lsfMPTCanTrade; + + if (*arg.mutableFlags & tmfMPTSetCanTransfer) + flags |= lsfMPTCanTransfer; + else if (*arg.mutableFlags & tmfMPTClearCanTransfer) + flags &= ~lsfMPTCanTransfer; + } } + env_.require(mptflags(*this, flags, holder)); + }; + if (arg.account) + require(std::nullopt, arg.holder.has_value()); + if (arg.holder) + require(*arg.holder, false); + } - if (arg.mutableFlags) - { - if (*arg.mutableFlags & tmfMPTSetCanLock) - flags |= lsfMPTCanLock; - else if (*arg.mutableFlags & tmfMPTClearCanLock) - flags &= ~lsfMPTCanLock; - - if (*arg.mutableFlags & tmfMPTSetRequireAuth) - flags |= lsfMPTRequireAuth; - else if (*arg.mutableFlags & tmfMPTClearRequireAuth) - flags &= ~lsfMPTRequireAuth; - - if (*arg.mutableFlags & tmfMPTSetCanEscrow) - flags |= lsfMPTCanEscrow; - else if (*arg.mutableFlags & tmfMPTClearCanEscrow) - flags &= ~lsfMPTCanEscrow; - - if (*arg.mutableFlags & tmfMPTSetCanClawback) - flags |= lsfMPTCanClawback; - else if (*arg.mutableFlags & tmfMPTClearCanClawback) - flags &= ~lsfMPTCanClawback; - - if (*arg.mutableFlags & tmfMPTSetCanTrade) - flags |= lsfMPTCanTrade; - else if (*arg.mutableFlags & tmfMPTClearCanTrade) - flags &= ~lsfMPTCanTrade; - - if (*arg.mutableFlags & tmfMPTSetCanTransfer) - flags |= lsfMPTCanTransfer; - else if (*arg.mutableFlags & tmfMPTClearCanTransfer) - flags &= ~lsfMPTCanTransfer; - } - } - env_.require(mptflags(*this, flags, holder)); - }; - if (arg.account) - require(std::nullopt, arg.holder.has_value()); - if (arg.holder) - require(*arg.holder, false); + if (arg.pubKey) + { + env_.require(requireAny([&]() -> bool { + return forObject([&](SLEP const& sle) -> bool { + if (sle) + { + return strHex((*sle)[sfIssuerElGamalPublicKey]) == + strHex(getPubKey(issuer_)); + } + return false; + }); + })); + } } } @@ -634,12 +651,12 @@ MPTTester::convert(MPTConvert const& arg) if (submit(arg, jv) == tesSUCCESS) { - auto const curConfidentialOutstanding = + auto const postConfidentialOutstanding = getIssuanceConfidentialBalance(); env_.require(mptbalance(*this, *arg.account, holderAmt - *arg.amt)); env_.require(requireAny([&]() -> bool { return prevConfidentialOutstanding + *arg.amt == - curConfidentialOutstanding; + postConfidentialOutstanding; })); uint64_t postInboxBalance = @@ -672,6 +689,22 @@ MPTTester::convert(MPTConvert const& arg) env_.require(requireAny([&]() -> bool { return postInboxBalance + postSpendingBalance == postIssuerBalance; })); + + if (arg.holderPubKey) + { + env_.require(requireAny([&]() -> bool { + return forObject( + [&](SLEP const& sle) -> bool { + if (sle) + { + return strHex((*sle)[sfHolderElGamalPublicKey]) == + strHex(getPubKey(*arg.account)); + } + return false; + }, + *arg.account); + })); + } } }